John Conway's Game of Life + Mutation - C++ + SDL

cellular automata c++

I've always been interested in AI, evolution simulations, and other interesting problems. But I will never forget one of my all time favorite classics, John Conway's Game of Life.. This simulation implements a few just a few simple rules, yet relatively complex structures emerge. The rules are:

1. Any live cell with fewer than two live neighbors dies, as if caused by underpopulation.
2. Any live cell with more than three live neighbors dies, as if by overcrowding.
3. Any live cell with two or three live neighbors lives on to the next generation.
4. Any dead cell with exactly three live neighbors becomes a live cell.

Below are some of the patterns that I found and thought were interesting:

Game of Life Simple Patterns Game of Life Complex Patterns

After watching many trails I noticed one thing immediately; The simulation always eventually "dies down", or reaches some equilibrium state and it is usually comprised of a bunch of simple structures. So I decided to add a mutation factor to the simulation such that upon mutation, A living cell dies and a dead cell comes to life. This significantly increased the life of the simulation. In fact with the right mutation rate the simulation will continue endlessly.

In my quick little simulation I also introduced a "wrap around" feature so that structures can move infinitely in any direction.

The demo is written in C and uses the SDL Library for drawing the points and is in 640x480 resolution. The source can be downloaded here. To Compile: g++ main.cpp -o LIFE -lSDL To Run: ./LIFE

Every thing from mutation rate to cell generation at startup is configurable. Read the ReadMe.txt file included to see what's configurable.

Screenshots:

Life Screenshot Life Screenshot Life Screenshot Changed Rule

Notice that the 3rd Image is a result of changing rule 4 to " Any dead cell with two or three live neighbors becomes a live cell." (I made this typo when first writing the program and was surprised by the result :)) Try changing the rules and see what results you find. I hope to release a more complex version in the future.