Share your repls and programming experiences

← Back to all posts
Conways Game Of Life
h
CodeLongAndPros (1589)

Conway's game of Life

This is Conway's game of life.

There are three rules (and four lights):

  • Any cell with less than 2 around dies
  • Any cell with 2-3 stays the same
  • A dead cell with 3 becomes alive

Once this starts, press ^C to get to command mode.

You have these commands:

  • t: Toggle cell at x, y. If there is no y, it defaults to x, x
  • s: Advance one iteration
  • i: Display current generation / iteration
  • g: Display the board in a grid format
  • G: Toggle how the board is displayed in command mode: Grid or pretty print
  • d: Sets the delay between iterations. (0.75 default). Warn: Setting this to high values may cause flicker
  • h: Get help text

Some common structues are:

Glider:

0, 1
2, 1
2, 2
1, 2
0, 0

toggle:
1, 0
1, 1
1, 2

Hive:
1, 0
0, 1
0, 2
1, 3
2, 1
2, 2