fix: a_until_dialog_end breaks after a single A press (wrong dict key) - #6
Open
golldyck wants to merge 1 commit into
Open
fix: a_until_dialog_end breaks after a single A press (wrong dict key)#6golldyck wants to merge 1 commit into
golldyck wants to merge 1 commit into
Conversation
_execute_action('a_until_dialog_end') checked state.get('dialog_active'),
but dialog state is nested under state['dialog']['active'] (see read_dialog
and the state builder; autopilot.py and dashboard/history.py read it the
same way). The top-level 'dialog_active' key never exists, so the lookup
always returned the default False and the loop broke after a single A
press — long/multi-box NPC dialogs were never advanced.
Read the nested dialog flag with the same defensive pattern used elsewhere
((state.get('dialog') or {}).get('active', False)) so the loop runs until
the dialog clears or the 300-frame cap is hit. Adds unit tests covering
the loop-until-clear, max-cap, and no-dialog cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
a_until_dialog_endaction is supposed to press A every 30 frames until the dialog clears (max 300), but it exits after a single press.Cause
In
_execute_action(pokemon_agent/server.py), the loop checks:Dialog state is nested.
_get_state_dict()returnsstate["dialog"] = reader.read_dialog(), which is{"active": bool, ...}. There is no top-level"dialog_active"key. So.get("dialog_active", False)always returnsFalse,not FalseisTrue, and the loop breaks on the first iteration.The rest of the codebase already reads this flag from the nested location:
autopilot.py:95uses(state.get("dialog") or {}).get("active")dashboard/history.py:240usesstate.get("dialog", {}).get("active")Effect
a_until_dialog_endpresses A exactly once (30 frames) instead of looping. Multi-box NPC dialogs and long text are never advanced by this action, which defeats the purpose of the command.Fix
Read the nested flag with the same defensive pattern used elsewhere. This also handles
dialogbeingNone, e.g. FireRed whereread_dialogis not yet implemented:Tests
Adds
test_dialog_action.pywith a fake emulator/reader (no ROM needed):The first two fail on
main(1 press each, proving the single-press bug) and pass with this change.