https://github.com/shonejin/Minesweeper/blob/master/src/com/shonejin/minesweeper/game/Board.java
我研究Minesweeper算法。我想开始游戏并附加标志。
我在第65行修改了以下代码,但未更改
// randomly place mines in the board
// and update "count of mines" of neighboring cells
private void putMines() {
Random rand = new Random();
int mines = NMines;
while (mines-- > 0) {
int pos = rand.nextInt(NCovered);
int x = pos % N;
int y = pos / N;
if (isMine[y][x])
mines++;
else {
isMine[y][x] = true;
for (int d = 0; d < di.length; d++) {
mineCnt[y + di[d] + 1][x + dj[d] + 1]++;
states[x][y] = CellStates.FLAGGED // What I attached
}
}
}
}