Since my school days, I've always liked the Game
of Life, invented by mathematician John Conway. It
nicely demonstrates how complex behaviour can come about from just a few simple rules.
Anyway, when I was reading up on the I2C interface recently,
I accidentally found
this code on the Wiring Pi
website (which is a GPIO interface library for the Raspberry Pi). It looked like a nicely written bit of code
so I decided to write something similar in C#. There's no real reason why I should, but it just seemed like
a fun thing to do...
In terms of my example (with black and white cells), the rules go like this:
- a black cell with less than 2 black neighbours goes white
- a black cell with 2 or 3 black neighbours stays the same
- a black cell with more than 3 black neighbours goes white
- a white cell with three black neighbours becomes black
Here is the result:
This console app version demonstrates a glider
gun, which is some pretty impressive behaviour from those four simple rules.
Oh, and if you're really interested, and would like to see my code, it's here (as a text file).