Project Information

  • Category: Games
  • Origin: Practical Assignment
  • Project Date: August 20, 2023
  • URL: Click here

Battleship Game in C#

The Battleship game is a digital version of the classic board game. Here's how it works:

Initial Setup:

On the game home screen, players (computer and human) select positions for their ships. Each ship occupies a certain number of cells on the board.
Players choose the row and column where they want to place their ships.

Game Board:

The board is a two-dimensional matrix (9x9).
Cells are represented by coordinates (row, column).
Ships are placed within these cells.

Turns:

Players take turns to attack.
The human player selects a cell to attack (row and column).
The computer randomly selects a cell to attack.

Attack Outcome:

If the targeted cell contains part of a ship, it's a hit.
If the cell is empty, it's a miss.
The game continues until all parts of a ship are hit (sunk), or all attacks are completed.

End of Game:

The game ends when all ships of one player are sunk.
The result is announced: victory for the player who sank all opponent ships, or a draw if both players lose all ships.

Final Message:

At the end of the round, the game displays a message indicating whether it was a draw or if there was a winner.