Skip to content
This repository was archived by the owner on Mar 25, 2026. It is now read-only.

dani01Lost4ever/BattleShip

Repository files navigation

BattleShip 2.0

A classic Battleship game built with C# and Windows Forms (.NET 6). Play against an AI opponent on a 10×10 grid, placing your fleet strategically and hunting down enemy ships.

Gameplay

The game follows standard Battleship rules. Both the player and the AI start with identical fleets placed on separate 10×10 ocean grids. Players take turns firing at each other's grids until one side's entire fleet is sunk.

Fleet Composition

Ship Size Count
Battleship 4 cells 1
Submarine 3 cells 2
Corvette 2 cells 3
Lance 1 cell 4

Total: 10 ships

How to Play

  1. Place your ships — Select a ship from the panel on the right, then click a cell on your grid (left board) to place it. Use the rotation button (/) to toggle between vertical and horizontal orientation. Hovering over the grid previews ship placement.

  2. Start the game — Once all 10 ships are placed, click the Shield button to confirm. An animated spinner randomly determines who goes first.

  3. Take your turn — Click cells on the enemy grid (right board) to fire. A hit shows a flame icon; a miss shows a splash icon. A message appears when you sink a ship.

  4. AI turn — The AI fires automatically after each of your moves. It uses a hunt/target strategy: random shots when hunting, then focused adjacent attacks after a hit.

  5. Win condition — Sink all of the AI's ships to win. If the AI sinks all of yours, it wins. A dialog prompts to play again.

Debug Mode

A debug button reveals the AI's ship positions on the enemy grid (color-coded by size) and shows a data grid with exact coordinates. Useful for testing.

Requirements

Building from Source

  1. Clone the repository:
    git clone https://github.com/your-username/BattleShip.git
    
  2. Open BattleShip2.0.sln in Visual Studio 2022 or later.
  3. Build and run (F5).

No external dependencies — all assets are embedded in the project.

Project Structure

BattleShip/
├── Form1.cs               # Main game logic (ship placement, AI, turn management)
├── Form1.Designer.cs      # WinForms UI layout
├── Program.cs             # Entry point
├── BattleShip2.0.csproj   # Project file (.NET 6 WinForms)
├── Properties/
│   └── Resources.*        # Embedded image resources
└── Resources/             # Game assets (ships, hit/miss icons, backgrounds)

License

See LICENSE.txt.

About

Batlleship game, human vs AI

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages