A Python implementation of Conway's Game of Life with PyGame module.
- Any live cell with two or three live neighbours survives.
- Any dead cell with three live neighbours becomes a live cell.
- All other live cells die in the next generation. Similarly, all other dead cells stay dead.
>>> life = GameOfLife.from_file('figures/glider.txt')>>> life.curr_generation
[[0, 1, 0, 0, 0],
[0, 0, 1, 0, 0],
[1, 1, 1, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]]>>> for _ in range(4):
... life.step()>>> life.curr_generation
[[0, 0, 0, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 1, 0],
[0, 1, 1, 1, 0],
[0, 0, 0, 0, 0]]>>> life.save('glider-4-steps.txt')- To pause the game: press SPACE key.
- To draw or remove cell: click LEFT MOUSE button.
python -m unittest discover