Preparing your design workspace

Loading the problem and your saved attempt…

Design and Implement a Terminal Battleship Game

Model a two-player Battleship match and implement a terminal runner over its placement, shot-resolution, turn, and victory invariants.

Design and implement the core domain layer and a terminal runner for a Battleship game. For this exercise, assume one in-memory, two-player match uses rectangular boards and a supplied fleet specification of ship identifiers and positive lengths.

Before play, each player enters a ship identifier, length, starting coordinate, and horizontal or vertical orientation for every ship; the entered length must match the supplied fleet specification, placements must stay within the board, and ships may not overlap.

After both fleets are ready, players alternate one shot at an untried coordinate on the opponent's board. An accepted shot returns miss, hit, or sunk. An out-of-bounds, repeated, setup-phase, finished-match, or out-of-turn shot is rejected without changing match state. The match ends when one fleet has no unsunk ships.

Design the objects, responsibilities, interfaces, and interactions, then implement the bounded placement and shot-resolution core plus a deterministic terminal command loop in the language of your choice.

The terminal adapter must parse commands for placing a ship, marking a player ready, firing a shot, and reading status; map tokens into domain values; print an unambiguous success or error result; and keep all rules inside the domain layer.

Ship-adjacency rules, random placement, artificial intelligence, graphical user interfaces, salvo rules in the base game, and rematches are out of scope. Networking and persistence are not part of the implemented core; a final follow-up discusses running the finished core as an online service that hosts many matches.