Primary Goal: Investigate and resolve the "Leonidas bug" and "Greek Fleet Movement bug" in the 300: Earth & Water game through AI agent testing and analysis.
Bug #1: Leonidas Movement Bug (CRITICAL)
- Error:
Cannot read properties of undefined (reading '0') - Location:
rules.js:443inmove_greek_armyfunction - State:
greek_land_movement_leonidas - Cause:
game.units[destination]is undefined when trying to move armies - Frequency: ~110 occurrences per 1000 games (11% error rate)
Bug #2: Greek Fleet Movement Bug (INVESTIGATION FOCUS)
- Error:
Cannot read properties of undefined (reading '2') - Location:
rules.js:452inmove_greek_fleetfunction - State:
greek_naval_movement - Cause:
game.units[from]is undefined when trying to move fleets - Frequency: ~28 occurrences per 1000 games (2.8% error rate)
- User Hypothesis: May be caused by choosing 0 as the number of fleets to move
✅ COMPLETED:
- UUID System: All games now generate unique UUIDs for identification
- Enhanced Logging: Logs use UUID as primary identifier (
game-{uuid}.log) - State Capture System: Integrated into BasePlayer for comprehensive error debugging
- Large-Scale Testing: Completed 1000 game analysis revealing bug patterns
- Bug Categorization: Errors are automatically categorized by type
🔄 IN PROGRESS:
- Investigating Greek Fleet Movement Bug (error #2)
- User hypothesis: 0 fleet movement selection causes undefined access
Core System Files:
src/base-player.js- Abstract base class with UUID generation and state capturesrc/random-player.js- RandomPlayer implementation for testingsrc/logger.js- UUID-based logging systemsrc/state-capture.js- Error state capture and debugging system
Game Rules (READ-ONLY):
rules/300-earth-and-water/rules.js- Cannot be modified (public server constraint)- Line 443:
move_greek_army- Leonidas bug location - Line 452:
move_greek_fleet- Greek fleet bug location
UUID Implementation Details:
// BasePlayer constructor
constructor(options = {}) {
this.gameUuid = options.gameUuid || uuidv4();
this.gameId = options.gameId || `game-${this.gameUuid.substring(0, 8)}`;
this.logger = new GameLogger({ gameId: this.gameId, gameUuid: this.gameUuid, ...options });
}
// Logger naming convention
const logFileName = gameUuid ? `game-${gameUuid}.log` : `${gameId}.log`;
// State capture naming
const filename = `bug-capture-${timestamp}-${gameIdentifier}.json`;CRITICAL CONSTRAINTS:
- No rules.js Modification: Agent will play on public server where rules cannot be changed
- Defensive Programming: All bug fixes must be implemented in the agent, not the rules
- UUID as Primary ID: All logging and error capture must use UUID system
Current Investigation Approach:
- Run normal games with RandomPlayer to generate logs and dumps
- Analyze dumps to understand bug conditions
- Implement defensive validations in agent to avoid triggering bugs
From 1000-game analysis:
- 862 games completed successfully (86.2%)
- 138 total errors (13.8% error rate)
- Leonidas bug: 110 occurrences (79.7% of errors)
- Greek fleet bug: 28 occurrences (20.3% of errors)
- 100% capture rate (all errors have debug files)
Bug Distribution by Campaign:
- Campaign 1: 23 errors
- Campaign 2: 25 errors
- Campaign 3: 29 errors
- Campaign 4: 40 errors (most problematic)
- Campaign 5: 21 errors
- Execute normal RandomPlayer games to generate fresh logs and dumps
- Analyze dump files for Greek fleet movement bug patterns
- Test user's hypothesis about 0 fleet movement causing the bug
- Implement defensive validation in RandomPlayer to avoid the bug condition
- Verify fix with additional test runs
Architecture Pattern: Template Method Pattern with BasePlayer abstract class
- All player types inherit common UUID generation, logging, and state capture
- Individual
makeDecision()methods implement specific AI strategies - Error handling and debugging is universal across all player types
Testing Strategy:
- Use RandomPlayer for systematic bug discovery
- State capture provides complete reproduction cases
- UUID system enables precise tracking and correlation of errors
Bug Investigation Methodology:
- Large-scale random testing to discover bug patterns
- State capture analysis to understand exact failure conditions
- Defensive programming to implement workarounds in agent
- Validation through continued testing
- Run normal games: Execute RandomPlayer games to generate fresh logs and dumps
- Analyze Greek fleet bug: Look for dump files with
greek_naval_movementstate - Test 0-fleet hypothesis: Check if RandomPlayer passes 0 as fleet count
- Implement fix: Add validation in agent to prevent problematic conditions
- Validate solution: Run test games to confirm bug is avoided
The project is well-structured with comprehensive logging, UUID tracking, and systematic bug investigation tools in place.