game of life with some optimizations
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
lifep
spec
.rspec
README.md
cell.rb
future_strategy.rb
life.rb
main.rb
toroid.rb
world.rb

README.md

GAME OF LIFE

Yet another implementation of Conway's Game of Life. Initially built as a straightforward kata. As an exercise, I sought two obvious optimizations:

  1. Instead of counting neighbors, I cached the number of neighbors for each cell, and updated them as I changed the value of a given cell.
  2. Instead of updating every cell, I maintained a set of those cells having a changing neighbor, and only updated those cells.

These required some changes to the initial design. Spiked a .LIF file reader and rewrote the mainline to read from STDIN. (If "RANDOM" is sent, then a random screen will be built.)