This is a generator for Elementary Cellular Automata and John Conway's Game of Life. Inspired by Stephen Wolfram's 2002 book: A New Kind of Science.
- The universe of the Game of Life is an infinite, two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead.
- Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent.
- At each step in time, the following transitions occur:
- Any live cell with fewer than two live neighbours dies, as if by underpopulation
- Any live cell with two or three live neighbours lives on to the next generation
- Any live cell with more than three live neighbours dies, as if by overpopulation
- Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction
- This creates complex patterns from very simple rules.
- There are three prederminated patterns included:
- R-Pentomino: A finite pattern with a predetermined lifespan.
- Glider Gun: A finite pattern with unbounded growth.
- Infinite Growth: A one cell thick infinite growth pattern.
- Elementary Cellular Automata are the simplest class of one-dimensional cellular atomata.
- Each cell in a grid has two possible values (0 or 1) and rules that depend on their previous three nearest neighbours.
- In this program, different automata can be generated simply by changing an 8-bit binary number that represents the rules for what each cell's state should be given it's neighbours.
- More details at Wolfram Mathworld.
- This is my first attempt at a non-trivial project with zero influence from a tutorial. Please enjoy :)
User must have the Meson build system installed before the project can be built. Project is self-contained and easily builds on Linux, but GLEW must be installed linked separately on Windows due to an issue with how Meson invokes the Microsoft Resource Compiler for the GLEW library. This can be done using vcpkg or your package manager of choice.
Dependencies:
# Navigate to the desired directory, then run the following command
$ git clone --recursive https://github.com/Karsteski/The_Cellular_Automata.git
$ cd builddir
$ meson configure -Dcpp_std=c++17
$ meson configure -Dbuildtype=release
$ meson compile
$ ./cellular-automata-generator
- Use
std::vector
instead ofstd::map
. This would result in significantly faster iteration (O(n) instead of O(log(n)). - Write unit tests while writing the program. At the time I was in a hurry to get something working, and therefore I thought unit testing would have slowed me down. BIG MISTAKE. It would have certainly helped fix bugs far faster.
- Stick to STL containers.
ImVec2
was used to store point information but ultimately it would have been simpler to stick tostd::pair
orstd::tuple
.