Skip to content

Don't route through rival cities or onto foreign-unit tiles - #1002

Open
Billytifft wants to merge 1 commit into
C7-Game:Developmentfrom
Billytifft:billy/ai-routing-foreign-barriers
Open

Billytifft wants to merge 1 commit into
C7-Game:Developmentfrom
Billytifft:billy/ai-routing-foreign-barriers

Conversation

@Billytifft

Copy link
Copy Markdown
Contributor

Summary

Two related AI-routing fixes around foreign barriers, in one small PR:

#371 — Units shouldn't route through rival cities. Verified the intent-based movement refactor already rejects rival city tiles as intermediate path nodes. Added 7 regression tests locking in the behavior for human and AI units (peace and war): cities are avoided in the middle of a path, but remain targetable as an attack destination; non-combat units can never enter them.

#213 — Settler AI stuck forever when destination is unreachable. The original crash ("Could not get next part of path" exception) is already gone — TryToMoveAlongPath repaths and fails gracefully with Result.Error. But a reproduction test found the settler still gets effectively stuck: SettlerLocationAI.GetScoredSettlerCandidates re-picks a destination the settler can't reach (e.g., a rival unit parked on it), so it re-evaluates the same impossible task every turn and never builds. Fixed by excluding tiles occupied by foreign units from settlement candidates.

Changes

Verification

  • dotnet build — 0 errors
  • dotnet test — 83 passed, 0 failed
  • dotnet format ... whitespace --verify-no-changes — clean

@ajhalme ajhalme changed the title Don't route through rival cities or onto foreign-unit tiles (#213, #371) Don't route through rival cities or onto foreign-unit tiles Sep 28, 2026
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.

Units shouldn't route through rival cities If Settler AI can't complete the next step in its path, it gives up and stays where it is forever

1 participant