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.
![](https://private-user-images.githubusercontent.com/35427506/313738659-fd0e8886-c0e6-40b6-a5ca-7c663eecba30.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxNDY4MzgsIm5iZiI6MTcyNTE0NjUzOCwicGF0aCI6Ii8zNTQyNzUwNi8zMTM3Mzg2NTktZmQwZTg4ODYtYzBlNi00MGI2LWE1Y2EtN2M2NjNlZWNiYTMwLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MzElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODMxVDIzMjIxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRkZDI2YzVjZDZmZWE0YzhmMDQwNzIxYzUwNDhjOTkzYTUyZjkwZDY2NTZjNzk4NzA2M2QzNjA4NjA1ZmY0OWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.a2wcG26Q-VtnmQUkKlPgUpf7kGLi6BUD2b0Fx68asVg)
Also features file input:
![](https://private-user-images.githubusercontent.com/35427506/313289430-42296ea4-e11e-44b0-bc3a-cad9e7a83a3a.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxNDY4MzgsIm5iZiI6MTcyNTE0NjUzOCwicGF0aCI6Ii8zNTQyNzUwNi8zMTMyODk0MzAtNDIyOTZlYTQtZTExZS00NGIwLWJjM2EtY2FkOWU3YTgzYTNhLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MzElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODMxVDIzMjIxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTljNjExMDljYWM2ZGMzNmY0YzQyNDQ1NmNmM2M5ZWY0ODM4NjBkNDIxMjY0NjlkYjEyN2UwNThhNjRmMWUyNmQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.xAGbTQz_8_-aiOBEY1KAEy0aoJktxg7pYnr5EvsO_YQ)
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.
![](https://private-user-images.githubusercontent.com/35427506/313291854-411d1051-de01-4301-9b70-b50af10b665a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxNDY4MzgsIm5iZiI6MTcyNTE0NjUzOCwicGF0aCI6Ii8zNTQyNzUwNi8zMTMyOTE4NTQtNDExZDEwNTEtZGUwMS00MzAxLTliNzAtYjUwYWYxMGI2NjVhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MzElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODMxVDIzMjIxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVmYzc3MmQyODVmZWQ1YTEwY2Q2YTdhY2M5YzIxOWQzNzg3MmMxZDFmODEzM2YwNjYxYjFjNjI5NzljYjJjMzAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.SW6h2SMBkUjz1KDWCR_Apml9QUR9cmb2d13215JJj_Q)
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.
![](https://private-user-images.githubusercontent.com/35427506/313738436-4a231cb9-2b0b-4a2d-a2bd-a873da8ebd18.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxNDY4MzgsIm5iZiI6MTcyNTE0NjUzOCwicGF0aCI6Ii8zNTQyNzUwNi8zMTM3Mzg0MzYtNGEyMzFjYjktMmIwYi00YTJkLWEyYmQtYTg3M2RhOGViZDE4LmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MzElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODMxVDIzMjIxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI0MWNhYWY2MWQzNDVmOTg1ZjYxOTk3NWQ1ZTcwYWFmZjcyNTRlMjMzOWU2N2JkZmI2NWRjMzEyNjgyMDRmNTAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.kAyzJKNqBRojQ7Ykgh_Z5MRbUkgx12axRiOq2kcwoGU)
Every cell picks a random neighbor, they both play RPS and the loser takes the winner's color. Credits to luciopaiva for the idea.
![](https://private-user-images.githubusercontent.com/35427506/313737857-9bfe2a12-6f53-4a51-8683-2e5b6beb9d41.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxNDY4MzgsIm5iZiI6MTcyNTE0NjUzOCwicGF0aCI6Ii8zNTQyNzUwNi8zMTM3Mzc4NTctOWJmZTJhMTItNmY1My00YTUxLTg2ODMtMmU1YjZiZWI5ZDQxLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MzElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODMxVDIzMjIxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTMxOTI4NWRkMzk1ZWYzY2JiNTA1NDU0MzlmMTAxMjc5OGFmNzcxNDA0Zjk3MjJlYmNlYmNiYzBlMjY3OGJlM2MmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.VnjUvzI9TSa00s7k4ODW9n_q-dcBNVh_4xGB30LC-8w)
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