public void GameOfLife(int[,] board) { Board board2 = new Board (board); int row = board.GetLength (0); int col = board.GetLength (1); int[,] temp=new int[board.GetLength(0),board.GetLength(1)]; for (int i=0; i<row; i++) for (int j=0; j<col; j++) { temp[i,j]=board[i,j]; } for (int i=0; i<row; i++) for (int j=0; j<col; j++) { int count=board2.GetAdjacentPointCount(i,j); if(board[i,j]==1){ if(count<2){//0 or 1 temp[i,j]=0; } else if(count<4){//2 or 3 temp[i,j]=1; } else if(count>3){//3,4,5,6,7,8 temp[i,j]=0; } } else if(count ==3){ temp[i,j]=1; } } board = temp; b = temp; }
public void CalculateGameOfLife(int[,] array) { board = new Board (array); row = array.GetLength (0); col = array.GetLength (1); int[,] temp=new int[array.GetLength(0),array.GetLength(1)]; for (int i=0; i<row; i++) for (int j=0; j<col; j++) { temp[i,j]=array[i,j]; } for (int i=0; i<row; i++) for (int j=0; j<col; j++) { int count=board.GetAdjacentPointCount(i,j); if(array[i,j]==1){ if(count<2){//0 or 1 temp[i,j]=0; } else if(count<4){//2 or 3 temp[i,j]=1; } else if(count>3){//3,4,5,6,7,8 temp[i,j]=0; } } else if(count ==3){ temp[i,j]=1; } } array = temp; mArray = temp; }