The whole project consists of two applications:
- Client
- Server
That are meant to work together to provide a way to play Tic Tac Toe over the Internet using sockets using the socket library in Python.
Demo can be fired of using Docker Engine.
docker
installedgit
installedmake
(optional but really useful)
git clone https://github.com/simonloach/PS_2021.git
make demo
That builds and runs a total of 11 docker containers(1 server and 10 clients) that work over docker instantiated network defined in docker-compose-demo.yml
basing on server/Dockerfile and client/Dockerfile.
Entrypoint scripts are server.py and client.py
Clients will run with option to randomize moves (x,y)
and sort of play on its own.
All will be viewed from the scope of docker compose up
command and each instance of container is distinguishable by color of the stdout
.
Now to interact with containers that play random moves attach to the container that you want to interact with from other terminal. You can do that by typing docker ps
and then copy the ID of container that you want to attach to into docker attach <ID>
. We suggest observing from the perspective of the server. To restart do make demo-down
.
Additionaly you can do make up
to start two containers with automatic moves not enabled on one of them so that you can play yourself against computer.
To restart do make down
.
Client is an application that functions as combination of user interface and endpoint translator of users inputs and Server messages. All user's inputs are being translated into our Communication Protocol described more throughly in protocol.md.
Server is an application that functions as a deamon. It allows users to connect to it and provides backend for each instance of Client to connect to. Server then handles fiding oponent for the Client initiates an instance of a Game between two Clients that become Player at this stage. Game session is being handled by server until one of the Players wins by aligning three.
- Game is being played on a grid of 3x3 size
- Each player is either 'O' or 'X'
- 'O' starts
- Player put their marks on empty tiles of the grid taking turns
- The first player to put 3 consecutive marks that line up(horizontaly or verticaly or diagonaly) wins
Classes are well commented in the code itself. The communication protocol is described in protocol.md.