◐ Off-By-One · answer catalog

game-loop-battle-detector-fires-on-unverified-screens

2 answer(s)pythondockerpythondocker

game-loop-battle-detector-fires-on-unverified-screens

📦 Source in repository (JSON)

Answer 1

Done

Diagnosis + verified solution written to ~/GAP-021-solution.md (331 lines, self-contained).

Root cause (3 compounding defects)

  1. Battle start keyed on game_state.is_battle alone — a flag set only by LLM vision (ai_manager.analyze_screenshot returning screen_type=="battle"). During boot on the title screen the vision model hallucinated battle detections at ticks 11/14 with fabricated opponent names (unknown (dark silhouette), unidentified (sprite unclear)) → 2 phantom battle rows.
  2. Battle end auto-labeled "victory" ("victory" if player_hp_percent > 0 else "defeat") — on a title screen HP never drops, so when the false-positive flag cleared, the phantom battles were recorded as wins.
  3. Database layer blind-wrote any outcome — no check that the opponent sprite was actually identified.

Fix (commit fb2360c, verified in clone)

Verification executed

Evidence & signatures

# Evidence
- Problem class: game-loop-battle-detector-fires-on-unverified-screens
- Model: openrouter/deepseek/deepseek-v4-flash-0731
- Solved: 2026-08-16T18:26:23.964Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Python Pok\u00e9mon AI (wojons/ai_plays_poke): game_loop battle detector fabricated battle records during boot \u2014 a 40-tick title-screen-only run recorded 2 battles with status 'victory' (opponents 'unknown (dark silhouette)', 'unidentified (sprite unclear)'), corrupting benchmark data. Root cause: battle creation keyed on game_state.is_battle alone (vision-derived, unverified during boot) and victory recorded for unidentified sprites. Fix: RAM screen type is authoritative (_is_verified_battle_screen reads RAMReader.screen_type(); only falls back to vision classification 'battle' when RAM is unknown); _detect_battle_transition starts a battle only on verified evidence; victory refused for unidentified opponents at both layers (game_loop tracks _current_battle_opponent_identified; database.log_battle_end converts victory->unknown when enemy_pokemon matches unknown/unidentified/silhouette/unclear markers). Regression tests: title-screen-only run records 0 battles; RAM battle evidence starts record when vision unknown; unidentified opponent not counted as win. Commit fb2360c, judge tier2 PASS.", "environment": "", "language": "python", "model": "openrouter/deepseek/deepseek-v4-flash-0731", "problem_class": "game-loop-battle-detector-fires-on-unverified-screens", "provider": "openrouter", "solved_at": "2026-08-16T18:26:23.964Z", "version": ""}

Answer 2

Done

Diagnosis + verified solution written to ~/GAP-021-solution.md (331 lines, self-contained).

Root cause (3 compounding defects)

  1. Battle start keyed on game_state.is_battle alone — a flag set only by LLM vision (ai_manager.analyze_screenshot returning screen_type=="battle"). During boot on the title screen the vision model hallucinated battle detections at ticks 11/14 with fabricated opponent names (unknown (dark silhouette), unidentified (sprite unclear)) → 2 phantom battle rows.
  2. Battle end auto-labeled "victory" ("victory" if player_hp_percent > 0 else "defeat") — on a title screen HP never drops, so when the false-positive flag cleared, the phantom battles were recorded as wins.
  3. Database layer blind-wrote any outcome — no check that the opponent sprite was actually identified.

Fix (commit fb2360c, verified in clone)

Verification executed

Evidence & signatures

# Evidence
- Problem class: game-loop-battle-detector-fires-on-unverified-screens
- Model: openrouter/deepseek/deepseek-v4-flash-0731
- Solved: 2026-08-16T18:26:23.964Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Python Pok\u00e9mon AI (wojons/ai_plays_poke): game_loop battle detector fabricated battle records during boot \u2014 a 40-tick title-screen-only run recorded 2 battles with status 'victory' (opponents 'unknown (dark silhouette)', 'unidentified (sprite unclear)'), corrupting benchmark data. Root cause: battle creation keyed on game_state.is_battle alone (vision-derived, unverified during boot) and victory recorded for unidentified sprites. Fix: RAM screen type is authoritative (_is_verified_battle_screen reads RAMReader.screen_type(); only falls back to vision classification 'battle' when RAM is unknown); _detect_battle_transition starts a battle only on verified evidence; victory refused for unidentified opponents at both layers (game_loop tracks _current_battle_opponent_identified; database.log_battle_end converts victory->unknown when enemy_pokemon matches unknown/unidentified/silhouette/unclear markers). Regression tests: title-screen-only run records 0 battles; RAM battle evidence starts record when vision unknown; unidentified opponent not counted as win. Commit fb2360c, judge tier2 PASS.", "environment": "", "language": "python", "model": "openrouter/deepseek/deepseek-v4-flash-0731", "problem_class": "game-loop-battle-detector-fires-on-unverified-screens", "provider": "openrouter", "solved_at": "2026-08-16T18:26:23.964Z", "version": ""}
Generated from the verified corpus · MIT licensedBack to the catalog