[US-04] Single-player mode vs. computer opponent
Implementation Summary
This merge request implements single-player mode against a computer opponent for the Battleship game, as specified in issue #4.
Features Implemented
-
Computer Player Class (
ComputerPlayer.java)- Automatic legal fleet placement (no overlaps/out-of-bounds)
- Difficulty levels: Easy (random shots) and Standard (hunt-and-target strategy)
- Smart targeting that avoids repeat shots
- Hunting mode that targets adjacent cells after hits
-
Game Integration
- Single-player game initialization in
GameController - Computer turn execution in
GameService - Difficulty selection support
- Single-player game initialization in
-
Acceptance Criteria Validation
-
✅ Computer fleet exists and is legal but hidden -
✅ Computer never targets same coordinate twice -
✅ Standard difficulty targets adjacent cells after hits
-
Technical Implementation
- Computer AI: Strategy pattern for different difficulty levels
- Fleet Placement: Random placement with fallback systematic placement
- Targeting: Efficient untargeted position tracking
- Hunting Mode: Adjacent cell targeting after successful hits
Testing Coverage
-
Unit Tests:
ComputerPlayerTest.javacovers all acceptance criteria -
Integration Tests:
GameServiceTest.javavalidates single-player mode integration - Test Coverage: All acceptance criteria verified with specific test methods
Pipeline Status
- Compile job:
✅ Success - Test job:
✅ Success - All tests passing:
✅ Verified
Closes #4
Edited by Ivan Esau