私は人生のゲームを試みています- 私が立ち往生しているのは、その周囲の領域に基づいて、空間が生きているか死んでいるかを判断することです. 私は自分が何を間違っているのか分からないところまで来ています - 願わくば、別の目が助けてくれることを願っています。
これは単なるスニペットで、完全なコードはこちら: http://pastebin.com/ucYe653p
public static void updateMatrix(boolean[][] board, int[] birthLive) {
//clone the board so modified values don't affect the results of upcoming spaces
boolean[][] boardCopy = board.clone();
for (int i = 0; i < board.length; i++)
boardCopy[i] = board[i].clone();
int count = 0;
for (int i = 1; i < board.length - 1; i++) {
for (int j = 1; j < board[i].length - 1; j++) {
//different requirements for dead or living pieces' living status
if (board[i][j] == false) {
//check the nine-by-nine square, starting at (-1, 1) and ending at (1, -1) where 0 is the affected location
// * * *
// * 0 *
// * * *
for (int ii = board[i - 1].length; ii < board[i + 1].length; ii++) {
for (int jj = board[j - 1].length; ii < board[j + 1].length; jj++) {
if (boardCopy[i][j] == true)
count++;
}
}
//check to see what high and low amt of required adjacent lifeforms is
if (count >= birthLive[0] && count <= birthLive[1])
board[i][j] = true;
else
board[i][j] = false;
count = 0;
}
else {
for (int ii = board[i - 1].length; ii < board[i + 1].length; ii++) {
for (int jj = board[j - 1].length; ii < board[j + 1].length; jj++) {
if (boardCopy[i][j] == true)
count++;
}
}
count -= 1; //For board[i][j] is always true
if (count >= birthLive[2] && count <= birthLive[3])
board[i][j] = true;
else
board[i][j] = false;
count = 0;
}
}
}
}