game-loop-battle-detector-fires-on-unverified-screens
Diagnosis + verified solution written to ~/GAP-021-solution.md (331 lines, self-contained).
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."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.fb2360c, verified in clone)_is_verified_battle_screen() consults RAMReader.screen_type() (Gen-1 WRAM battle flag); falls back to vision "battle" only when RAM is unknown._detect_battle_transition(): starts battles only on verified evidence; tracks _current_battle_opponent_identified; end outcome = defeat / victory (only if opponent identified) / unknown.database.log_battle_end: converts victory → unknown whenever enemy_pokemon is None/empty or matches unknown/unidentified/unclear/silhouette markers (is_identified_opponent()).test_game_loop.py + 1 parametrized test in test_game_database.py + integration enemy_pokemon="Pidgey" fix.fb2360c^, new tests applied): 6/6 FAIL — phantom rows + victory for unidentified sprites reproduced exactly.HEAD == fb2360c src): 6/6 regression tests PASS; 169 passed across test_game_loop.py, test_game_database.py, test_integration.py (9.59s).git diff fb2360c HEAD -- src tests empty → no source drift; matches judge verdict tier2 PASS 20b57192 (21 battle tests).# 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": ""}Diagnosis + verified solution written to ~/GAP-021-solution.md (331 lines, self-contained).
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."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.fb2360c, verified in clone)_is_verified_battle_screen() consults RAMReader.screen_type() (Gen-1 WRAM battle flag); falls back to vision "battle" only when RAM is unknown._detect_battle_transition(): starts battles only on verified evidence; tracks _current_battle_opponent_identified; end outcome = defeat / victory (only if opponent identified) / unknown.database.log_battle_end: converts victory → unknown whenever enemy_pokemon is None/empty or matches unknown/unidentified/unclear/silhouette markers (is_identified_opponent()).test_game_loop.py + 1 parametrized test in test_game_database.py + integration enemy_pokemon="Pidgey" fix.fb2360c^, new tests applied): 6/6 FAIL — phantom rows + victory for unidentified sprites reproduced exactly.HEAD == fb2360c src): 6/6 regression tests PASS; 169 passed across test_game_loop.py, test_game_database.py, test_integration.py (9.59s).git diff fb2360c HEAD -- src tests empty → no source drift; matches judge verdict tier2 PASS 20b57192 (21 battle tests).# 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": ""}