Because I needed something to tinker with. This started as a one day experiment for brushing up my Nim skills and got a bit out of hand. The code is not optimized in any way and really just my playground.
- With colors (inspired by Jim Blackler's version):
- At startup the cells are assigned colors randomly
- Newly-created cells take the most common color of neighbouring cells
- When cells die, they leave a shaded version of their original color
- Borderless (optional)
- REL import
There are plenty of other Game of life implementations in Nim on Github for example. Only after I started this project, I found another Nim implementation using SDL (actually Nimgame2) by andrew644 and the code looks a lot nicer. Unfortunately I couldn't get it to work under WSL2, because SDL can't find an audio device...
You will need Nim as well as SDL2 installed.
Run nimble install
(which also installs required Nim packages).
The resulting binary is called gol
and placed in your (Nimble) PATH.
Alternatively run nimble build
which builds the binary locally but doesn't install it. However, this doesn't use compiler optimization and will hence be slow.
Run gol -h
or ./gol -h
to see command-line arguments.
For importing RLE patterns (e.g. downloaded from the LifeWiki), it's a good idea to add some padding, e.g. gol -f patterns/p5760unitlifecell.rle -c 1 -p 100
If you are under WSL2 and this segfaults early, please set the DISPLAY
variable.
Under Ubuntu/WSL2 I first had to link libSDL2-2.0.so.0 so that Nimble would find it:
ln -s /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 libSDL2.so
export LD_LIBRARY_PATH=$(pwd):$LD_LIBRARY_PATH
- Fix stupid color handling!
- Add support for stepping (currently mouse click starts and stops)
After 397 generations.