Question

Alright, I am trying to program Conway's game of life, I don't understand it conceptually tho, even tho it seems quite simple. So:

-This is how the Gilder becomes according to the simulators I've found online (Forgive my poor paint)

enter image description here

Yet I don't quite understand. Let me explain: Consider the following grid:

enter image description hereIf I proceed by rows, and I apply the rules:

Block 1 -> Has two live neigh (4,5) doesn't change. Block 2 -> Has three live neigh (4,5,6) reproduces and lives. Block 3 -> Has three live neighbours now (2,5,6) so he lives. Now the situation has changed to:

enter image description here

Second row: Block 4 -> Has three live neigh (2,5,7) lives on. Block 5 -> Has five live neigh (2,3,4,6,7) dies. Block 6 -> Has two live neigh (2,3) lives on

So:

enter image description here

Block 7 -> Has two live neigh (4,11) lives on Block 8 -> Has 4 live neigh (4,6,7,11) doesn't change. Block 9 -> Has 2 live neigh (6,11) doesn't change. Block 10 -> Has 2 live neigh (7,11) doesn't change. Block 11 -> Has 1 live neigh (7) dies. Block 12 -> No neigh. Doesn't change.

So it changes to:

enter image description here

PLEASE TELL ME WHAT'S WRONG! :P I am going nuts!

Was it helpful?

Solution 2

In Conway 's game of life, all the cells are updated simultaneously. In other words, the survival and birth of cells depends only on the number of live neighbors in the previous turn, since the new cells that will be born this turn don't exist yet, and the cells that will die haven't died yet.

In practice, the easiest way to implement this is by using double buffering: on each turn, you set the live/dead status of cells in buffer B according to their status and number of live neighbors in buffer A, and then swap the buffers.

OTHER TIPS

To evolve a grid of cells you just look at the cells in the "old" grid. You don't apply the changes to a cell and then make subsequent changes to other cells based on the new value of the changed cell. All of the changes to a grid take place simultaneously, not in any kind of order like you are doing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top