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 with computer opponent functionality for the Battleship game.

Features Implemented

  • Computer Player AI: Computer opponent with Easy and Standard difficulty levels
  • Ship Placement: Computer automatically places legal fleet (no overlaps/out-of-bounds)
  • Turn Management: Computer selects valid untargeted coordinates and avoids repeats
  • Difficulty Levels:
    • Easy: Random shots
    • Standard: Hunting strategy - after a hit, preferentially targets adjacent cells

Technical Implementation

  • Created ComputerPlayer class extending Player with AI logic
  • Created GameService for single-player game flow management
  • Created Game and GameState classes for game state management
  • Updated existing classes (Ship, Cell) for game logic integration

Acceptance Criteria Coverage

  • Criterion 1: Computer fleet exists and is legal but hidden
  • Criterion 2: Computer shots are at previously untargeted coordinates
  • Criterion 3: Standard difficulty hunting strategy targets adjacent cells after hits

Current Status

Pipeline Status: FAILED (#8751) Compilation: SUCCESS Tests: 79 tests run, 11 failures, 15 errors

Critical Issues Identified

  1. ComputerPlayer.placeShipsAutomatically() - Fails to place ships successfully
  2. Game.startGame() - Doesn't transition game state from SETUP to IN_PROGRESS
  3. Turn Management - "Not computer player's turn" errors in test execution

Next Steps Required

  • Coding Agent needs to fix the identified implementation issues
  • ComputerPlayer ship placement must be corrected
  • Game state transitions must be fixed
  • Turn management logic must be resolved

Closes #4

Merge request reports

Loading