Compete in Real-Time: Battle against friends or other players around the world.
-
Create & Join Rooms: Set up a new room with a unique ID and choose between public or private. Join any room by ID or jump into a random public match.
-
Manage Your Game: Toggle room privacy, exit when needed, and watch the game start once both players are ready.
-
Turn-Based Battles: Engage in strategic, turn-based gameplay. The server ensures privacy settings and manages the turn-based gameplay including time per turn validation.
-
Endgame: The game wraps up when one player's fleet is sunk, or when a player does not make his move in time.
Face the AI: Challenge a smart battle bot in a solo game.
- Quick Setup: Create a room and the AI bot will join to face you.
- Automated Challenge: Enjoy a dynamic game as the bot makes strategic moves and keeps you on your toes.
To get started with the Battleships Game, follow these steps:
If Python is not already installed on your system, download and install it from the official Python website. Ensure you select the appropriate installer for your operating system.
Open a terminal and clone the Battleships Game repository:
git clone https://github.com/TeogopK/Battleships_Game.git
Change your current directory to the Battleships_Game directory:
cd Battleships_Game
It is recommended to use a virtual environment to manage dependencies. Create a virtual environment named env
:
python -m venv env
Activate the virtual environment. The command depends on your operating system:
-
On Windows:
.\env\Scripts\activate
-
On Unix or macOS:
source env/bin/activate
With the virtual environment activated, install the required dependencies:
pip install -r requirements.txt
To build the project and create a wheel distribution, use:
python -m build --wheel
To start the server, run. Note that the server IP address should be configured correctly. This may require using tools like ipconfig
or ngrok
:
python -m game.server.multiplayer_server
To start the game, run. Note that the game has an offline mode that does not require the server to be running:
python -m game.application
To ensure everything is working correctly, run the tests using:
pytest
Run Tox to execute linting and formatting checks:
tox
This will perform linting with Pylint and check for code formatting issues.
From the project directory run the following script:
python -m PyInstaller --clean --onefile --noconsole --add-data "game;." game\application.py
The executable will be in ./dist/application.exe
.
To build the Docker image for the game, navigate to the project directory and run the following command:
docker build -t my-python-game .
After building the image, you can run the container using the following command. This requires adding localhost
as the host in the yaml file:
docker run -d -p 5555:5555 --name my-python-game-container my-python-game
To see the list of running containers and confirm that your game container is running, use:
docker ps
Show the logs of the local server:
docker logs --tail 100 my-python-game-container
Stop and remove the container simualting the server using:
docker stop my-python-game-container
docker rm my-python-game-container