Battleship made in Python
The goal of the game is to sink all 5 of your opponent’s ships before they sink yours.
- The game is played on an 8×8 grid.
- There are two players:
- Human player
- Computer
- Each player has 5 ships.
- Each ship occupies exactly one square (no multi-square ships).
- Ships are placed secretly on the player’s own board.
Each player interacts with two boards:
- Shows all available squares where attacks can be made.
- Used to track hits and misses against the opponent.
- Shows where your own ships are placed.
[ ]→ A square that contains a ship (only visible on your own board)(X)→ A successful hit on the opponent’s ship(*)→ A successful hit by the computer on your ship(-)→ An attack that missed (no ship in that square)
- A coin is tossed to determine who goes first.
- Choose one square on the opponent’s board to attack.
- The square will be marked as:
(X)if you hit a ship(-)if you miss
- It randomly attacks one square on your board.
- The square will be marked as:
(*)if it hits your ship(-)if it misses
- A square can only be attacked once.
- Ships do not move after being placed.
- Players cannot see the opponent’s ship locations.
- The computer follows the same rules as the player.
The game ends when one player has all 5 ships hit.
- If you sink all 5 computer ships first → You win! 🎉
- If the computer sinks all 5 of your ships first → Computer wins 💻