Skip to content

[#739] Tile-trait beliefs out of MindGraph#748

Merged
milkyskies merged 3 commits into
mainfrom
feature/#739.tile-traits-out-of-mindgraph
May 10, 2026
Merged

[#739] Tile-trait beliefs out of MindGraph#748
milkyskies merged 3 commits into
mainfrom
feature/#739.tile-traits-out-of-mindgraph

Conversation

@milkyskies

Copy link
Copy Markdown
Owner

closes #739

Summary

  • Grazable/Drinkable are objective terrain facts, not subjective beliefs. Move them out of every agent's MindGraph and read them from WorldMap directly.
  • Add TileType::has_trait(Concept) and WorldMap::tiles_with_trait(center, radius, concept) — the planner's TargetSource::TileWithTrait now does a bounded spatial scan instead of querying the agent's belief store.
  • Delete perceive_grass_tiles and perceive_water_tiles entirely. No legacy shim per the no-backwards-compat rule.
  • Per-agent subjective tile beliefs left in place: Unreachable (learned pathing failure with TTL) and Territory (per-agent claim set once at spawn) — neither churns.

Why

Audit on the issue showed 717K MindGraphMutation events over a 12-game-hour run, dominated by the perception lifecycle adding/removing (Tile, HasTrait, Grazable|Drinkable) triples as the agent walks in and out of vision. N agents perceiving the same grass tile produced N duplicate triples; the tile didn't change. Storing objective world state in a subjective belief store was the wrong abstraction.

Test plan

  • CI green on unit tests for TileType::has_trait and WorldMap::tiles_with_trait (src/world/map.rs)
  • CI green on tests/test_graze.rs::grazing_deer_has_no_per_tile_grazable_beliefs (asserts no (Tile, HasTrait, Grazable) triples appear after grazing)
  • CI green on tests/test_graze.rs::two_deer_both_graze_without_per_tile_beliefs (overlapping perception, both can graze, neither stores tile beliefs)
  • CI green on existing hungry_deer_on_grass_grazes_and_reduces_hunger and hungry_deer_on_grass_enters_graze_action

🤖 Generated with Claude Code

milkyskies and others added 3 commits May 10, 2026 12:15
Grazable and Drinkable are objective world facts derivable from terrain
type, not subjective beliefs. The audit on issue #739 showed perception
churned 717K HasTrait mutations on a 12-game-hour run, dominated by the
"agent walks in → asserts (Tile, HasTrait, Grazable) → walks out →
removes it" cycle, with N agents perceiving the same tile producing N
duplicate triples.

Replace the per-agent belief path with a direct WorldMap spatial query:

- Add TileType::has_trait(concept) and WorldMap::tiles_with_trait(...)
  that map terrain types to concepts (Grass→Grazable, water→Drinkable).
- target_enumeration::enumerate_tiles_with_trait now scans the world
  map within a planning radius of the agent — no MindGraph round-trip.
- Delete perceive_grass_tiles and perceive_water_tiles entirely. No
  legacy shim per the no-backwards-compat rule.

Subjective tile beliefs that are *not* derivable from terrain stay in
MindGraph: Unreachable (per-agent learned pathing failure with TTL),
Territory (per-agent claim, set once at spawn).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pre-#739 the herbivore-only restriction on Graze rode along with
perceive_grass_tiles, which only wrote (Tile, HasTrait, Grazable) for
herbivores. With the perception path gone, omnivores were enumerating
grass tiles too — a hungry human at (50,50) on the all-grass test map
would graze instead of walking to the apple tree, breaking the brain
cadence test.

Add Action::eligible_diets (default empty = all diets) and override on
Graze to return Herbivore. collect_planning_actions filters by it
alongside the existing satiation gate. Add a regression test that an
omnivore never starts Graze.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@milkyskies
milkyskies merged commit 8267d67 into main May 10, 2026
2 checks passed
@milkyskies
milkyskies deleted the feature/#739.tile-traits-out-of-mindgraph branch May 10, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move tile-trait beliefs out of MindGraph into world-state

1 participant