Skip to content

[US-04] Single-player mode vs. computer opponent

Ivan Esau requested to merge feature/issue-4-us-04-single-player-mode-vs-co into master

Implementation Summary

This merge request implements single-player mode against a computer opponent with the following features:

Core Requirements Implemented:

  1. Single-Player Mode: Computer places a legal fleet automatically (no overlaps/out-of-bounds, standard sizes)
  2. Computer Turn Logic: Computer selects valid untargeted coordinates and avoids repeats
  3. Difficulty Options:
    • Easy: Random shots
    • Standard: After a hit, preferentially targets adjacent cells until ship is sunk

Key Components:

  • ComputerPlayer class with automatic ship placement and shot generation
  • SinglePlayerGameService extending base game service for single-player flow
  • Difficulty enum for Easy/Standard difficulty levels
  • Comprehensive test coverage for acceptance criteria

Acceptance Criteria Verified:

  • AC1: Single-player game initializes with computer fleet that exists, is legal, and hidden
  • AC2: Computer takes turns with untargeted coordinates (never repeats shots)
  • AC3: Standard difficulty targets adjacent cells after hits until ship is sunk

Technical Implementation:

  • Layered architecture following planning documents
  • Model-View-Controller pattern
  • Java 21 with Maven build system
  • JUnit 5 test framework with JaCoCo coverage

Closes #4

Merge request reports

Loading