Question about the rules

For general discussion about Conway's Game of Life.
Post Reply
merijn0301
Posts: 2
Joined: April 13th, 2016, 9:19 am

Question about the rules

Post by merijn0301 » April 13th, 2016, 9:52 am

Hi,

I plan to make program-code for the "game of life".
To thoroughly understand the principle I took some graph-paper and drew a starting-pattern (the Pentomino).
Now, I have some questions :

Suppose a dead Cell (call this Cell A) pops into life because of 3 live neighbours. Chances are that, as a result, another live cell (call this B) will die because it suddenly has more than three living neighbours.

Is it common practice to FIRST show Cell A and then in the next step eliminate B or do should this all be done in some background-activity and show cell A and B together?.

My plan was to scan the grid, see which cell pop to live and which ones will die. Then scan the grid again and do the same and-so-on....

User avatar
dvgrn
Moderator
Posts: 5905
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Question about the rules

Post by dvgrn » April 13th, 2016, 11:07 am

merijn0301 wrote:Is it common practice to FIRST show Cell A and then in the next step eliminate B or do should this all be done in some background-activity and show cell A and B together?.

My plan was to scan the grid, see which cell pop to live and which ones will die. Then scan the grid again and do the same and-so-on....
Yes, that's how it works. All birth and death updates happen simultaneously in each generation.

In other words, a cell that's newly ON or OFF at time T won't affect neighbor counts at time T, but it will affect counts at time T+1. A common way of programming this is to copy the Life grid back and forth between two arrays, checking each cell to see if it should change in that step.

There are other algorithms that are usually much faster -- e.g., keeping a list of ON cells and their OFF neighbors, and only checking the OFF cell list for births, and the ON cell list for deaths, in each step. There's a lot of empty space in most Life grids, and there's really no point in processing it unless there are live cells right next to it.

merijn0301
Posts: 2
Joined: April 13th, 2016, 9:19 am

Re: Question about the rules

Post by merijn0301 » April 13th, 2016, 2:09 pm

Thank's,
that answers my questions.
about the algorythms : I will, initially go for the 2-arrays-approach you mentioned.

I did think about keeping track of live cells and the dead neighbours, however. I know how it would work but details about the implementation need some thinking

Kind regards.

Post Reply