Game of Life

Problem Description

This Kata is about calculating the next “generation” of Conway’s game of life given an arbitrary starting position. To learn more about Conway’s Game of Life and its rules, click here.

Rules

  • Any “live” cell with fewer than two living neighbors dies.
  • Any live cell with more than three living neighbors dies.
  • Any live cell with two or three living neighbors survives.
  • Any dead cell with exactly three living neighbors comes alive (as if the living cells reproduced).

Requirements

  • Your program should accept an arbitrary grid of cells and then output the grid for the next generation.
  • Because Game of Life is only fun if you have multiple generations, put the above in a loop so you can play with it.

Recommendations

You will want to start out with a console grid format that is easy to understand. The following format shows three living cells in a 4x8 grid:

........
....*...
...**...
........

Additional Challenges

  • Extend your game to run on a torus by wrapping the left/right top/bottom edges
  • Extend your game to run on an infinite plane