Skip to content

fix: wire Rhizome methods into smart_hard AI gameplay loop - #60

Merged
linkbag merged 1 commit into
mainfrom
feat/ic-verify-rhizome-gameplay
Mar 9, 2026
Merged

linkbag merged 1 commit into
mainfrom
feat/ic-verify-rhizome-gameplay

Conversation

@linkbag

@linkbag linkbag commented Mar 9, 2026

Copy link
Copy Markdown
Owner

Summary

Three Rhizome methods were computed every frame but their results were never read by AI.ts, making them dead code despite the 30-unit test suite passing.

  • meetsSpacingRule — now checked in findBuildingPlacement() and findDefensePlacement() so smart_hard buildings obey the Rule-of-3 tile spacing. Prevents AoE bombardment from wiping a cluster of same-type buildings/turrets.

  • getPotentialFieldBias — now applied in issueFormationApproach(). Each unit's attack waypoint is nudged by the potential field gradient (avoid turrets, escort harvesters, explore fog) at 2-tile strength. A cachedState field threads GameState into the helper without changing call-site signatures.

  • pressure density state — getDensityState() was already handling 'isolated' (retreat), but 'pressure' (outnumbered-by-enemies cluster) was silently ignored. Pressured units now skip the HP-based retreat check and flood forward (overspill behavior).

All previously-wired hooks remain unchanged:

  • rhizome.update() — every frame ✅
  • rhizome.getOrganPriority() — followTechTree() ✅
  • rhizome.isOverdriveActive() — retreatDamagedUnits() + considerAttacking() ✅
  • rhizome.notifyEnemySwCooldown() — tickSuperweapons() ✅

Test plan

  • npx tsc --noEmit — clean
  • npx vitest run — 62/62 tests pass (29 Rhizome, 5 AIGoals, 21 spawn validation, 4 ore recovery, 3 map balance)
  • Manual gameplay: set difficulty to smart_hard and verify buildings spread out, units avoid turrets during approach, low-HP units in large groups keep fighting

🤖 Generated with Claude Code

Three Rhizome methods were computed but never read by the AI:

1. meetsSpacingRule — now checked in findBuildingPlacement() and
   findDefensePlacement() so smart_hard buildings obey the Rule-of-3
   tile spacing, preventing AoE bombardment from wiping clusters of
   the same building type.

2. getPotentialFieldBias — now applied in issueFormationApproach() via
   a cachedState field. Each unit's attack waypoint is nudged by the
   field gradient (avoid turrets, escort harvesters, chase fog) at a
   2-tile strength so routing is influenced without overriding tactics.

3. pressure density state — getDensityState() already handled 'isolated'
   (retreat), but 'pressure' was silently ignored. Now pressured units
   skip the HP-based retreat check and flood forward (overspill).

All other Rhizome hooks (update, getOrganPriority, isOverdriveActive,
notifyEnemySwCooldown) were already wired and remain unchanged.

tsc: clean | vitest: 62/62 pass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@linkbag
linkbag merged commit a0ae31c into main Mar 9, 2026
1 check passed
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.

1 participant