- Authored by Kyle Clark - kyleaclark.com
- Run application as a text game or simulated animation
- Game of Life is similar to Game of Thrones, except they're not really the same.
- Game of Life was created by mathematician John Conway in 1970 as a way to represent the interactions of cells.
- Played on a two-dimensional grid with a maximum of 8 neighbours for a grid square.
- Zero-player game determined by the initial random state of cells alive or dead.
- Subsequent states are determined by a set of rules.
- Any live cell with 2 or 3 live neighbours lives on to the next generation (survival).
- Any live cell with fewer than 2 live neighbours dies (under-population).
- Any live cell with more than 3 live neighbors dies (overcrowding).
- Any dead cell with exactly 3 live neighbors evolves into a live cell (reproduction).
- Each cell lives or dies independently (non-sequentially) in a generational evolution.
- Python 3.10.6
- Poetry dependency management
- Setup instructions are specific to macOS. Steps may vary.
- Install pyenv for python version management - https://github.com/pyenv/pyenv
- Update pyenv if previously installed e.g. via brew
brew upgrade pyenv
- Install poetry for python dependency management - https://python-poetry.org/docs/#installation
- Update poetry if necessary (optional):
poetry self update
- Add pyenv path to profile e.g. add
export PYENV_ROOT="$HOME/.pyenv
+export PATH="$PYENV_ROOT/bin:$PATH"
- Add poetry path to profile e.g. add
export PATH="$HOME/.poetry/bin/:PATH
- Install python version:
pyenv install 3.10.6
- Set python version within the repo directory:
pyenv local 3.10.6
- Set the poetry env version of python:
poetry env use ~/.pyenv/versions/3.10.6/bin/python
- Install python application dependencies:
poetry install
- Run text game via terminal:
poetry run python run_text_game.py
- Run simulated animation via terminal:
poetry run python run_simulated_animation.py
- Run tests via terminal:
poetry run python -m pytest -p no:cacheprovider tests
- Open PyCharm Preferences
- Open Project Interpeter > Add existing Virtualenv Environment e.g.
/Users/<username>/Library/Caches/pypoetry/virtualenvs/<poetry-name>/bin/python
- Open Tools > Python Integrated Tools > Default test runner: pytest
- Run text game: Right-click on
run_text_game.py
and choose Run - Run simulated animation: Right-click on
run_simulated_animation.py
and choose Run - Run tests via pytest: Right-click on
tests
and choose Run
- Poetry documentation - https://python-poetry.org/docs/
poetry install
- Install dependencies from poetry.lock - https://python-poetry.org/docs/cli/#installpoetry update
- Update poetry.lock from pyproject.toml - https://python-poetry.org/docs/cli/#updatepoetry add
- Add a dependency into pyproject.toml - https://python-poetry.org/docs/cli/#addpoetry remove
- Remove a dependency in pyproject.toml and update poetry.lock - https://python-poetry.org/docs/cli/#remove