- Solution's author: Artsiom Praneuski (artem.pronevskiy@gmail.com, @artempronevskiy)
- Last revision: 2024-09-07
- Description
- Dependencies to run the app
- Steps to run the app
- Dependencies to run tests
- Steps to run tests
- Note for developers
- Issue reporting
- License
- This is a simple Tic Tac Toe emulator which allows to play the game in CLI mode.
- There is no human input. Both player moves are simulated. Moves are determined using an external randomizer service or a local one.
- Game stops as soon as there is a winner and the winner and cells of the boards get printed.
- Python: app was developed and tested using 3.12 version, but it should work with 3.10+ version
- External python libraries: no external libraries are needed (Python 3 stdlib is used only)
- External library is needed only for remote randomizer service, but it's considered to be not a part of the application itself.
- Install dependencies for remote randomizer service:
python3 -m pip install -r remote_randomizer/requirements.txt
- Run remote randomizer service (in non production mode):
python3 remote_randomizer/main.py
- Run the Tic Tac Toe emulator:
python3 src/main.py
- To get more detailed information about the app's flow, set log level to
debug
:
python3 src/main.py --log-level debug
- To use local randomizer service, set
--randomizer-type
parameter tolocal
:
python3 src/main.py --randomizer-type local
- See CLI help to get information about available commands:
python3 src/main.py --help
- Python: app was developed and tested using 3.12 version, but it should work with 3.10+ version
- External python libraries:
pytest
package is needed to run tests
- Install
pytest
package:
python3 -m pip install pytest
- Run tests:
export PYTHONPATH=src:tests
pytest tests
- Application is developed using Clean Architecture approach with Onion architecture. There are the following layers with strict hierarchy and dependencies direction (shown by arrows):
presenter
|
v
infrastructure
|
v
service
|
v
domain
- Each layer has its own responsibilities and dependencies.
presenter
layer is responsible for interaction with the user (CLI in this case).infrastructure
layer is responsible for low level components and interaction with external services (Randomizer service in this case).service
layer is responsible for game rules (use case).domain
layer is responsible for business logic and entities.
- All dependencies are injected into the components on
presenter
layer.
If you have found any issues or have any suggestions, please report them in the project's issue tracker.
This project is licensed under the MIT License.