Conways Game of Life
This is a C++ implementation of Conway's Game of life.
The algorithm is using ideas from Michael Abrash's Graphics Programming Black Book, Chapter 17, of using neighbour counts. It seems that this method is several times faster than the naive way of implementing it. (The naive way of implementing it is using a bool for each cell, where
true is used for alive cells and
false is used for dead cells.)
I implemented this algorithm as part of my master studies (1st semester course in efficient programming) of Game Engineering at the University of Applied Sciences FH Technikum Wien (Austria).
GNU General Public License 3. See LICENSE.md for details.
This is a command line tool (running on Windows and macOS.)
Command line parameters:
||file to load (see below for file format)|
||specify number of generations to calculate|
||specify where the result should be saved to|
||for testing: after we finished calculating the generations, check that the resulting board is the same as the verification board given here. The result is printed to stdout.|
||Mode of operation.
||Specify number of threads to use. Only valid for OpenMP mode. Defaults to 4.|
||Use CPU or GPU for OpenCL. This option is only valid in
||Enable verbose mode|
||Print time measurements at the end. Three times are printed: (1) the time it took to load the input file, (2) the time it took to calculate the generations, (3) the time it took to save the output file or to do the verification.|
./GameOfLife --load GameOfLife_Testdata/step1000_in_250generations/random10000_in.gol --verify GameOfLife_Testdata/step1000_out_250generations/random10000_out.gol --verbose --measure --generations 250 --mode seq
./GameOfLife --load GameOfLife_Testdata/step1000_in_250generations/random10000_in.gol --save result.gol --verbose --measure --generations 250 --mode seq
width,height ....x ....x
x denotes alive cells and
. denotes dead cells.
6,4 ...... ..xx.. ..xx.. ......
You need either Xcode or Visual Studio.
It has been tested with Xcode 9 and with Visual Studio 2017
Some example test data
Or you can create your own random test data with the included perl script