0

So I'm trying to print the first six generations of the Game Of Life in a 7x7 array. I only have the code for one generation, but I can fix that later. I made the array types integers. What I need help with is getting the correct code for all of the neighbors that each cell has and also the code for each generation to correctly mutate. If you can help, PLEASE do!

```
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class blank {
public static void main(String[] args) throws FileNotFoundException {
Scanner fileReader = new Scanner(new File("project3.txt"));
int [][] neighbor = new int [7][7];
int [][] board = new int [7][7];
for(int i = 0; i<7; i++){
for(int j = 0; j<7; j++){
board[i][j] = fileReader.nextInt();
if(i >= 1 && i <= 5 && j >=1 && j <= 5){
if(board[i-1][j]==2)
neighbor[i][j]++;}
if(i >= 1 && i <= 5 && j >=1 && j <= 5){
if(board[i+1][j]==2)
neighbor[i][j]++;}
if(i >= 1 && i <= 5 && j >=1 && j <= 5){
if(board[i][j-1]==2)
neighbor[i][j]++;}
if(i >= 1 && i <= 5 && j >=1 && j <= 5){
if(board[i][j+1]==2)
neighbor[i][j]++;}
if(i >= 1 && i <= 5 && j >=1 && j <= 5){
if(board[i][j-1]==2)
neighbor[i][j]++;}
if(i >= 1 && i <= 5 && j >=1 && j <= 5){
if(board[i-1][j-1]==2)
neighbor[i][j]++;}
if(i >= 1 && i <= 5 && j >=1 && j <= 5){
if(board[i-1][j+1]==2)
neighbor[i][j]++;}
if(i >= 1 && i <= 5 && j >=1 && j <= 5){
if(board[i+1][j+1]==2)
neighbor[i][j]++;}
if(i >= 1 && i <= 5 && j >=1 && j <= 5){
if(board[i+1][j-1]==2)
neighbor[i][j]++;}
if (i==0 && j>=1 && j<=5){
if(board[i+1][j]==2)
neighbor[i][j]++;}
if (i==0 && j>=1 && j<6){
if(board[i][j+1]==2)
neighbor[i][j]++;}
if (i==0 && j>0 && j<=5){
if(board[i][j-1]==2)
neighbor[i][j]++;}
if (i==0 && j>=1 && j<6){
if(board[i+1][j+1]==2)
neighbor[i][j]++;}
if (i==0 && j>0 && j<=5){
if(board[i+1][j-1]==2)
neighbor[i][j]++;}
if(j==0 && i>=0 && i<=6){
if(board[i][j+1]==2)
neighbor[i][j]++;}
if(j==0 && i>=0 && i<6){
if(board[i+1][j]==2)
neighbor[i][j]++;}
if(j==0 && i>0 && i<=6){
if(board[i-1][j]==2)
neighbor[i][j]++;}
if(j==0 && i>=0 && i<6){
if(board[i+1][j+1]==2)
neighbor[i][j]++;}
if(j==0 && i>0 && i<=6){
if(board[i-1][j+1]==2)
neighbor[i][j]++;}
if(i==6 && j>=1 && j<=5){
if(board[i-1][j]==2)
neighbor[i][j]++;}
if(i==6 && j>=1 && j<6){
if(board[i][j+1]==2)
neighbor[i][j]++;}
if(i==6 && j>0 && j<=5){
if(board[i][j-1]==2)
neighbor[i][j]++;}
if(i==6 && j>=1 && j<6){
if(board[i-1][j+1]==2)
neighbor[i][j]++;}
if(i==6 && j>0 && j<=5){
if(board[i-1][j-1]==2)
neighbor[i][j]++;}
if(j==6 && i>=0 && i<=6){
if(board[i][j-1]==2)
neighbor[i][j]++;}
if(j==6 && i>=0 && i<6){
if(board[i+1][j]==2)
neighbor[i][j]++;}
if(j==6 && i>0 && i<=6){
if(board[i-1][j]==2)
neighbor[i][j]++;}
if(j==6 && i>=0 && i<6){
if(board[i+1][j-1]==2)
neighbor[i][j]++;}
if(j==6 && i>0 && i<=6){
if(board[i-1][j-1]==2)
neighbor[i][j]++;}
}printMe(board);
System.out.println();
printIt(neighbor);
mutate(board, neighbor);
}
}
private static void printMe(int [][]board){
int gen = 0;
System.out.println("Generation " + gen + ": ");
for (int i = 0; i < 7; i++){
for (int j = 0; j < 7; j++){
System.out.print(board[i][j] + "\t");
}//end for j
System.out.println();
System.out.println();
}//end for i
gen += 1;
}//end printMe
private static void printIt(int [][]neighbor){
for (int i = 0; i < 7; i++){
for (int j = 0; j < 7; j++){
System.out.print(neighbor[i][j] + "\t");
}//end for j
System.out.println();
System.out.println();
}//end for i
}//end printMe
private static void mutate(int [][]board, int [][]neighbor){
for(int i = 0; i < 7; i++){
for(int j = 0; i < 7; j++){
neighbor[i][j] == ?????;
board[i][j] == ?????;
if(board[i][j] == 1 && neighbor[i][j] == 3)
board[i][j]=2;
if(board[i][j] == 2 && neighbor[i][j] >= 4)
board[i][j]=1;
if(board[i][j] == 2 && neighbor[i][j] <= 1)
board[i][j]=1;
}
}
}
}
```