Gap to leader and interval to car ahead in the feed #16
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Depends on
Reference
mintopia/blur#16
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What to build
Time gaps for an F1-style timing tower: per racer,
gap_ms(behind the leader) andint_ms(behind the car directly ahead), in single-player, split-screen and network races.Where the data is (shipped
Blur.exe, needs runtime confirmation)The racer object (vtable
0xe72ac8) holds track-progress floats next to the position byte (+0xefc; getter0x436170returnsracer+0xefc), all zeroed at race init (0x450d05):+0xf08float: looks like cumulative race distance.0xc26c24loads+0xf08of two racers, scales both and compares the difference with a threshold;0x463b4dfinds the racer whose position byte is 2 and subtracts its+0xf08from another racer's (lead distance).+0xf00float: looks like progress within the current lap.0x468e00: on the last lap (lap == laps) compares+0xf00against a global threshold (0x112a674), i.e. "near the end of the final lap";0x44dc28passes+0xf00of two racers to a helper at0x45ee90.Units (metres vs. normalised) are unknown.
Approach
+0xf00,+0xf08, lap and position for all racers over a few laps (SP and 2-instance LAN). Confirm+0xf08grows monotonically with distance driven across laps (and what happens on a lap decrease / reset), find its units and whether it is updated for remote racers. If neither field is a usable progress measure, stop and comment the findings on this issue instead of implementing.+0xf08distance, race clock in ms from the lap-times ticket), sampled at the scan rate (5 Hz). A racer'sgap_ms= now - the time the leader was at that racer's current distance (linear interpolation between samples).int_ms= same against the car one position ahead (keep a short history per racer, or difference ofgap_msvalues). Leader has no gap. Lapped racers: gap as time (can exceed a lap); optionally addlaps_down.dist(rounded+0xf08) instandingsso clients can do their own maths.Proposed shape
Add to each
standingsentry:gap_ms,int_ms(integers, absent for the leader and before the leader has history),dist.Acceptance criteria
standingsentries carrygap_ms,int_ms,disttests/race_feed_test.cpp: interpolated gap from a synthetic leader history, interval to car ahead, leader omitted, history reset between racesdocs/state-websocket.mdupdatedBLUR_ENGINE=recompBlocked by
Done on harmonic/task-14 (
95812a0). standings entries now carry dist (race progress in laps, 3 decimals), and gap_ms/int_ms for non-leaders. Runtime check (recomp, SP 20 racers + 2-instance LAN): +0xf08 = lap byte + +0xf00 (fraction of lap), normalised not metres, continuous across the line, keeps rising after finish; grid starts ~0.8; stale 1.8->0.8 reset at race init (history clears on a >0.25 lap drop). Remote racers update; cross-machine dist agrees median 0.02 s, p95 0.07 s. Gaps use the front-runner (max dist) history with linear interpolation; int_ms = gap difference to car ahead. Unit tests added (interpolated gap, interval, leader omitted, reset between races); race_feed/game_state/state_ws pass. ADR 0013 and docs/state-websocket.md updated. Not verified: LAN race where both cars drive from the start (second car idled in the captured run, so gap-vs-gap comparison on both sides not done); menu driving of 2 instances was flaky.Done: standings now carry dist, gap_ms, int_ms (gaps interpolated from front-runner progress history, cleared between races). Unit tests, ADR 0013, ws docs updated. Last fix: removed inaccurate reset comment in race_feed.cpp.
Follow-up on harmonic/task-14 (
48f2f4c,987d155). This closes the unverified LAN criterion and fixes the defects the LAN run exposed.LAN verification (recomp, 2 instances, both cars driving 3 laps, lead swapped several times): the two machines'
gap_msfor the same racer at matched times agree to a median of 0.010 s and a p95 of 0.055 s (799 samples). 5 single samples were 0.3–0.9 s apart, all at wall collisions where the leader stalled near the trailer's distance. Frozen finish gaps: 3.31 s and 3.26 s, against a 3.38 s difference in race_ms. An earlier run gave 0.011 s / 0.087 s over 857 samples. Results are in ADR 0013.Why the previous run had one-sided gaps: the leader history only started once the local racer crossed the line. Also, the unfocused instance lost throttle because
windowDidResignKeyclearskey_state. That is a test-harness issue; I drove throttle via the virtual pad trigger instead.Fixes:
+0xf08at exactly the lap count for about 0.4 s.gap_msfreezes at the finish, as on an F1 timing tower. Before this, it drifted because+0xf08keeps rising after the line.gap_msfor the cars behind it.int_msstill needs the car ahead to have a gap.docs/state-websocket.mdand ADR 0013 are updated.Not runtime-tested: split-screen (same code path) and an SP pause (covered by a unit test).
laps_down(optional) is not done.Completed and merged by Harmonic (task 14).