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:
Anonymous2009-12-06 13:11
}
Fixed.
Name:
Anonymous2009-12-06 13:12
>>2
fuck off asshole, that was just a typo. The thing is still buggy. How about you tell me why instead of being such a pathetic shitbag.
Name:
Anonymous2009-12-06 13:21
(n[i][j] == 2 || n[i][j] == 2)
( ≖‿≖)
Name:
Anonymous2009-12-06 13:30
I'm going to assume that w, h, and n are defined outside of this function.
"board[i][j] =
" board[i][j]
" ? (n[i][j] == 2 || n[i][j] == 2)
" : (n[i][j] == 3)"
I know what you're trying to do, but I have no clue what you're doing. I'm assuming that board is boolean, so then why are you assigning the value of 2 or 3 to it? And what's with that || in the THEN position?
Name:
Anonymous2009-12-06 13:36
>>1
Stop being such a pissy dick and you'll get proper help
This isn't /g/
Name:
Anonymous2009-12-06 13:54
make a new board for each generation, populate it according to the old board, repeat
>>21
I think you don't quite grasp what the code does.
Name:
Anonymous2009-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.
Name:
Anonymous2009-12-07 17:59
>>23
The problem is that OP should be using double buffering and not store the neighbour count at any time.
This thread has been threadstopped, you can't crickets anymore
Name:
Anonymous2009-12-08 14:36
>>18
I still say your problem must have to do with the initialization of your variables w, h, or the arrays board and n. Or neighbours(in, int) just doesn't work like you think it does at some point.
>>21
It's like this. Just remember that board is a boolean array.
>>43
In >>7 you're implying creating a new board for each generations, so that the memory cost of your solution is O(n). My proposition in >>24 has a memory cost of O(1).
Name:
Anonymous2009-12-10 17:15
>>44
If you discard the boards when you are finished with them, they should be functionally equivalent. Later, if you wanted to, for example, play back the game, then >>7s solution is better. For a simple first go, I'd double buffer, as you suggested.