Engineering / Autonomous racing
Autonomous racing on the Corkscrew circuit
A Python controller that drives a TORCS race car around one standing-start lap with no human input, built for the IBM AI Racing League. This page follows it from a first completed lap of 279.22 seconds to a locally validated 65.968 seconds with the final controller, P1. These are local validation results, not an official ranking.
- Best validated lap
- 65.968seconds, TORCS result screen 01:05:96
- Damage
- 0in every counted run
- Repository runs
- 5 / 5all 65.968 s, no timeouts
- Faster than the first lap
- 4.2×279.22 s to 65.968 s, unmodified car. The first lap was a deliberately slow driver
01Overview
One lap, no damage, as fast as the simulator allows
The challenge was to drive one standing-start lap of the Corkscrew circuit in the TORCS simulator, in the league's stock car1-ow1, with zero damage, using only a program that reads the car's sensors and sends back steering, throttle, brake and gear commands.
The controller is deterministic and model-based. It is not a trained neural network. It plans a racing line and a speed profile from the track geometry before the race, then follows them with feedback every simulator step.
- SimulatorTORCS, native Windows build (wtorcs.exe) with the SCR server
- LanguagePython (3.9.13 in the validation runs), NumPy
- CircuitCorkscrew, 3.608 km, one lap from a standing start
- CarStock car1-ow1, 100 L fuel, normal damage
- DevelopmentDeveloped and maintained by @youssefabdelkariem with AI-assisted engineering tools
- StatusLocally validated on the author's machine. Not an official league time or ranking; the organisers have not verified it
02Environment
Simulator and development setup
TORCS talks to a client program over UDP on port 3001 through the SCR server plugin. Each step the server sends the car's sensors and waits for the client's reply. The controller answers about 50 times per second, and TORCS is deterministic while it answers every step on time.
The first task was getting a lap to complete at all. On 9 October the supplied example clients were run unchanged and neither finished the lap. A deliberately slow validation driver (30 to 60 km/h) then completed it in 4:39.22 with no damage, which proved the Windows TORCS, Python and SCR chain worked.
The final entry point is the supplied starter client loop, unmodified, calling the project's driver. No TORCS asset is redistributed; the controller reads the track file from the user's own TORCS install.
03Architecture
Autonomous controller architecture
The work is split in two. Before the race, the track geometry becomes a racing line and a speed plan stored as arrays. During the race, a feedback controller follows them. Nothing is searched or trained while the car is moving.
- Track XMLStock Corkscrew file, read-only
- Geometry modelStraights and arcs integrated exactly; the lap closes at 360.00°
- Racing lineMinimum-curvature path inside the road, with tuned offsets in chosen windows
- Speed planTarget speed along the line from a friction model with load transfer, downforce and banking
- Stored arraysplan_y2_4.npz, line_4.4.npz: nothing is optimised during the race
Sensors in
- Distance from start, track position, heading angle
- Speed (forward and sideways), wheel spin, engine rpm
- Lap clock
Commands out
- Steering
- Throttle and brake
- Gear and clutch
- SteeringCurvature command from the planned path plus error feedback
- Speed and brakingPlan target, live curvature limit, braking from required deceleration
- Traction and ABSRear slip limit, front slip brake relief
- Gearbox and launchLowest gear under the rev limit; standing-start clutch
04Steering
Following the line
Steering is a curvature command: the curvature of the planned path a short distance ahead, plus feedback on lateral and heading error. Read from controller_c3.py, the pieces are:
- Look-ahead feed-forward. Curvature of the planned path at a distance proportional to speed, so the car turns in early enough for its steering delay.
- Error feedback. Gains on lateral and heading error from pole placement, with a small integral term on the difference between commanded and measured curvature.
- Understeer feed-forward. A table of extra steering that grows as the demanded lateral acceleration nears the tyre limit.
- Sideslip counter-steer and spin recovery. Steer toward the velocity vector when the car slides; blend fully into recovery if the slide grows.
- Rate limit. Steering moves by at most 0.20 of full lock per step.
- Exact road heading. In the minimum-time corner windows the error terms use the true road heading and an identified steering response delay.
05Speed and braking
Speed control and braking strategy
The speed plan comes from a point-mass friction model with axle load transfer, aerodynamic downforce, banking and a braking table. At run time the target speed is the plan a short distance ahead, limited again by the curvature being demanded right now.
- Braking comes from the deceleration needed to reach the target speed, with a short brake lead so the pedal acts before the plan's corner.
- Traction control. A rear over-speed limit that shrinks with lateral load and grows with speed.
- ABS. Front slip above 0.12 reduces the brake pedal.
- Gearbox. The lowest gear that stays under the rev limit, with a dwell time and an up and down rev window.
- Launch. A small clutch command on the grid and a larger traction allowance until 163 km/h, choosing gear from driven-wheel speed.
What the lap looks like
| Point | Distance (m) | Speed (km/h) | Note |
|---|---|---|---|
| Start line | 0 | 59.3 | Standing start from a grid about 10 m behind the line, so the first sample is already moving. |
| Top speed | 2,313 | 293.6 | Highest sampled speed of the lap. |
| Slowest point | 2,458 | 84.9 | Inside the Corkscrew window (2,301 to 2,493 m), where the P1 racing line changed. |
| Hairpin | 3,282 | 86.4 | Lowest-speed corner of the final third. |
Mean speed over the lap is about 197 km/h (3.608 km in 65.968 s; computed here from those two numbers).
06Iterations
Eight stages of controller development
Lap times are official TORCS results. Each stage names the AI-assisted tool the project history credits.
- 9 Oct · setup
Make a lap complete
Native Windows TORCS, SCR and Python 3.9 working end to end. A conservative driver finishes the lap.
279.22 s, damage 0
- 9–10 Oct · IBM Bob
Speed-limited controllers, V2 to V3.4
Steering, corner speed, braking, traction, gear selection and recovery, under an 80 and then a 100 km/h ceiling. Reliability work included 17 controlled fault tests. Anti-hunting logic cut gear changes from 148 to 43 in one comparison. In V3.4, a predictive-braking change at the chicane reduced peak steering in that window by 41% but made the lap 0.96 s slower; it is recorded as a trade-off, not a win, and V3.4 is not part of the final controller.
207.14 s → 186.56 s → 185.11 to 186.10 s
- 10–11 Oct · Codex
Model-based line and speed plan, on a tuned car file
The ceiling gave way to track geometry, a planned line and a planned speed profile. These laps used a changed car file (5 L fuel, wing angles, ride height), so they are not comparable with the rest. The best, 67.064 s, could not be reproduced in later sessions and is kept as one measured lap.
89.386 s → 67.064 s
- 13 Oct · Claude Code
A new controller for the unmodified car
A minimum-curvature line, a friction-circle speed plan and a path-following steering law, then sideslip counter-steer, spin recovery, slip-aware traction control and a lowest-gear rule.
82.888 s → 74.750 s → 68.846 s
- 13–14 Oct
Hairpin and corner-exit work
Local plans for the hairpin and the corner exits, each checked with repeat official runs.
66.986 s → 66.906 s
- 14 Oct
Simulator-in-the-loop optimisation
Because TORCS is deterministic when the client answers every step on time, one real lap is an exact measurement. A CMA-ES search per corner window, over 10 variables (6 line offsets and 4 speed targets), ranked every candidate by the official lap time and rejected any with damage, a timeout or too much sideslip.
66.906 s → 66.356 s
- 14 Oct · packaging
Portable package and validation
A single entry point through the unmodified starter client, checksums for every controller file and a one-command validation script.
- Oct · Claude Code
Final optimisation: P1
Launch settings and a finish-line braking fix (phase 2A), a global parameter search over traction control, ABS, yaw filtering and the live grip assumption (2B), and a new racing line through the Corkscrew that cut sliding (2C). A last study of the 770 m corner (2D) found no gain worth adopting, so P1 stayed final. Details in section 07.
66.356 s → 66.262 s → 66.020 s → 65.968 s
07Performance
How the lap time came down
Each row is an official TORCS lap time with one completed lap and zero damage. Bars are scaled to the slowest lap. The two hatched rows used a tuned car file and should not be compared with the others.
- 01Validation driverA deliberately conservative driver (30 to 60 km/h) proving the Windows TORCS and Python setup completes a lap. The supplied example clients did not finish.Official lap time 279.22 s9 Oct 2026TORCS results screenshot, project history
- 02V2, 80 km/h ceilingFirst speed controller.Official lap time 207.14 s9 Oct 2026TORCS results screenshot, project history
- 03V3, 100 km/h ceilingSteering, corner, braking, traction, gear and recovery logic. Three consecutive official runs gave exactly the same time.Official lap time 186.56 s9 Oct 2026TORCS results screenshot, project history
- 04V3.2 to V3.4Gear selection, anti-hunting, slip response and predictive chicane braking. Results across the series: 185.11 to 186.10 s. The 100 km/h ceiling capped further gains.Official lap time 185.11 s10 Oct 2026Project history report
- 05Model-based rewrite, first lapTrack geometry and a planned speed profile replace the fixed ceiling. Run on a tuned car file, so it is not comparable with the rows above or below.Official lap time 89.386 s10–11 Oct 2026Tuned car fileProject history report
- 06Best on the tuned car file5 L fuel, 50° front and 30° rear wing, 115 mm and 125 mm ride height. Later attempts did not reproduce the opening straight, so the result is recorded as one measured lap.Official lap time 67.064 s11 Oct 2026Tuned car fileResult file in the local project folder (not published)
- 07Stock-car controller, lightweight runnerNew controller for the unmodified car: planned line and speed profile with a path-following steering law. Its first complete lap took 82.888 s; this time came from four identical official runs.Official lap time 74.750 s13 Oct 2026Result file in the local project folder (not published)
- 08Slide control and gearbox modelAfter adding sideslip counter-steer, spin recovery, slip-aware traction control and a lowest-gear-below-rev-limit rule (laps of 74.1, 71.1 and 70.3 s on the way).Official lap time 68.846 s13 Oct 2026Result file in the local project folder (not published)
- 09Hairpin entry and exit workA local plan around the hairpin; three identical official runs.Official lap time 66.986 s13 Oct 2026Result file in the local project folder (not published)
- 10Minimum-time line, first corner complexTwo identical official runs. Start of the simulator-in-the-loop series.Official lap time 66.906 s14 Oct 2026Result file in the local project folder (not published)
- 11Corner windows at 770 m and 1,042 mPer-window search, ranked by official lap time (66.686 s after the 770 m window).Official lap time 66.526 s14 Oct 2026Repository README table
- 12330–680 m complexLine and speed nodes searched together, after the 2,700 m window (66.506 s).Official lap time 66.356 s14 Oct 2026Repository README table
- 13Launch settings and finish-line fixClutch and traction allowance on the standing start, then a fix for braking near the finish line: the speed look-ahead read the standing-start speed limit at the end of the lap and is now clamped to the last plan sample.Official lap time 66.262 sOct 2026Repository README table
- 14Traction control and ABS tuningA search over 145 candidates; looser traction control and earlier ABS release gave about 0.55 s more full throttle and 0.39 s less braking per lap.Official lap time 66.020 sOct 2026Repository README table
- 15Corkscrew racing line: P1, finalA straighter line through the left-right direction change at 2,301 to 2,493 m. Final package: six races at 65.968 s, and five more through the repository, all with zero damage and zero timeouts.Official lap time 65.968 sOct 2026Result file in the repository
- Unmodified car files, 100 L fuel
- Tuned car file (5 L fuel, wings, ride height): not comparable
- Final validated lap
The final phases
The final simulator-in-the-loop work took the lap from 66.906 s to 65.968 s, a gain of 0.938 s (about 1.4%). The three phases that produced the final controller are below.
Phase 2A: launch settings and finish-line correction 66.356 → 66.262 s
The standing-start clutch and traction allowance were tuned, and the controller no longer braked unnecessarily near the finish line. Its speed look-ahead read the standing-start speed limit at the end of the lap plan; clamping the look-ahead to the last plan sample fixed it.
Phase 2B: global parameter optimisation 66.262 → 66.020 s
A systematic search evaluated 145 candidates. The gains came from traction control, ABS activation, yaw filtering and the live speed limiter's grip assumption. The resulting controller, F2, spent about 0.55 s more of the lap at full throttle and 0.39 s less braking, because it intervened less where the car did not need it.
Phase 2C: Corkscrew racing line 66.020 → 65.968 s
The last significant gain came from changing the racing line, only between about 2,301 m and 2,493 m. A straighter line through the left-right direction change reduced sliding, so the car carried more speed through it.
Phase 2D: final evaluation no change
Further experiments around the 770 m corner did not help the whole lap. One candidate recorded 65.966 s, only 0.002 s quicker, which was not robust enough to replace P1. Optimising one corner is not useful if the complete lap becomes slower or less reliable, so P1 remained the final controller.
| Measure | F2 (phase 2B) | Final P1 |
|---|---|---|
| Lap time | 66.020 s | 65.968 s |
| Corkscrew peak sideslip | 14.4° | 9.4° |
| Corkscrew minimum speed | 79.9 km/h | 84.2 km/h |
| Lap damage | 0 | 0 |
The last 0.9 seconds
| Step | Official lap (s) | Change (s) |
|---|---|---|
| Starting point for this series | 66.906 | — |
| 1,528 m corner window | 66.780 | -0.126 |
| 770 m corner window | 66.686 | -0.094 |
| 1,042 m corner window | 66.526 | -0.160 |
| 2,700 m corner window | 66.506 | -0.020 |
| 330–680 m complex (line and speed nodes) | 66.356 | -0.150 |
| Launch settings and finish-line fix (phase 2A) | 66.262 | -0.094 |
| Global parameter optimisation (phase 2B) | 66.020 | -0.242 |
| Corkscrew racing line (phase 2C, P1) | 65.968 | -0.052 |
The README also records what did not work: the hairpin window gave no feasible improvement because every faster candidate exceeded the sideslip limit, and planner-only changes (speed windows, a rebuilt line and speed window, a lateral-law swap at 1,528 m) were slower in the simulator and were rejected.
08Testing
Testing and reliability
The final P1 package reproduced 65.968 s in six native Windows races, five of them through the real submission entry point, and in a seventh, graphics-mode race recorded with OBS. All had zero damage and zero server timeouts. The repository's own validation script then ran the published controller folder five more times: all five gave 65.968 s, and the result files, simulator logs and client logs are published.
The controller files matched the sealed, verified package, and the stock TORCS car, track, race and physics files were checked before and after every race and never changed.
Native Windows only. Results are from the TORCS build supplied with the league and were not reproduced in the Linux container.
Tuned to one track. The plan arrays are specific to Corkscrew. This is not a general driver.
Local validation. The times come from the author's machine. They are not official league times or rankings.
Stock files must match. Lap times are exact only when the car, track and race files match the published reference hashes.
| Run | Start order | Lap (s) | Damage | Timeouts | Counted |
|---|---|---|---|---|---|
| Repository run 1 | repository validation script | 65.968 | 0 | 0 | Yes |
| Repository run 2 | repository validation script | 65.968 | 0 | 0 | Yes |
| Repository run 3 | repository validation script | 65.968 | 0 | 0 | Yes |
| Repository run 4 | repository validation script | 65.968 | 0 | 0 | Yes |
| Repository run 5 | repository validation script | 65.968 | 0 | 0 | Yes |
- Determinism. All 3,241 logged states of a P1 reference lap were fed to the repository's driver, and every steering, throttle, brake, gear and clutch command matched exactly.
- Timing safety. A single server timeout costs about 0.4 s. The driver disables garbage collection once before the race so a collection pause cannot cause one.
- Early noise. Before the cause was found, identical settings varied by up to 1.5 s between runs. Every later result is checked for timeouts.
Technical validation details
- Track position. Maximum 0.967 of the half-width: the car stayed on the track.
- Sideslip. Peak 13.6° over the lap, and 9.4° in the Corkscrew.
- 446 m complex. 0.721 against its 0.73 limit.
- Constraints on every candidate. Complete lap, zero damage, zero timeouts, a sideslip cap and per-corner edge-clearance limits.
09Demonstration
Final demonstration
Final validated lap: 65.968 s

- Simulator
- TORCS, Corkscrew
- Start
- Standing start
- Damage
- 0
- Recording
- Full lap
- Final recorded time
- 01:05:96
Watch on YouTube (opens in a new tab)
Text description of the video
An 80-second recording with no audio track; this description covers the picture only. It opens on the starting grid with the word Ready and a title card reading "IBM AI Racing League, Final AI Controller, 65.968 s" and below it "TORCS, Corkscrew, 1 lap from a standing start, damage 0". A blue single-seater race car with the IBM name is then followed from behind through the whole Corkscrew circuit, with a track map, timer and damage panel, and speed and rpm gauges on screen. It ends on the TORCS Race Results screen: Corkscrew, one lap, total and best time 01:05:96, top speed 293, damages 0, followed by a card reading "Youssef Studio, youssef.studio".
10Source
Source code and evidence
youssefabdelkariem / IBM-AI-Racing-League
The final P1 controller, its settings, racing-line data, technical documentation, validation tools, performance evidence and compliance notes are in the repository's main branch, read here at commit e71b6fe on 2026-10-23.
Credits and licence
The gym_torcs starter client is used unmodified (MIT, upstream credits in the repository). TORCS and the league's car and track belong to their owners and are not included. The repository states that no open-source licence has been chosen for the project's own code.
Documented tools: Python, TORCS, IBM Bob, Claude Code, OpenAI Codex and OBS Studio (screen recording). This page makes no claim of contest placement, award, endorsement or official IBM recognition, and no claim that IBM Granite contributed to the controller.
11Takeaways
Lessons from the lap
- Measure the simulator, not only the model. Planner-only changes that looked good on paper were slower on track; the real simulator ranked every candidate.
- Protect the timing before tuning. A single late reply costs about 0.4 s, and part of the early variation was this, not the controller.
- Write down the conditions. The 67.064 s lap depended on a tuned car file and could not be repeated. The final result uses stock files with published hashes, so someone else can check it.
- Judge the whole lap. A corner change that gains 0.002 s is not worth adopting if the complete lap is not clearly better and just as reliable; P1 stayed final for that reason.
- Keep the dead ends. The 100 km/h ceiling, the rejected V4, and the windows that gave no feasible gain are part of the record.
- Know the limits. One track, one simulator build, deterministic only while the client keeps up.