Just a fun project to code a simple Tic-Tac-Toe game. However, I created two games actually:
- the console version (in console package)
- the desktop version using PyGame (in desktop package)
I wanted to test out the PyGame lib and also practise some design patterns. Thanks to this motive I was able to add the following design patterns:
- State - the game class can have 3 states: PRE_GAME, GAME, POST_GAME based on which the game behaves differently (shows different windows))
- FlyWeight - Used when loading symbol images so that we load them only once instead of each time creating a new symbol on the board
To keep things simple and to learn as much as I can I decided to only use:
- PyGame for the game development
First, check which Python version is used in the Dockerfile. If you do not have the current version please install it. Then create a python virtual env:
python3.12 -m venv env/Activate the env and set PYTHONPATH:
source env/bin/activate
export PYTHONPATH=`pwd`Install the requirements:
pip install --upgrade pip
pip install --upgrade setuptools
pip install -r requirements.txtStart the console app by:
cd console/
python main.pyOr the desktop version just by (from the root directory):
python main.pyNOTE: the only works for the console version because for PyGame we need to be able to show the app itself.
Start the application with the following:
docker compose up --buildEnter the container:
docker compose run --rm app bashAnd run the console version with:
cd console/
python main.pyThe project follows some specific conventions thanks to pre-commit:
- isort
- black
- flake8
- no-commit-to-branch (main branch)
- bandit
- docformatter
- python-safety-dependencies-check
To install the GitHub pre-commit hooks. This can be done in your virtual environment by:
pre-commit install