makhidkarun / traveller_pyroute

Traveller trade route generator
MIT License
14 stars 5 forks source link

Start enforcing during-pathfinding invariants #27

Closed CyberiaResurrection closed 2 years ago

CyberiaResurrection commented 2 years ago

Start implementing the during-generation invariants I listed here: https://github.com/makhidkarun/traveller_pyroute/issues/16#issuecomment-991689038

@tjoneslo , et al, a program's invariants are like a building's foundations - you need them to build a solid building (or program). Invariants describe conditions that must always hold for your program to have a chance of running correctly.

The existing code was only generating at most one of the forward or reverse routes from star A to star B, so I enforced that behaviour. The positive-edge-cost invariant actually applies to A* pathfinding itself, not PyRoute directly, but (as you can see in the commit), enforcing it saves a lot of hassle.

CyberiaResurrection commented 2 years ago

@tjoneslo , get busy while you weren't looking?

CyberiaResurrection commented 2 years ago

Thanks for rolling this up