OpenTPW

WANDER: the guest's decision state (6), its walk (7) and the staff patrol#

Lane: WANDER (research and plan, 2026-10-13). This lane covers GUEST-010 ("OpenTPW has no separate state 6") and the handyman positions behind ECON-022. Before this lane OpenTPW let a guest decide on a seconds timer (DecisionIntervalSeconds) and wander one random neighbour cell at a time, and it tested the leaving rule for every walking guest on every park turn. The original does none of that: a guest alternates between a decision state (6, "Doing nothing") and a walk to a chosen destination (7, "Walking around"). Staff patrol with the same destination routine, restricted to a rectangle.

Source: the decrypted Windows v2.0 tp.exe (SHA-256 5472f97b…1b805), read with REA (Ghidra) and capstone, statically. The Mac build has the same routines; the Mac addresses are not mapped here. Confidence as in QUEUE-plan:

The x86 oracle executes both routines (ORACLE.md section 7.14): tpw-exe-guest-state6 (X18) and tpw-exe-wander-destination (X19) agree with this description on every input.

1. The guest state dispatcher#

0x5019f0 runs once per guest update and dispatches on the state word +0x220 (KIDSTATES indices; the state setter is 0x501db0). For this lane:

StateHandlerBehaviour
6 Doing nothing0x4fec90the decision tree of §2 (high)
7 Walking aroundinline0x4fa2a0 walks one step. It returns 0 on arrival, 1 while walking, 2 when stuck. On 0 or 2: if rand & 3 == 0 and the wander destination 0x4f9490 (§3) succeeds, stay in 7, else state 6 (high)
8 (activity)inlinewhen the turn passes +0x208 + 10 (unsigned, 0x501d26), 0x4fc890 ends the activity and returns to the state saved at +0x224 (high)
9 Throwing away litter0x4fff20walks to a bin (not read in detail)
10 Going to a ride0x4ffbc0the walk to the chosen ride (read for GUEST-011)

rand is the world LCG 0x516330 (multiply by 1664525, add 1013904223, rotate right by 13, signed absolute value; ORACLE.md X1).

The two stamps are words the queue already uses:

The guest constructor zeroes both (0x4faf75, 0x4faf87).

2. State 6: 0x4fec90 (high unless marked)#

One draw R = rand() at entry; later tests use R % 3, R % 100, R % 101 and R % 5 of that same draw. T is the park turn ([0x80239c] + 0x1da70c). Bytes are _ftol of the float, low byte. Each branch that changes the state returns, so the handler makes at most one change per call. In order:

  1. Cheering. If T − +0x208 > 100 (unsigned) and the happiness byte is above 80: activity 5 (0x4fc800(5)). An activity stamps +0x208 = T, saves the state in +0x224 and enters state 8 for 10 turns.

  2. Vomiting. If the illness byte is exactly 100 and R % 3 == 0, the guest does these and returns:

    • activity 7;

    • litter type 7 on its cell (0x4d93b0(7));

    • guest event 18;

    • a sound;

    • illness = 0.

  3. Litter. If the guest's litter meter byte (+0x1b4) is at least 90 and its state is 6, 7 or 10:

    • The nearest object with flag +0x32 bit 0x40 (a bin, medium) within radius 3 that a route reaches becomes the target, and the guest goes to state 9 and returns.

    • Otherwise it draws rand() again, drops litter of type 1 + R2 % 5 on its cell, sets the litter meter to 0 and goes on.

  4. Leaving gate. If the happiness byte is 0, the exit counter +0x1bc is 0, or the park is closed (+0x1da710):

    • happiness drops by the big step (0x4fea70(2));

    • the guest tries a route to the two gate cells, (+0x7855cc, +0x7855d0) and (+0x7855d4, +0x7855d0), in an order by R & 1, twice;

    • the first route found sets state 18 (leaving) and returns;

    • if neither is found, it goes on.

    This is the rule of GuestLifecycle.ShouldLeave (ORACLE.md F26), tested only here.

  5. Facing a show. The nearest unoccupied object with flag 0x80 within squared distance 5 (medium: features or entertainers) turns the guest towards it. The heading is written to +0x1c, and the handler returns. This is presentation only.

  6. Facing a performer. If an object of kind 6 stands within radius 1 and the nearest guest-list object is in state 14, the guest turns towards it and returns (medium; presentation).

  7. Pranks. With the happiness byte below 15 and the prank byte +0x1c0 above R % 101:

    • prank byte 100, when R % 100 is below the settings word 0x7850e0: litter type 8 and a sound;

    • prank byte 101: litter type R % 5 + 1;

    • prank byte 102: it bursts the balloon of another guest on its cell.

    A prank records event 15 and adds 1.0 to happiness (GUEST-007).

  8. Decision, by R % 3:

    • 0, the major choice, only when T > +0x1fc + 30 (unsigned). 0x4fcb10 (the choice loop, ORACLE.md X16) picks a ride:

      • If it finds one: event 2, state 10, and +0x1fc stays.

      • If not: event 1, activity 4 (a "can't decide" pause), the small happiness drop, and +0x1fc = T.

    • 1, the walk: if 0x4f9490 (§3) sets a destination, state 7; otherwise +0x1fc = T.

    • 2: nothing.

Settings words: 0x785058/5c/60 are the small/medium/big happiness changes (key order, medium). 0x7850e0 is not identified. 0x70048c is the constant 6 (litter types 1..5 plus one).

3. The wander destination 0x4f9490 (high)#

It returns 1 when a route to a destination is set.

On a path cell (the cell has connections, 0x522810), it takes rand % 5 + 1 steps (a do-while; one more each time the last step ends on the start cell). Each step:

  1. The candidate neighbours are those the current cell is connected to, in the order +Y (link 16), +X (4), −Y (1), −X (64).

  2. It removes the candidates that are not allowed:

    • for staff, a neighbour outside the patrol rectangle;

    • when standing on a path cell (type 1), any queue neighbour;

    • when standing on a queue cell (type 3), the direction of its own link;

    • any neighbour of cell type 10.

  3. If fewer than two candidates remain, it takes the first one left in that order. If none remain, the guest is stranded (state unchanged, return 0); staff try the patrol rectangle instead.

  4. Otherwise it starts at rand & 3 and takes the first candidate that is not the way back (the reverse of the previous step).

The destination is the last cell, at sub-cell bytes x, y = rand & 0x7f, each clamped to 5..123 of the cell's 256: always in its first quarter. 0x510100 (on the steering state +0xd4) asks the path-finder for a route there. The step directions come from the table 0x7cdba0.., which 0x4d9a65 fills at start-up: link 1 is (0, −1), 4 is (+1, 0), 16 is (0, +1), 64 is (−1, 0).

Off the paths, it searches the eight directions at distances 0..3 for a path cell that a route reaches. If none is found, it tries five random cells within ±5 cells.

4. Staff (ECON-022, phase 3; high for the handyman, read in full)#

The handyman's state machine is 0x4d73c0:

Each walk starts its job timer only on arrival.

Read in full for the handyman (2026-10-14):

Read in full for the entertainer and the guard (2026-10-14). Every staff thing is updated in list order by 0x50b360: the type's pre-update, then its state handler. States 2, 3 and 4–13 are the generic staff handlers (0x505fe0 walk to rest, 0x5061d0 resting, 0x5056e0). The per-grade tables follow PerGradeStaffConsts (0x785330, 16 bytes a grade), each followed by four spare bytes: EntertainerConstsPerGrade at 0x785398 (WorkDuration, HappinessEffectOnCell, ActivationDistance, Pounds; 16 bytes), HandymanConstsPerGrade at 0x7853ec (12), MechanicConstsPerGrade at 0x78542c (8), ResearcherConstsPerGrade at 0x785458 (12), GuardConstsPerGrade at 0x785498 (WorkDuration, Pounds; 8). The speed bonus words at 0x75c7f0 are 0, 25 and 50.

Read in full for the researcher and the shared states (2026-10-14):

Read in full for the mechanic (2026-10-14). The handler 0x4da490: 0 idles (voice 163) until the turn passes IdleDuration + +0x200; 1 patrols (voice 162, the walk drain); both end in the search 0x4da5b0: the gate, too tired ("Too tired to fix rides"), then the ride finder 0x4daa90. It walks the object list once from a cursor (on the manager at game +0x1da71a) that moves one object on per search, and takes rides broken down (state 1, 0x4e0370), upgrading (state 2, 0x4e03e0) or with mRequestedService (+0x64, 0x4e03d0) that are no toilet, whose claim (0x4e0220: +0x5e, lapsing after 100 turns when the claimant is no longer on it) is free or his, by the smallest squared distance (strictly smaller replaces). A route to its access cell claims it (0x4e01f0: +0x5e, +0x60 = the turn) and sets state 12 (no speed bonus; the advisor's "on the way" message for a ride neither requested nor upgrading); otherwise a wander or idle. State 12 0x4da740 checks the claim, walks, and on arrival at a ride that still needs him sets state 13 with the timer +0x214 (0x4da370: an upgrade's DurationOfUpgrade × WorkDuration, else (100 − the repair byte) × WorkDuration / 100; MechanicConstsPerGrade at 0x78542c); held, it clears its ride and searches. State 13 0x4da830 drains as work, counts the timer down, waits for a broken ride's fix animation, then 0x4df8f0 repairs fully (gauge 100, the claim and the request cleared) or installs the upgrade, and searches.

The player's controls (2026-10-14). The ride panel's call button (0x48ce50; art b_callmech, b_callhandy) runs 0x4dfe30: a call sets mRequestedService (+0x64) and closes the ride (mCanLoad 0, script variable 6 = 1); the mechanics' finder takes a requested ride that is no toilet, the handymen's toilet search a requested toilet at any distance (closer than the best so far); the repair (0x4df8f0) or the clean (0x4dfd80) clears it, and a cancel reopens the ride when the reopen guard allows. The employee panel's patrol buttons (0x4b5b50) clear the rectangle (0x506e90: cells (0, 0) and (127, 127), the constructor's default) or start mouse mode 0x36: the first map click stores a corner, the second orders the two and sets +0x20a/+0x20c (0x506e50, from the click handler 0x524960). The wander keeps a member inside it: from outside, up to 30 random cells of the rectangle (two draws each) that a route reaches (0x506f30), else the wander without it ("I can't reach my patrol area"); inside, the steps that leave it are removed, and with none left 0x506f30 runs again.

5. Plan#

6. Litter (high unless marked)#

A map cell record ([0x8023a0], 0x44 bytes) holds at most one item: +0x2c the type (mLitter, 0 none), +0x28 its sprite, +0x30 the handyman who claimed it (mLitterCollector), +0x34 the claim's turn, +0x38 a stinkbomb's particle.

7. Pranks (high unless marked)#

Source: docs/reverse/WANDER-plan.md in the project repository.