It is a mix between a BattleShip game and a Minesweaper game with a GUI.
The rules are simple, the main objective remains the same as in the battleship game except that here there are mines in addition and each missed shot gives you insights on the number of ships and mines in the surrounding tiles within a certain radius.
In addition to the basic rules and functionalities of the game I implemented some features that I found useful.
Main menu
- A Player Vs Player game mode
- A Player Vs AI game mode
- An AI Vs AI game mode
- A settings tab
- Hint radius, corresponds to the radius in which you will have insights on the number of ships and mines in the surrounding tiles
- Random placement, either the player places its ships and mines, or the placement is random
- Number of ships, number of ships for each players
- Number of mines, number of mines for each players
- A help tab
- Gives you the color code of the game
Placement menu
- You have a first button to choose between placing a mine or placing a ship
- When you hover over a tile on the board and you can place the ship/mine, it is showing up on the board
Game board
-
You have a button to switch between 4 differents hint type
- Only display hints about ships
- Only display hints about mines
- Display both
- Display none
-
Another button to switch between two types of gamebaord
- Search grid, it's the hidden opponent grid with your shot displayed
- Player's grid, it's the current player grid with opponent's shot displayed
-
You can right click on a tile to place a flag as in the Minesweaper game
-
Next button to allow time for the players to move on to the next round
AI explanation
At the start of every turn, it works out all possible locations that every remaining ship could fit in. In addition to that, the neighbors of the boxes containing a ship touched but not cast are highly valued. These different combinations are all added up, and every tile on the board is thus assigned a probability that it includes a ship part, based on the tiles that are already uncovered and the ones that are known to be clear. Finally, we add to this all the information collected thanks to the clues found at each shot and we take the tile with the highest probability of having a ship on it
As it is said in the requirements.txt file, pygame and numpy are mandatory to run the program. And if you want to run some perfs test with test_AI_perf.py you will need to install the click package.
To install a new package juste run pip install <package>
To launch the game just run the gui.py file with python gui.py
If you want to make some performance tests, head into the test_AI_perf.py file, tweak the test settings and run python test_AI_perf.py
- Add a Client/Server architecture to be able to play in multiplayer
- Improve AI by enabling it to detect and avoid mines through an algorithm using inferences(the same algo used in the Minesweaper game)
- Add images instead of colored shapes
Main menu
Help menu
Settings menu
Placement menu
Game board (search board)
Game board (player's board)