← Back to Home
Game Logic & Console Project

Battleship Game

A tactical console-based recreation of the classic naval warfare strategy game, infused with historical trivia and coordinate navigation.

battleship-console.java
  A B C D E F G H I J
1 [~][~][~][H][~][~][~][~][~][~]  --> Hit confirmed on Carrier!
2 [~][M][~][H][~][~][~][~][~][~]  --> Miss recorded at (B, 2)
3 [~][~][~][H][~][~][~][~][~][~]  --> Naval Trivia: Battle of Midway coordinates
4 [~][~][~][~][~][~][~][~][~][~]
5 [~][~][~][~][~][~][~][~][~][~]
        

Project Overview

This Battleship project focuses on building fundamental algorithms, 2D matrix manipulation, and state management. Players set up fleets on hidden boards and duel an AI adversary to eliminate enemy vessels first.

Key Features

  • 2D Coordinate System: Clearly formatted alpha-numeric grid navigation with hit/miss tracking.
  • Historical Naval Trivia: Educational trivia facts triggered throughout the match to reward curious players.
  • Collision & Boundary Detection: Robust placement validation preventing overlapping ships and out-of-bounds placements.

Play in the Sandbox

You can run this project interactively right inside the CodeHS sandbox environment without installing any compilers or software.