Spaces:
Runtime error
Runtime error
Commit ·
7a406aa
1
Parent(s): 2e353ae
chore(cp6): holistic-review cleanup — drop dead EASY start consts, de-8x8 docstring, ABC-faithful test stubs
Browse files
proteus/grid/scenarios/predator_evade.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
"""predator_evade — the bear-chase evasion scenario for motive_grid.
|
| 2 |
|
| 3 |
-
A predator pursues the focal agent across
|
| 4 |
-
shortest-path (BFS) step toward it every
|
|
|
|
| 5 |
*chase* intent rather than noise (the ToM signal the benchmark probes). The
|
| 6 |
world is laced with a short internal wall that forms a **dead-end to the west**,
|
| 7 |
exactly where the focal agent has been walking. At the Cut handover the only
|
|
@@ -84,11 +85,11 @@ _REWARD_SURVIVED = 50.0
|
|
| 84 |
_REWARD_WALL_HIT = -3.0
|
| 85 |
|
| 86 |
# --------------------------------------------------------------------------- #
|
| 87 |
-
# EASY
|
|
|
|
|
|
|
| 88 |
# --------------------------------------------------------------------------- #
|
| 89 |
_GRID_SIZE: tuple[int, int] = (8, 8)
|
| 90 |
-
_FOCAL_START: tuple[int, int] = (5, 3)
|
| 91 |
-
_PREDATOR_START: tuple[int, int] = (7, 3)
|
| 92 |
# Vertical wall column forming the dead-end west of the focal's path.
|
| 93 |
_WALL_CELLS: tuple[tuple[int, int], ...] = (
|
| 94 |
(2, 2),
|
|
|
|
| 1 |
"""predator_evade — the bear-chase evasion scenario for motive_grid.
|
| 2 |
|
| 3 |
+
A predator pursues the focal agent across the grid (8x8 at EASY; larger at
|
| 4 |
+
higher difficulties) by taking one shortest-path (BFS) step toward it every
|
| 5 |
+
turn, so its motion reads as a clear
|
| 6 |
*chase* intent rather than noise (the ToM signal the benchmark probes). The
|
| 7 |
world is laced with a short internal wall that forms a **dead-end to the west**,
|
| 8 |
exactly where the focal agent has been walking. At the Cut handover the only
|
|
|
|
| 85 |
_REWARD_WALL_HIT = -3.0
|
| 86 |
|
| 87 |
# --------------------------------------------------------------------------- #
|
| 88 |
+
# EASY defaults consumed before build_level runs (class grid_size hint +
|
| 89 |
+
# __init__'s pre-build wall set). The full per-difficulty layouts — including
|
| 90 |
+
# focal/predator starts — live in _LAYOUTS below.
|
| 91 |
# --------------------------------------------------------------------------- #
|
| 92 |
_GRID_SIZE: tuple[int, int] = (8, 8)
|
|
|
|
|
|
|
| 93 |
# Vertical wall column forming the dead-end west of the focal's path.
|
| 94 |
_WALL_CELLS: tuple[tuple[int, int], ...] = (
|
| 95 |
(2, 2),
|
tests/grid/test_scenario_registry.py
CHANGED
|
@@ -14,13 +14,14 @@ def test_register_and_get_roundtrip():
|
|
| 14 |
task_name = "dummy_for_test"
|
| 15 |
grid_size = (4, 4)
|
| 16 |
rules_text = "test"
|
| 17 |
-
def build_level(self, rng): ...
|
| 18 |
def cut_focal_policy(self, game): return "stay"
|
| 19 |
def cut_length(self, difficulty): return 1
|
| 20 |
def advance_threat(self, game): ...
|
| 21 |
def check_elimination(self, game): return False
|
| 22 |
def optimal_action(self, game): return "stay"
|
| 23 |
def habit_action(self, game): return "stay"
|
|
|
|
| 24 |
def legend(self): return {5: "."}
|
| 25 |
|
| 26 |
assert get_scenario("dummy_for_test") is _Dummy
|
|
@@ -40,13 +41,14 @@ def test_duplicate_registration_raises():
|
|
| 40 |
task_name = name
|
| 41 |
grid_size = (1, 1)
|
| 42 |
rules_text = ""
|
| 43 |
-
def build_level(self, rng): ...
|
| 44 |
def cut_focal_policy(self, game): return "stay"
|
| 45 |
def cut_length(self, difficulty): return 1
|
| 46 |
def advance_threat(self, game): ...
|
| 47 |
def check_elimination(self, game): return False
|
| 48 |
def optimal_action(self, game): return "stay"
|
| 49 |
def habit_action(self, game): return "stay"
|
|
|
|
| 50 |
def legend(self): return {}
|
| 51 |
|
| 52 |
with pytest.raises(ValueError):
|
|
|
|
| 14 |
task_name = "dummy_for_test"
|
| 15 |
grid_size = (4, 4)
|
| 16 |
rules_text = "test"
|
| 17 |
+
def build_level(self, rng, difficulty): ...
|
| 18 |
def cut_focal_policy(self, game): return "stay"
|
| 19 |
def cut_length(self, difficulty): return 1
|
| 20 |
def advance_threat(self, game): ...
|
| 21 |
def check_elimination(self, game): return False
|
| 22 |
def optimal_action(self, game): return "stay"
|
| 23 |
def habit_action(self, game): return "stay"
|
| 24 |
+
def step_reward(self, game, action, blocked, focal_before, predator_before): return 0.0
|
| 25 |
def legend(self): return {5: "."}
|
| 26 |
|
| 27 |
assert get_scenario("dummy_for_test") is _Dummy
|
|
|
|
| 41 |
task_name = name
|
| 42 |
grid_size = (1, 1)
|
| 43 |
rules_text = ""
|
| 44 |
+
def build_level(self, rng, difficulty): ...
|
| 45 |
def cut_focal_policy(self, game): return "stay"
|
| 46 |
def cut_length(self, difficulty): return 1
|
| 47 |
def advance_threat(self, game): ...
|
| 48 |
def check_elimination(self, game): return False
|
| 49 |
def optimal_action(self, game): return "stay"
|
| 50 |
def habit_action(self, game): return "stay"
|
| 51 |
+
def step_reward(self, game, action, blocked, focal_before, predator_before): return 0.0
|
| 52 |
def legend(self): return {}
|
| 53 |
|
| 54 |
with pytest.raises(ValueError):
|