Last active
August 29, 2015 13:57
-
-
Save elikem/9557884 to your computer and use it in GitHub Desktop.
create a board with all the cells you need
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Board | |
| attr_reader :all_cells | |
| def initialize | |
| @all_cells = [] | |
| (0..99).each do |x| | |
| (0..99).each do |y| | |
| @all_cells << Cell.new(x, y) | |
| end | |
| end | |
| end | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
find the neighbors of the ...it... cell
if cell.x_coord == x && cell.y_coord == x
(x - 1..x + 1).each do |i|
(y - 1..y + 1).each do |j|
Find the neighbors and sum their true states - 1.
The rules...
Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:
Any live cell with fewer than two live neighbours dies, as if caused by under-population.
Any live cell with two or three live neighbours lives on to the next generation.
Any live cell with more than three live neighbours dies, as if by overcrowding.
Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.