feat: implement brain-driven dynamic decision making to prevent goap traps
This commit is contained in:
33
tests/test_planner_dynamic_brain.py
Normal file
33
tests/test_planner_dynamic_brain.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
from GramAddict.core.navigation.planner import GoalPlanner
|
||||
from GramAddict.core.perception.screen_identity import ScreenType
|
||||
|
||||
|
||||
def test_planner_falls_back_to_brain_when_hd_map_fails():
|
||||
"""
|
||||
Test that if HD Map routing fails because the structural target is not visible
|
||||
(and thus in explored_nav_actions), the planner falls back to the Brain
|
||||
to dynamically pick an action like 'scroll down'.
|
||||
"""
|
||||
planner = GoalPlanner("testuser")
|
||||
|
||||
# Simulate a screen where the target isn't visible
|
||||
screen = {
|
||||
"screen_type": ScreenType.OWN_PROFILE,
|
||||
"available_actions": ["press back", "scroll down", "tap profile tab"],
|
||||
"context": {},
|
||||
}
|
||||
|
||||
# Simulate that 'tap following list' failed previously and is in explored actions
|
||||
explored = {"tap following list"}
|
||||
|
||||
# The brain should realize that 'scroll down' is the best way to uncover the target
|
||||
with patch("GramAddict.core.navigation.brain.ask_brain_for_action", return_value="scroll down") as mock_brain:
|
||||
action = planner.plan_next_step("go to followers/following list", screen, explored_nav_actions=explored)
|
||||
|
||||
# Verify the brain was queried
|
||||
mock_brain.assert_called_once()
|
||||
|
||||
# Verify the brain's decision is respected
|
||||
assert action == "scroll down"
|
||||
Reference in New Issue
Block a user