ex3: Conway's Game of Life


Controls: Press 'C' to initialize grid and clear it while paused. Press 'R' to randomise cell states while being paused. Use 'P' to play/pause life simulation.

The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.

The universe of the Game of Life is an infinite, two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, living or dead .

Whether a cell is dead or alive depends on the cell's eight neighbours.

Every turn, cells live, die or are "born" based on these rules:

    Any live cell with fewer than two live neighbors dies, as if by underpopulation.
    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.