The Conway's Game of Life is actually a zero player game, where every cell follows a set of rules:
- Any live cell with 0 or 1 live neighbors become dead, because of underpopulation
- Any live cell with 2 or 3 live neighbors stays alive, because its neighborhood is just right
- Any live cell with more than 3 live neighbors becomes dead, because of overpopulation
- Any dead cell with exactly 3 neighbours becomes alive, by reproduction
By creating a initial pattern, which could be a random set of alive and dead cells or predefined formations, we can watch how births and deaths happen simultaneously to every cell and create unbelievably complex and beautiful patterns.
Type in terminal: python -u main.py [-w WIDTH] [-hs HEIGHT] [-g {1, 2, 3 4}] [-f] FILENAME
options:
-h, --help
: show this help message and exit
-w WIDTH, --width WIDTH
: Choose board's width.
-hs HEIGHT, --height HEIGHT
: Choose board's height.
-g {1,2,3,4}, --game {1,2,3,4}
: Choose which cellular automata you want to run. 1 is the default Game of Life, 2 is Langton's Ant, 3 is Seeds and 4 is Brian's Brain.
-f FILE, --file
: Choose file for assigning initial state of the board.
By default, the board will be 100x100 and the initial state for the Game of Life will be a random one.
By using matplotlib's FuncAnimation
, life can be watched.
Also features file input:
Features other cellular automata:
The ant moves according to these rules:
- At a white square, turn 90° clockwise, flip the color of the square and move forward one unit.
- At a black square, turn 90° counter-clockwise, flip the color of the square and move forward one unit.
The ant starts out by creating simple patterns which are often symmetric. After a few hundred moves, it starts moving in irregular patterns and it traces a pseudo-random path until around 10,000 steps. The ant ends up finding order amidst the chaos, and starts building a "highway pattern" which repeats indefinitely.
It adds a third "dying" state. All cells that were alive go into the dying state, and cells that were already in the dying state goes into the dead state. By setting a third color to this new state, new patterns can be watched.
Every cell picks a random neighbor, they both play RPS and the loser takes the winner's color. Credits to luciopaiva for the idea.
Luan Arita - [email protected]
- Robert Heaton for guiding on how to make this project.
This project is licensed under the MIT License - see the LICENSE file for details