Search code examples
apl

Why create surrounding "neighborhoods" when using APL to iterate through the initial N by N game of life


It seems that adding extra live and dead cells changes how the original "neighborhood" would progress through the generations.

When I apply the game of life rules to the initial N by N array, I get much different results going thru the generations than I get after surrounding the initial array with 8 reversed/transposed arrays.


Solution

  • Whether a cell is alive or dead in the next generation, depends on the exact number of live cells in its Moore neighbourhood. What do you do with cells at the edges? If you just count the live cells in the existing neighbour positions, you effectively count the missing positions (outside the array) as being dead, which has a noticable effect. Alternatives include, but are not limited to, wrapping around to the opposite edge, and mirroring in the edge, but either way, you have a choice to make.

    The dfns workspace includes notes on the Game of Life which explains, illustrates, and implements many such options.