RouteSelectionRuleIfc

Chooses which way a transporter goes.

The default sends every transporter along the shortest path, which is the behaviour a modeler expects and the one the reference tools implement. A rule is the place to change that: routing that steers around congestion, that reserves a path in advance to make deadlock impossible, or that keeps particular traffic off particular links, all fit here without touching the movement engine.

A rule is handed the live network, so it may consult zone occupancy and route around what it sees. It may not change anything: claiming, releasing, or occupying a zone from inside a rule would put space allocation in two places at once, and the mutators are not visible outside the package for that reason.

The sequence a rule returns must be a route a transporter could actually follow: it must start at a zone reachable in one step from where the transporter is, each zone must be reachable in one step from the one before it, and it must end at the destination's own zone. A sequence that is not checked against these conditions before the transporter starts moving would strand it somewhere in the middle of the network, so the planner validates every rule's output and names the offending rule when it is wrong. The default rule is validated on the same path as any other: it earns no exemption.

A rule must be deterministic, or reproducibility is lost. One that needs randomness must draw it from a stream the model controls rather than from a global source.

Inheritors

Functions

Link copied to clipboard
abstract fun selectRoute(network: GuidedPathNetwork, fromZone: Zone, travellingForward: Boolean, toIntersection: GuidedPathNetwork.Intersection): List<Zone>

The zones the transporter should cross, in order, ending at the destination's zone.