I'm trying to write conways game of life in Java but it's not working as it should. By that I mean, still lifes work but blinkers and ships do not.
Here is the code for my algorithm, the seeding is handled by a seperate mouse listener (which is working as intended).
int[][] state1 = new int[80][80];
int[][] state2 = new int[80][80];
public void logic(){
state2=state1;
for(int i=0;i<80;i++){
for(int j=0;j<80;j++){
int sum=state1[(i-1+80)%80][j]+state1[(i-1+80)%80][(j-1+80)%80]+state1[i][(j-1+80)%80]+state1[(i+1)%80][(j-1+80)%80]+state1[(i+1)%80][j]+state1[(i+1)%80][(j+1)%80]+state1[i][(j+1)%80]+state1[(i-1+80)%80][(j+1)%80];
if(sum!=2 && sum!=3){
state2[i][j]=0;
}
else if(sum==3){
state2[i][j]=1;
}
}
}
state1=state2;
}