Conway's Game of Life implementation in Python using Pygame.
This project was started as a learning experience to get better with OOP and object inheritance in Python. It is noticeable that some parts of the code are cleaner than others, since I obviously learned a lot during the weeks that I dedicated to code this.
It was also the first time I used Pygame. Therefore, I am sure that there are good practices that I did not follow and better ways to implement what I did. Nevertheless, there are some conscious choices, such as coding the menu buttons from scratch, that I made because I truly wanted to implement them from scratch as a learning and practice experience.
You can also download or watch a video in Youtube of the current state of the game as of 31/05/2023.
Since this was a side project and I could not dedicate lots of time, I decided to limit the scope of what I wanted to implement.
- Regular grid of cells that the user can click on to change state
- Working Game of Life that can propagate over time without Periodic Boundary Conditions
- Some way for the user to start and stop the simulation
- Periodic Boundary Conditions
- Some kind of UI menu for the user to click on
- Clear and randomize states
- Save and load states, including some predefined ones
- Camera that can move through the grid instead of having a fixed screen
- Slider that can change simulation speed
I also decided to take the time to learn Poetry for environment management, which automatically creates a '.toml' file that can be used to install the dependencies.
Clone the repository at the desired location
git clone https://github.com/EloiSanchez/game-of-life
and go into the newly created directory
cd game-of-life
If using Poetry, create and activate the environment with
poetry install
poetry shell
and then run the game with
python game_of_life/game_of_life.py
or Windows/Mac or whatever equivalent.
If using any other environment manager, create a new environment and activate it. Then, run
pip install .
and then run the game with
python game_of_life/game_of_life.py
or Windows/Mac equivalent.
At the time of writing this I am working as an Analytics Engineer mainly with Snowflake and dbt. Nevertheless, I still love to code more general stuff such as this game to keep on improving my general coding skills.
If you have any question, problem, suggestion or fix, please, create an issue or contact me directly.