60. The Game of Life

Write a program that implements the Game of Life cellular automaton proposed by John Horton Conway. The universe of this game is a grid of square cells that could have one of two states: dead or alive. Every cell interacts with its adjacent neighbors, with the following transactions occurring on every step:

  • Any live cell with fewer than two live neighbors dies, as if caused by under-population
  • Any live cell with two or three live neighbors lives on to the next generation
  • Any live cell with more than three live neighbors dies, as if by overpopulation
  • Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction

The status of the game on each iteration should be displayed on the console, and ...

Get The Modern C++ Challenge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.