[PR #100] [MERGED] Fix leaderboard incorrect positions at race start (Fixes #63) #142

Closed
opened 2026-05-07 00:18:53 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/IAmTomShaw/f1-race-replay/pull/100
Author: @heytt-satra
Created: 12/21/2025
Status: Merged
Merged: 12/21/2025
Merged by: @IAmTomShaw

Base: mainHead: fix/leaderboard-start-pos


📝 Commits (1)

  • 7baef98 Fix leaderboard incorrect positions at race start (Fixes #63)

📊 Changes

1 file changed (+9 additions, -0 deletions)

View changed files

📝 src/interfaces/race_replay.py (+9 -0)

📄 Description

Problem Description
The leaderboard was showing incorrect driver positions at the start of the race. Drivers on the grid (physically behind the start line) were being projected to the end of the lap (e.g., 4990m on a 5000m track) because the track projection logic treats the track as a closed loop. This caused backmarkers on the grid to appear as having completed nearly a full lap (Progress: 4990m) compared to the leader who had just crossed the start line (Progress: 10m).

image

Verification Results
Logic Check
Scenario 1: Car on Grid (Lap 1)

telemetry_dist: 0m (or close to 0)
projected_m: 4950m (Track Length: 5000m)
Old Result: progress_m = 4950m. (Incorrectly viewed as ahead of leader)
New Result: telemetry_dist (0) < 2500m AND projected_m (4950) > 2500m. Condition Met.
projected_m becomes 4950 - 5000 = -50m.
progress_m = -50m. (Correctly viewed as behind leader)
Scenario 2: Car crossed start line (Lap 1)

telemetry_dist: 10m
projected_m: 10m
New Result: Condition projected_m (10) > 2500m is False.
progress_m = 10m.
Scenario 3: End of Lap 1 (Approaching finish)

telemetry_dist: 4950m
projected_m: 4950m
New Result: Condition telemetry_dist (4950) < 2500m is False.
progress_m = 4950m. (Correct)
Automated Tests
Ran python -m py_compile to verify syntax correctness.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/IAmTomShaw/f1-race-replay/pull/100 **Author:** [@heytt-satra](https://github.com/heytt-satra) **Created:** 12/21/2025 **Status:** ✅ Merged **Merged:** 12/21/2025 **Merged by:** [@IAmTomShaw](https://github.com/IAmTomShaw) **Base:** `main` ← **Head:** `fix/leaderboard-start-pos` --- ### 📝 Commits (1) - [`7baef98`](https://github.com/IAmTomShaw/f1-race-replay/commit/7baef98f8e6de03f0f8a1bb3fb38644726a995ca) Fix leaderboard incorrect positions at race start (Fixes #63) ### 📊 Changes **1 file changed** (+9 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/interfaces/race_replay.py` (+9 -0) </details> ### 📄 Description Problem Description The leaderboard was showing incorrect driver positions at the start of the race. Drivers on the grid (physically behind the start line) were being projected to the end of the lap (e.g., 4990m on a 5000m track) because the track projection logic treats the track as a closed loop. This caused backmarkers on the grid to appear as having completed nearly a full lap (Progress: 4990m) compared to the leader who had just crossed the start line (Progress: 10m). <img width="746" height="425" alt="image" src="https://github.com/user-attachments/assets/5bd89c1e-a80e-47d0-aef7-2ccbd3816c9b" /> Verification Results Logic Check Scenario 1: Car on Grid (Lap 1) telemetry_dist: 0m (or close to 0) projected_m: 4950m (Track Length: 5000m) Old Result: progress_m = 4950m. (Incorrectly viewed as ahead of leader) New Result: telemetry_dist (0) < 2500m AND projected_m (4950) > 2500m. Condition Met. projected_m becomes 4950 - 5000 = -50m. progress_m = -50m. (Correctly viewed as behind leader) Scenario 2: Car crossed start line (Lap 1) telemetry_dist: 10m projected_m: 10m New Result: Condition projected_m (10) > 2500m is False. progress_m = 10m. Scenario 3: End of Lap 1 (Approaching finish) telemetry_dist: 4950m projected_m: 4950m New Result: Condition telemetry_dist (4950) < 2500m is False. progress_m = 4950m. (Correct) Automated Tests Ran python -m py_compile to verify syntax correctness. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-07 00:18:53 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/f1-race-replay#142
No description provided.