Conway's Game of Life Simulation

Following the rules outlined in wikipedia, this ruby implemetation uses the ruby2d gem with graph paper background having 20 rows and 30 columns and multicolored squares.

The number of squares that appear on the board is determined by a scale factor, which is currently hard coded to 4; producing a board of 80 rows x 120 columns or 9600 cells.

The game starts off with a random board and will continue until there are no state changes or it will loop if the state changes repeat in a cycle.

Cycle detection is checked by looking at the last number of state changes and if detected a new random board will be generated. If a cycle is partially detected the refresh rate it slowed before the new board is displayed.

You can also press any key or right click at any time to generate a new random board.

Running the program ruby gol.rb

Note there are serveral constants that change the simulation in gol.rb

# ***********************************
# ** User changeable constants start

# ** board size dictated by factor  1=20x30, 2=40x60, 3=60x90, 4=80x120, 6=120x180, 9=180x270 (48,600 cells)
# ** NOTE: scale factors greater than 4 are pretty slow on my machine, but speed up as colonies die off
# ** NOTE: larger scale factors increase entertainment value :)
SQUARE_SCALE_FACTOR = 4 # should be a factor of 36

# ** speed
ITERATION_PAUSE = 0.0 # seconds
SLOWER_ITERATION_PAUSE = 0.3 # seconds
STEADY_STATE_PAUSE = 2 # seconds

# ** colors for a multicolored board
COLORS = [['blue', 'green'], ['purple', 'red']]
# ***********************************