Learnable cellular automata... in PyTorch, using convolutions.
Just a fun thing to try. Documented here.
- Run
python3 life.py
just to see the basic game in action. Pressq
to exit.
-
Run
python3 lifedatagen.py
to start collecting some training data. Pressq
to exit once it gets fairly stable/boring. 2a. Edit the code oflifedatagen.py
at change line 21 fromif False:
toif 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. Runpython3 lifedatagen.py
several more times to gather training examples. 2c. You should see a file calledtrain.data
has been created. -
Run
python3 lifeshuffle.py
. This takestrain.data
, shuffles it, and removes discontinuities from when you exited/restarted in step 2b above. -
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. Pressq
to quit orr
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: