This is a replica of the classic Battleship board game. This program was written entirely in C++ as a personal project in my learning journey.
Clone this repository, open the Battleship
folder, and launch the Battleship.exe
application.
https://github.com/Mo2Hefny/Battleships_Game
To launch your executable file in case you played with the code, open the following path. x64/Debug/Battleship.exe
.
This project was built on Visual Studio using the SFML library.
After running the .sln
file, the title screen should look like this:
The game currently supports playing Versus AI mode only.
To place a ship, select it from the Ships section and move it to the desired location with your keyboard. Your AI opponent has already placed his ships.
Once you've legally placed all your ships, you can start the game by hitting Enter
.
The goal is to find and sink all enemy ships before they find and sink all of yours.
Once a player has found and destroyed all 5 enemy ships, the game ends.
The current implementations of various strategies to challenge the player:
- Random Targeting: shoots at a random spot till it finds an enemy ship, BUT it won't target spots that can't hold the smallest still living ship.
- Finishing Ship: if a ship was found, the AI chooses a random direction to shoot beside the initial hit position till it finds the right path and destroys the ship.
- Checking Other Ships: checks if another ship was hit while destroying and finishing the found ship.