irregular6612 Claude Opus 4.8 (1M context) commited on
Commit
b571b83
·
1 Parent(s): b50b604

test(errand): memory renders walls, donut, single courier

Browse files

Honor a scenario's bespoke focal symbol when painting the chosen agent
in memory_frames: resolve chosen_idx from legend "C" (errand_runner's
courier -> C_COURIER) falling back to "A"/focal_idx. Other scenarios
have no "C" so they stay on color 1 (unchanged).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

proteus/game/runtime/memory.py CHANGED
@@ -229,6 +229,10 @@ def memory_frames(
229
  sym2idx = _invert_legend(legend)
230
  bg = sym2idx.get(".", 5)
231
  focal_idx = sym2idx.get("A", 1)
 
 
 
 
232
  predator_idx = sym2idx.get("B", 2)
233
  wall_idx = sym2idx.get("#", 3)
234
  food_idx = sym2idx.get("F", 14)
@@ -267,7 +271,7 @@ def memory_frames(
267
  elif ag.kind in _NPC_COLOR:
268
  paint(grid, ag.pos[0], ag.pos[1], ag.size, _NPC_COLOR[ag.kind])
269
  else:
270
- color = focal_idx if ag.is_chosen else distractor_idx
271
  for r in range(ag.size):
272
  for c in range(ag.size):
273
  x, y = ag.pos[0] + c, ag.pos[1] + r
 
229
  sym2idx = _invert_legend(legend)
230
  bg = sym2idx.get(".", 5)
231
  focal_idx = sym2idx.get("A", 1)
232
+ # The chosen agent paints the legend's focal sprite. Scenarios that name a
233
+ # bespoke focal symbol (errand_runner's "C" courier) honour it; the rest
234
+ # keep "A"/1. Distractor (non-chosen) agents stay on `distractor_idx`.
235
+ chosen_idx = sym2idx.get("C", focal_idx)
236
  predator_idx = sym2idx.get("B", 2)
237
  wall_idx = sym2idx.get("#", 3)
238
  food_idx = sym2idx.get("F", 14)
 
271
  elif ag.kind in _NPC_COLOR:
272
  paint(grid, ag.pos[0], ag.pos[1], ag.size, _NPC_COLOR[ag.kind])
273
  else:
274
+ color = chosen_idx if ag.is_chosen else distractor_idx
275
  for r in range(ag.size):
276
  for c in range(ag.size):
277
  x, y = ag.pos[0] + c, ag.pos[1] + r
tests/runtime/test_director_errand_runner.py CHANGED
@@ -52,3 +52,12 @@ def test_default_memory_attached():
52
  scen = get_scenario("errand_runner")()
53
  ck = scen.default_memory(7, None)
54
  assert ck is not None and ck.scenario == "errand_runner"
 
 
 
 
 
 
 
 
 
 
52
  scen = get_scenario("errand_runner")()
53
  ck = scen.default_memory(7, None)
54
  assert ck is not None and ck.scenario == "errand_runner"
55
+
56
+
57
+ def test_memory_paints_walls_donut_and_one_courier():
58
+ ck = author_errand_runner(seed=7, persona="civic")
59
+ scen = get_scenario("errand_runner")()
60
+ g = memory_frames(ck, legend=scen.legend(), grid_size=scen.grid_size)[0]["grid"]
61
+ flat = [v for row in g for v in row]
62
+ assert w.C_WALL in flat and w.C_HOME in flat and w.C_ROAD in flat # walls/donut/road painted
63
+ assert flat.count(w.C_COURIER) == w.AGENT * w.AGENT # exactly ONE 2x2 courier