Life in a shade of ruby

Conway's Game of Life is a great way to practice your craft. I recently created my own rendition in Ruby, and have plans to implement it in Javascript and Erlang. If you haven't heard of Conway's Game of life (CGOL), it is a cellular automaton [1], essentially a mathematical model, consisting of a two dimensional grid where each x and y coordinate are either alive or dead. Whether a cell is alive or dead is governed by a simple set of rules, and the game advances/evolves by applying the rules to each cell based on the previous generation's configuration and then repeating. Wow, that was seriously a mouthful. I would go into why this game has kept programmers interested in it despite being ~forty years old, but as soon as you start with CGOL you'll see how fascinating it is to see an entire world of complexity arise from low level constructs. Let's go through the rules and then meet back up to discuss the code.

Rules

Each cell has eight neighbors, three above, one on either side, and three below. The rules of CGOL simply govern the state of the cell in question as it relates to the state of its neighbor cells.

game_of_life_rules

That's it. For real. The entire list of rules can be summarized in Ruby like so.