Path finding algorithm is unstable, leading to stupid trade/patrol routes.

  • We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

TehJumpingJawa

Field Marshal
93 Badges
Feb 26, 2011
2.974
3.890
  • Crusader Kings II: Way of Life
  • Crusader Kings III
  • Teleglitch: Die More Edition
  • The Showdown Effect
  • Warlock: Master of the Arcane
  • 500k Club
  • Europa Universalis IV: El Dorado
  • Magicka: Wizard Wars Founder Wizard
  • Mount & Blade: Warband
  • Mount & Blade: With Fire and Sword
  • Hearts of Iron IV: Cadet
  • Imperator: Rome
  • Prison Architect
  • Imperator: Rome Sign Up
  • Europa Universalis IV: Common Sense
  • Stellaris: Ancient Relics
  • Crusader Kings II: Conclave
  • Stellaris
  • Hearts of Iron IV Sign-up
  • Stellaris Sign-up
  • Stellaris: Federations
  • Age of Wonders: Planetfall Sign Up
  • Crusader Kings II: Reapers Due
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Crusader Kings II: Monks and Mystics
  • BATTLETECH
  • Shadowrun: Hong Kong
  • Age of Wonders III
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Surviving Mars: Digital Deluxe Edition
  • BATTLETECH - Digital Deluxe Edition
  • Cities: Skylines - Parklife
  • Stellaris: Distant Stars
  • Shadowrun Returns
  • Europa Universalis IV
  • Europa Universalis III Complete
  • Surviving Mars
  • Europa Universalis III Complete
  • War of the Roses
  • Warlock 2: The Exiled
  • Warlock 2: Wrath of the Nagas
  • Victoria 2: Heart of Darkness
  • Victoria 2: A House Divided
  • Victoria 2
  • Europa Universalis IV: Res Publica
  • Sword of the Stars II
  • Sword of the Stars
  • Semper Fi
An unstable sort algorithm is one that gives non-deterministic ordering of equal elements.

Likewise an unstable path finding algorithm is one that gives non-deterministic routes when encountering equal cost nodes.

I assume Stellaris uses A* for its pathing, in which case, the open list should be changed from an unstable queue to a stable queue, thereby making the search stable.

Without this, we end up with stuff like this;

Collinear trade routes taking different paths:

20181214134120_1.jpg


and this;

Trade route & patrol route following different paths:

20181207014602_1.jpg


When this occurs (and it occurs frequently), it's a micromanagement nightmare.

If you can't, or won't, make the search stable, then rethink the trade route system.
(Though ideally you should do both)

1) Explicitly assign fleets to patrol a trade route, so they don't have to be manually routed & so their path is guaranteed to match that of the trade route.

2) Make trade stations only route to the nearest friendly trade station that's closer to the homeworld, not to the homeworld directly.
This should:
- simplify your code (collating all trade routes that pass through a system will now be implicit),
- improve the interface (no more massive amounts of duplication in the 'Trade Capitals' window.
- improve performance (shorter routes, less rerouting calculations when network topology changes)
- avoid infuriating bugs like the ones above
 

pmchem

Major
24 Badges
Apr 13, 2018
625
1.236
  • Shadowrun Returns
  • Stellaris: Nemesis
  • Stellaris: Necroids
  • Stellaris: Federations
  • BATTLETECH: Heavy Metal
  • Stellaris: Lithoids
  • Stellaris: Ancient Relics
  • Stellaris: Megacorp
  • BATTLETECH: Flashpoint
  • Shadowrun: Hong Kong
  • Shadowrun: Dragonfall
  • Stellaris: Distant Stars
  • BATTLETECH - Digital Deluxe Edition
  • Stellaris: Apocalypse
  • Stellaris: Humanoids Species Pack
  • Stellaris: Synthetic Dawn
  • BATTLETECH
  • Stellaris - Path to Destruction bundle
  • Stellaris: Leviathans Story Pack
  • Stellaris: Digital Anniversary Edition
  • Stellaris
  • Pillars of Eternity
  • Crusader Kings II
  • BATTLETECH: Season pass
nice post from a user who appears to know the basics of graph algorithms, thanks!

I hope you also filed a report in the bug report forum. PDX may not read this thread.
 

incredibleharry

Private
31 Badges
Feb 13, 2017
11
0
  • Stellaris
  • Stellaris: Megacorp
  • Shadowrun: Hong Kong
  • Stellaris: Distant Stars
  • Cities: Skylines - Parklife
  • Cities: Skylines - Parklife Pre-Order
  • Stellaris: Apocalypse
  • Stellaris: Humanoids Species Pack
  • Crusader Kings II: Jade Dragon
  • Surviving Mars
  • Stellaris - Path to Destruction bundle
  • Crusader Kings II: Monks and Mystics
  • Stellaris: Leviathans Story Pack
  • Stellaris: Digital Anniversary Edition
  • Crusader Kings II: Reapers Due
  • Crusader Kings II: Conclave
  • Crusader Kings II: Horse Lords
  • Pillars of Eternity
  • Crusader Kings II: Way of Life
  • Cities: Skylines
  • Crusader Kings II
  • Europa Universalis IV
  • Stellaris: Synthetic Dawn
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: The Republic
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: Charlemagne
One thing that occurred to me is that it may be optimizing for a limited amount of trade protection on a given route. Thus in your second picture, it's possible that the trade between LR-9 and Delta Pavonis exceeds the protection available on that route, so they're piping half of it through Devil's Maw to take advantage of unused protection capacity along that alternative route.

Oh also, it should try to avoid systems with hostiles?
dontgothatwaythen.jpg

Like why are they going through a horde? You can fix this by going in and prohibiting navigation in the system, but why should I have to do that?