Skip to content

Make equal-cost pathfinding deterministic - #13361

Open
CIVITAS-John wants to merge 2 commits into
LoneGazebo:masterfrom
CIVITAS-John:pr/pathfinding-danger-cache
Open

CIVITAS-John wants to merge 2 commits into
LoneGazebo:masterfrom
CIVITAS-John:pr/pathfinding-danger-cache

Conversation

@CIVITAS-John

Copy link
Copy Markdown
Contributor

Units can choose different routes when equally good paths are explored in a different heap order. Give tied nodes a stable order so the same pathfinding inputs produce reproducible choices across heap implementations.

This is mostly needed for the offline tactical simulation project. It may make seeded games more reproducible as a result too.

PrNodeIsBetter in CvAStarNode.h preserves total-cost and heuristic priorities, then orders ties by Y, X, and normal nodes before stop nodes.

@schnetziomi5

Copy link
Copy Markdown
Contributor

Nice one!
#13349

@azum4roll

azum4roll commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Is this a common occurrence? If so, will AI behaviour be too predictable (they prefer using the northeastern path)?

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.

3 participants