RollerCoaster Tycoon is remembered for the coasters. Almost none of its code is about them. It is about people walking around deciding where to go next, and the decision is cheap on purpose. A guest picks a destination, the game searches the footpath layout on the guest’s behalf, and the search stops once it has passed five junctions: from there the guest walks the best route it has seen so far [2]. Five is not a hardware limit. It is a design choice written as a constant, and it sits in a file where every number is that small.

That single number is the game in miniature. A management game spends its budget on behaviour rather than on what the park looks like, and the behaviour is bought in constants this size [2]. Reading them in order explains why a management sim from 1999 feels the way it does, and why so much of the genre underneath still looks the same.

The wall

Sawyer describes the constraint in terms of size before anything else. “It’s very, very compact. We were right on the limit, and it was the only way to get a game that is compact enough” [1]. The budget was the whole game, measured in single megabytes: the path networks, the ride state, the scenery, and every guest in the park needing a destination and a route.

The second half of the wall is cycles. “You could get absolutely the most possible out of the machine, and you could work out how many cycles each instruction used, you could optimise it” [1]. Behaviour that is cheap enough to run for a crowd on hardware of that era is behaviour someone budgeted instruction by instruction, not behaviour someone wrote and hoped the compiler liked.

The move

Sawyer’s first decision is not a design decision at all, in the sense a systems article would use the word. It is a language choice, stated as a habit: “I’ve always written in assembler” [1]. The toolchain, in his words, was “Microsoft Macro Assembler” [1]. The rejected alternative is implied by the answer: write the game in a higher level language and accept what the compiler emits, which is the normal way to build software.

The second decision is the interesting one. Every guest needs a route, and the obvious answer is the best one: keep exploring until no unexplored junction can beat the best path found so far. That is what an A* search does, and the decompilation names it explicitly as the thing this code is not [2]. RollerCoaster Tycoon does not do that. It caps the work by counting junctions and returns whatever is best when the budget runs out.

The constants

In the decompilation, the cap is not one number. There are five limits, and they are all small:

// GuestPathfinding.cpp
kMaxJunctionsStaff = 8
kMaxJunctionsGuest = 5
kMaxJunctionsGuestWithMap = 7
kMaxJunctionsGuestLeavingPark = 7
kMaxJunctionsGuestLeavingParkLost = 8

The shape of that table matters more than any single row. A staff member gets eight junctions; a guest gets five. A guest holding a park map gets seven. A guest who is leaving the park gets seven, and a guest who is leaving and still lost gets eight. The three larger budgets belong to guests in a specific situation: holding a park map, leaving the park, or leaving and lost.

So the walking rule is: look five junctions ahead, commit, walk, repeat. A guest who has reached a junction and is still unsatisfied does not get a bigger search. The search already ended. The guest acts on the best answer it obtained, and the park keeps moving.

What the search actually is

The decompilation is careful to say what it is not, in a comment that reads like a correction: “Unlike an A* search, which tracks for each tile a heuristic score … a single best result ‘so far’ … is tracked via the score parameter” [2]. And then the plain description: “The implementation is a depth first search of the path layout in xyz according to the search limits” [2].

Depth first, with a score parameter carrying the best tile seen so far. Because the traversal is depth first, nothing is ordered by score in a queue. “The primary heuristic used is distance from the goal; the secondary heuristic used (when the primary heuristic gives equal scores) is the number of steps” [2]. Distance first, then fewer steps as the tiebreak. Two routes at the same distance are separated by length, and nothing more expensive than a counter is consulted.

There is one more deliberate refusal in the same file: “the search ignores thin paths that are ’no through paths’ no matter how close to the goal they get, but will follow possible ’through paths’” [2]. A thin path that leads nowhere is pruned even when it points straight at the destination, because a guest that walks down it has to walk back. The search is bounded in junctions and pruned by the shape of the path graph, and both of those are cheaper than exploring further.

Behaviour as a substate machine

The peep structure carries the rest of the answer. Behaviour is not one action enum per guest. It is a set of substate machines [3]: PeepSittingSubState, PeepRideSubState, PeepUsingBinSubState, PeepSpiralSlideSubState. A guest is inside one of them at any moment, and none of them plans a day.

That is the same trade made twice. The pathfinder refuses to search beyond five junctions, and the behaviour layer refuses to represent anything more ambitious than a current activity with sub-steps. Sawyer’s own description of the code is unromantic: “It’s very, very, very simple tasks it’s doing, but the processor is actually doing these instructions millions of times a second” [1]. Simple tasks, repeated, over a crowd. The budget went into making the repetition affordable, not into making one decision smart.

The shadow

The cost is that a guest can walk a worse route and the game will never notice. A search that stops after five junctions has no way to know whether the sixth junction held something better, and it does not care: the guest is already moving, and a moving guest is the thing the park needs. The code even names the bad outcome as a state of its own. kMaxJunctionsGuestLeavingParkLost is a constant, eight junctions, for a guest that is leaving the park and still lost [2]. Being lost is not a bug in that system. It is a row in a table.

The larger cost is a convention. Management games that followed inherited crowds of individually cheap agents as the normal way to build a park, and the wandering, misrouting guest became part of what the genre feels like rather than a limitation anybody remembers choosing. A guest who takes the long way around is not evidence that the simulation is deep. It is evidence that the simulation was budgeted.

You can see the inheritance most clearly in the decompilation itself, which had to state in the header comment that this search is not A* [2]. The comment exists because the code does not look like the pathfinding a reader expects: it is a search built to be cheap, with a junction count instead of a priority queue, and pruning dead ends instead of exploring them. The constants were never meant to be elegant. They were meant to fit, and they fit well enough that a genre kept them.

References

[1] Chris Sawyer, 20th anniversary Q&A, on writing in assembler, cycle counting, compactness, and Microsoft Macro Assembler. https://www.transporttycoon.com/anniversary

[2] OpenRCT2, src/openrct2/peep/GuestPathfinding.cpp, the junction limits and the header comment contrasting the search with A*. https://github.com/OpenRCT2/OpenRCT2/blob/develop/src/openrct2/peep/GuestPathfinding.cpp

[3] OpenRCT2, src/openrct2/entity/Peep.h, the peep substate enums including PeepSittingSubState and PeepRideSubState. https://github.com/OpenRCT2/OpenRCT2/blob/develop/src/openrct2/entity/Peep.h