I recently came across an interesting problem/game called Game Of Life. A visual version of this is available here. Also, here is a beginners introduction to Game Of Life, or simply Life, written by Alex Bellos at Guardian.
It is a cellular automation problem created by John Horton Conway, a British mathematician in 1970, not a game you play to win or lose. This problem has a few rules that we need to follow.
- A cell in the grid can be dead or alive.
- A live cell with less than 2 live neighbours will die.
- A live cell with 2 or 3 live neighbours will stay alive.
- A live cell with more than 3 live neighbours will die.
- A dead cell with exactly 3 neighbours will become alive.
These rules are pretty simple. Once we know the number of live neighbours of a given cell, we can determine it’s fate in a step. In this post I’m going to dicuss method to find neighbours of a given cell in a matrix.
In Game of Life, we take a seed grid and eventually get another grid as a output, by applying the rules to each cell.