Skip to content

TimurSl/SeaBattle

Repository files navigation

SeaBattle Console Game in C#

SeaBattle is a classic strategy game where two players compete against each other to sink each other's ships on a grid-based battlefield. In this version of the game, you will be playing against the computer.

How to Play

  1. The game is played on a 10x10 grid.
  2. Each player has a fleet of ships consisting of a battleship (4 squares), cruiser (3 squares), submarine (2 squares), and destroyer (1 squares).
  3. Each turn, you will select a square on the enemy grid to fire a shot.
  4. The computer will respond with a hit or a miss. If you hit an enemy ship, the square will be marked with an 'X'. If you miss, the square will be marked with an 'x'.
  5. The game ends when all of one player's ships have been sunk.

Getting Started

To get started with the game, simply clone the repository and open it in your preferred C# IDE. The code is organized into several files:

  • Game.cs contains the main game loop.
  • Map.cs defines the game board and provides methods for placing and checking ships.
  • Cell.cs defines the ship class and provides methods for checking if a ship has been hit or sunk.
  • Program.cs contains the main method and is used to run the game.
  • Player.cs defines the player class and provides methods for shooting in ships, or any other cells
  • RoundManager.cs defines the round manager class and provides methods for managing the game rounds
  • Menu.cs defines the menu class and provides methods for displaying the game menu

Player inputs

  • PlayerArrowInput.cs defines the input class and provides methods for getting input from the user. (Arrow controls)
  • PlayerStringInput.cs defines the input class and provides methods for getting input from the user. (String controls A2)

Bot inputs

  • EasyBotInput.cs defines the input class and provides methods for getting input from the computer. (Easy bot)
  • MediumBotInput.cs defines the input class and provides methods for getting input from the computer. (Medium bot)
  • HardBotInput.cs defines the input class and provides methods for getting input from the computer. (Hard bot)

To run the game, simply compile and run the Program.cs file. The game will start with the computer randomly placing its ships on the board, and then prompt you to place your own ships. Once both players have placed their ships, the game will begin.

Conclusion

SeaBattle is a classic game that has been enjoyed by generations. This version of the game provides a fun and challenging experience that will keep you entertained for hours. So what are you waiting for? Download the code and start playing!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages