Game of Life

Description

Your task is to write a program to calculate the next generation of Conway's game of life, given any starting position. You start with a two dimensional grid of cells, where each cell is either alive or dead. The grid is finite, and no life can exist off the edges. When calculating the next generation of the grid, follow these four rules:

  1. Any live cell with fewer than two live neighbors dies, as if caused by underpopulation.
  2. Any live cell with more than three live neighbors dies, as if by overcrowding.
  3. Any live cell with two or three live neighbors lives on to the next generation.
  4. Any dead cell with exactly three live neighbors becomes a live cell.

(Source)

Progress

  1. Find all living neighbors of a given cell (tests)
  2. Convert grid in text file to two dimensional array (tests)
  3. Cell returns it's current status: live or dead (tests)
  4. Fate will determine a cell_fate: born, live or dead (tests)

Notes

  • All files should be independent of each other except life-generation.rb
    • cell
    • fate
    • grid
    • neighbors/living neighbors
  • The Generation class should, for each cell in the grid and:
    • find number of living neighbors
    • get current status
    • return determined fate
    • add cell's new status to a next_gen_grid array
    • split into 2D array with same proportions as original grid & return

Functions used in Generation

instance_of_grid.start_grid(num)

instance_of_neighbors.living_neighbors(x,y,grid)

instance_of_fate.cell_fate(status,living_neighbors)

instance_of_cell.status(status)