Qt4.6 Example: Game of Life


As there was occasional downtime at work, I used that time to teach myself the simply wonderful Qt framework. With kind permission of SonyEricsson Mobile Communications I am allowed to release the source.

Example image with trails enabled

Here's a simple Game of Life simulator program implemented in Qt. Download source.

Some example world configurations (use File/Open): example.gol, slurp2.gol, trash.gol and turbine.gol.

Features

  • Toroidal 2-dimensional Conway's Game of Life
  • Moore and von Neumann neighbourhoods
  • Trails mode (UI bling)
  • Load and save world (XML)
  • Edit mode - draw your own pattern
  • Different colours e.g. invert mode
  • Save image
  • Import world from 80x50 black and white PNG image
  • Settings menu

Build it

Qt 4.6 is needed.

Unpack, then go to the folder and:

qmake make

Then run the resulting GameOfLife binary.

It's been tested under Symbian 9.4, Windows and Linux. Works OK, although in Symbian some of the file dialogs were laid out funnily, it ran "mostly OK" anyway.

Note: The doc/ folder contains an UML diagram of the design/structure. It's not really anything fancy, but in case you're wondering about why something is the way it is, it's probably good to check that first.

License

This source code is placed into public domain. Feel free to use it for learning, poke it and see what happens, change it, extend it, etc. Developing it helped my understanding of Qt, maybe it'll do the same for you. Have fun!

If you do anything interesting with it, please drop a comment with a link!