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.gitChange your current directory to the Battleships_Game directory:
cd Battleships_GameIt is recommended to use a virtual environment to manage dependencies. Create a virtual environment named env:
python -m venv envActivate 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.txtTo build the project and create a wheel distribution, use:
python -m build --wheelTo 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_serverTo start the game, run. Note that the game has an offline mode that does not require the server to be running:
python -m game.applicationTo ensure everything is working correctly, run the tests using:
pytestRun Tox to execute linting and formatting checks:
toxThis 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.pyThe 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-gameTo see the list of running containers and confirm that your game container is running, use:
docker psShow the logs of the local server:
docker logs --tail 100 my-python-game-containerStop and remove the container simualting the server using:
docker stop my-python-game-container
docker rm my-python-game-container

