Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Game of dicks

Name: Anonymous 2009-12-06 13:11


live() {
 for(int i = 0; i < w; i++) {
 for(int j = 0; j < h; j++) {
  n[i][j] = neighbours(i,j);
  board[i][j] =
   board[i][j]
    ? (n[i][j] == 2 || n[i][j] == 2)
    : (n[i][j] == 3)
 }
 }


motherfuckers, I can't get my game of life working. Help me you assholes. live is meant to do one iteration but it's fucked up somehow.

Name: Anonymous 2009-12-07 17:50

>>21
That's not the problem; that's valid. The solution to the actual problem is to split live() into two passes: completely calculate the amount of neighbours each cell has, then calculate if the cells live or die.

I am assuming that neighbours(i,j) looks at the 8 cells surrounding board[i][j]. If you intertwine neighbour cell counting with destructively updating the board, the neighbour counts will be wrong because when neighbours(i,j) accesses the board[i-1][j-1] it will be accessing the new value, when it should be accessing the old value.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List