about summary refs log blame commit diff stats
path: root/life.txt
blob: f0791e47f7d4584b6947b4be1970e027cfe820b7 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16















                                                                                                     







                                                                                                                     
 
# Conway's Game of Life

I like to implement Conway's Game of Life. Here are some notes on my general approach to doing that. 

## Rules

- The universe is an infinate 2d plain of equally sized cells
- The univsrse's state exists as discrete snap-shots of time, 1 snap-shot is a generation
- Every cell has exactly 2 states, live and dead
- A cell must be in exactly 1 state at a time, either living or dead
- A cell's neighbors are considered to be all adjacent cells
- Any cell with less than 2 live neighbors dies
- Any cell with 2 or 3 live neighbors continues to the next generation
- Any cell with more than 3 live neighbor dies
- Any dead cell with 3 neighbors becomes a living cell

## Implementation

- Define the world as a 2d grid, typically an array
- Function to dislay the grid
- Function to count living neighbors
- Function to apply the rules of life to each cell
- Function to bundle everything together, this takes in the initial state as well as the number of generations to run