Skip to main content

Module commute

Module commute 

Source
Expand description

The town’s commute optimisation, run from StockManager::Update every 300 s of game time. See docs/COMMUTE.md.

  • Start: one cell pair (residence entrance, workplace entrance) per distinct pair of map regions, each region pair cached with rank 0.
  • Step (every update): up to seven pairs, last first, get their path rank (Map::PathRank mode 0; 0 or 1 become the straight distance). With none left:
  • Homes: families in single-family residences, the longest commute first, move to the empty residence that shortens theirs most, goods and all.
  • Jobs: every working adult is let go, then each workplace takes back as many as it had, the workplace whose nearest candidate is furthest (weighted by how much of it is still to fill) choosing first; the rest get the professions left over.

Pointer orders in the original’s trees (citizens, residences, professions) are taken as index order here.

Original: FUN_140091780, FUN_1400dc590, FUN_1400dc3d0, FUN_1400db770, FUN_1400d9880.

Structs§

Commute
The optimisation’s state: StockManager (the time since the last run) and the job object (its pairs, the next pair’s index and the region-pair ranks).