NFSU.cc / RE Atlas / Rivals & Race AI

Rivals: how often they get stuck, and what GetUnstuck really is

Rivals & Race AI 36 verified Speed.exe addresses Speed.exe (2003, x86)

Question: how often are rivals stuck or sideways, what triggers GetUnstuck (type 0xa, update 0x452070), how long does the recovery last, what does it do to the car, and is the trigger or the timer the cause. V = read in code (address) or measured in the logs; I = inference; U = doubt. Nothing was run.

Answer

  1. The game's stuck test is not "speed < 2 m/s". It is: the car has been within 0.4 s of a contact/keep

list entry and its speed is below 5.0 m/s, or it is more than 20 m off its route line, or two special modes (vehicle+0x24 == 3 at < 25 m/s, == 4 at < 20 m/s) with 0x44e9c0(...)==1. V

  1. Trigger cost is tiny: 0.4 s under 5 m/s is enough, and the returned priority is 500, the highest in the

race selector. A rival that is merely slowed behind traffic or another car burns the recovery. V

  1. The recovery is a reverse, not a reset: the action's own speed target (racer+0x1e4) is set to

-15.0 m/s when vehicle+0x24 == 3, else -6.0 m/s, and route-node speed is disabled (racer+0x1f0 = 0). V Duration from the ctor slot 0x462ae0 = 1.3 s default, 1.6 s (float 0x3fa66666 / 0x3fcccccd) under one condition. Cooldown 6.0 s since the last creation (racer+0x408, 0x462aa0). V

  1. Measured: rivals spend 2.7 % to 8.8 % of their sampled seconds below 2 m/s (telemetry definition), with

single stops of 13.7 s to 17.9 s. GetUnstuck is entered 7 to 25 times per minute across 8 rivals (~1 to 3 per rival-minute), and 27 % to 38 % of those entries happen at speed >= 5 m/s, i.e. above the game's own threshold: those reversals are false positives, not recoveries. V (numbers below)

  1. So: yes, the trigger is the cause, and the timer makes it worse (0.4 s is far too short for a 5 m/s test on a

car that is 0.4 s behind traffic). A patch is drafted, opt-in, data only.

The trigger, line by line (asm, sub_451b00 = finder)

20 m, flag stuck. V for the constant and the compare at 0x451b87.

(now - entry+8) * 0.00025 >= 0.4 (0x6b7680) and then own speed < 5.0 (0x6b7684), with a fuzz call 0x424b50(speed, 5.0, 0.001) that can still veto (I: a rare escape roll; U: exact semantics). On a hit the local flag is set to 1. V for constants and flow, I for what the list membership means.

(0x6b768c), then 0x44e9c0(ctx+0x38c, 1) == 1 sets the flag. V for constants; U for what modes 3/4 are.

0x44dd45); both require current type != 0xa, current priority <= 500, and the 6.0 s cooldown vt+0x6c (0x462aa0), then set racer+0x408 = now and take the duration from vt+0x70 (0x462ae0). V

entry), so at least one path can create the action without the finder. I (callers V, semantics I).

The update, 0x452070 (what it does to the car)

The telemetry contract says +0x1e4 is the action's own speed target when +0x1f0 is 0, so the car drives backwards at 6 to 15 m/s, on a lane target, for 1.3 to 1.6 s. V for the stores, I for "reverse".

(Draft, priority 100, duration -1) at 0x44bc11. That is the sideways behaviour at low speed. V (addresses), I (link to the visible sideways drift).

Numbers (AIR logs, 1 Hz per rival; runs/w_*)

runspanrivalsstuck <2 m/smax stopentriesper minentries at >=5 m/stime in 0xa
w_ai_s1234 s85.3 %17.7 s297.434 %3.1 %
w_ai_s2243 s84.9 %13.9 s4611.428 %5.2 %
w_ai_s3225 s88.8 %14.1 s9425.127 %10.3 %
w_x_base190 s86.6 %13.7 s5718.035 %7.3 %
w_b314 s83.3 %17.9 s7814.938 %3.7 %
w_L3618 s82.7 %8.1 s14914.530 %5.8 %

exist (w_L3 CARL 5, 5, 6 s; w_b FISH 2-3 s runs), so the action is re-created inside the 6 s cooldown or the duration taken was longer. I/U (1 Hz sampling cannot tell a re-create from one long action).

(800,-400) and (2000,0); w_x_base (2000,-400) and (1600,0); w_b (2000,0), (1600,400); w_L3 (1600,0). Those are the same corners where AIHIT wall hits cluster; w_ai_s3 has all 94 entries on one cell (2000,-800), which is a single bad corner, not a global problem. V for the cells, I for "bad corner".

lines by distance/speed), 2.4 s in w_a (that run is not usable for timing). V

Proposed patch (opt-in, data only, reason: trigger + timer)

tools/recomp/patches.py, both floats are read only by the three stuck finders (refs: 0x451c2e, 0x451eaf, 0x451ffb for the timer; 0x451c48/0x451c54, 0x451ec5, 0x45201b/0x452027 for the speed):

Both behind RN_AI_STUCK=1, so original mode stays untouched and the log prints what changed. Not done here: the 20 m off-route branch and the mode 3/4 branch (needs to know what vehicle+0x24 is), and the -15 m/s strength (a 15 m/s reverse at speed is what looks clumsy; halving it is a separate experiment).

Not verified (U)