/gameoflife

Conway's Game of Life, in PyTorch, using convolutions

Primary LanguagePython

Learnable Game Of Life (John Conway) with convolutions, in PyTorch

Learnable cellular automata... in PyTorch, using convolutions.

Just a fun thing to try. Documented here.

Instructions

  1. Run python3 life.py just to see the basic game in action. Press q to exit.

A basic game run according to the rules

  1. Run python3 lifedatagen.py to start collecting some training data. Press q to exit once it gets fairly stable/boring. 2a. Edit the code of lifedatagen.py at change line 21 from if False: to if True:. The first time you run the script, it creates a new file (a numpy vector). The second time it'll append to that vector instead (provided you make the change.) 2b. Run python3 lifedatagen.py several more times to gather training examples. 2c. You should see a file called train.data has been created.

  2. Run python3 lifeshuffle.py. This takes train.data, shuffles it, and removes discontinuities from when you exited/restarted in step 2b above.

  3. Run python3 lifetrain.py. This trains the network. Once training is done (GPU required, likely only 5-10 minutes) it'll run the modelled game and display it. Press q to quit or r to restart with a new randomly initialized board. Some params like learning rate, num epochs can be edited inside that file.

Here's an example output:

A learned game