This is a REST API for playing Tic-Tac-Toe against a computer.
-
Install dependencies:
pip install -r requirements.txt
-
Run the migration:
python manage.py migrate
-
Run the application:
python manage.py runserver
POST /api/games/
: Create a new game.POST /api/games/<game_id>/movements/
: Make a move in a game.GET /api/games/<game_id>/
: Get the state of a game.GET /api/games/
: List all games.GET /api/games/<game_id>/movements/
: List all movement of a specific game.
Approximately 4 hours. The first hour was spent thinking about the game logic and overall structure. The second hour involved implementing the planned logic and creating the models, serializers, and views. Finally, the last two hours were dedicated to performing manual tests to verify functionality and creating unit tests.
- The opponent makes random moves.
- The game logic is implemented in the
logic.py
file. - The game and movement data are stored using Django's ORM.
- No persistent storage for simplicity.
- Validation for moves.
- Simple winner detection.
There are test for models, serializers and views. To run the test use the command:
python manage.py test
This was an interesting challenge! It allowed me to demonstrate my skills in designing a REST API and implementing game logic in Python.