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.

Before the race, once
  1. Track XMLStock Corkscrew file, read-only
  2. Geometry modelStraights and arcs integrated exactly; the lap closes at 360.00°
  3. Racing lineMinimum-curvature path inside the road, with tuned offsets in chosen windows
  4. Speed planTarget speed along the line from a friction model with load transfer, downforce and banking
  5. Stored arraysplan_y2_4.npz, line_4.4.npz: nothing is optimised during the race
Every simulator step, 50 per second

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
  1. SteeringCurvature command from the planned path plus error feedback
  2. Speed and brakingPlan target, live curvature limit, braking from required deceleration
  3. Traction and ABSRear slip limit, front slip brake relief
  4. Gearbox and launchLowest gear under the rev limit; standing-start clutch
Conceptual diagram, from the repository code and README. The simulator link is the SCR server on UDP port 3001.

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

Speed along the validated lapRecorded speed in kilometres per hour against distance from the start line over one lap of 3.608 kilometres. Speed rises from a standing start to a peak of 293.6 kilometres per hour near 2,313 metres, falls to 84.9 kilometres per hour at the slowest point near 2,458 metres, and to 86.4 kilometres per hour at the hairpin near 3,282 metres. The table below lists these points.010020030005001,0001,5002,0002,5003,0003,5007701,0421,5281,9312,700330–680CorkscrewDistance from the start line (m)Speed (km/h)
Measured. Recorded telemetry of the 65.968 s lap, every 10th sample. The shaded band and the ticks along the top mark the corner windows the optimiser searched (positions as listed in the repository README). Circles mark the points in the table below.
Points read from the telemetry in the chart (nearest recorded sample)
PointDistance (m)Speed (km/h)Note
Start line059.3Standing start from a grid about 10 m behind the line, so the first sample is already moving.
Top speed2,313293.6Highest sampled speed of the lap.
Slowest point2,45884.9Inside the Corkscrew window (2,301 to 2,493 m), where the P1 racing line changed.
Hairpin3,28286.4Lowest-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.

  1. 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

  2. 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

  3. 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

  4. 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

  5. 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

  6. 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

  7. 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.

  8. 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.

  1. 01
    Validation 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.
    9 Oct 2026TORCS results screenshot, project history
    Official lap time 279.22 s
  2. 02
    V2, 80 km/h ceilingFirst speed controller.
    9 Oct 2026TORCS results screenshot, project history
    Official lap time 207.14 s
  3. 03
    V3, 100 km/h ceilingSteering, corner, braking, traction, gear and recovery logic. Three consecutive official runs gave exactly the same time.
    9 Oct 2026TORCS results screenshot, project history
    Official lap time 186.56 s
  4. 04
    V3.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.
    10 Oct 2026Project history report
    Official lap time 185.11 s
  5. 05
    Model-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.
    10–11 Oct 2026Tuned car fileProject history report
    Official lap time 89.386 s
  6. 06
    Best 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.
    11 Oct 2026Tuned car fileResult file in the local project folder (not published)
    Official lap time 67.064 s
  7. 07
    Stock-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.
    13 Oct 2026Result file in the local project folder (not published)
    Official lap time 74.750 s
  8. 08
    Slide 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).
    13 Oct 2026Result file in the local project folder (not published)
    Official lap time 68.846 s
  9. 09
    Hairpin entry and exit workA local plan around the hairpin; three identical official runs.
    13 Oct 2026Result file in the local project folder (not published)
    Official lap time 66.986 s
  10. 10
    Minimum-time line, first corner complexTwo identical official runs. Start of the simulator-in-the-loop series.
    14 Oct 2026Result file in the local project folder (not published)
    Official lap time 66.906 s
  11. 11
    Corner windows at 770 m and 1,042 mPer-window search, ranked by official lap time (66.686 s after the 770 m window).
    14 Oct 2026Repository README table
    Official lap time 66.526 s
  12. 12
    330–680 m complexLine and speed nodes searched together, after the 2,700 m window (66.506 s).
    14 Oct 2026Repository README table
    Official lap time 66.356 s
  13. 13
    Launch 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.
    Oct 2026Repository README table
    Official lap time 66.262 s
  14. 14
    Traction 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.
    Oct 2026Repository README table
    Official lap time 66.020 s
  15. 15
    Corkscrew 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.
    Oct 2026Result file in the repository
    Official lap time 65.968 s
  • 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.

Lap time after each final optimisation phaseLap time in seconds after each phase: phase 2A 66.262 seconds, then phase 2B 66.020 seconds, then phase 2C 65.968 seconds. From phase 2A to phase 2C the lap falls by 0.294 seconds. The time axis runs from 65.9 to 66.3 seconds, not from zero. The table below lists the same values.65.966.066.166.266.366.262Phase 2A66.020-0.242Phase 2B65.968-0.052Phase 2CFinal optimisation phases (axis zoomed: starts at 65.9 s, not zero)Lap time (s)
Measured. Official local TORCS lap times, stock car, one lap, zero damage. From phase 2A to phase 2C the lap fell by 0.294 s. The axis is zoomed so that fractions of a second are visible; on the full-scale ladder above they are barely a pixel.

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.

Corkscrew window, controller F2 against final P1
MeasureF2 (phase 2B)Final P1
Lap time66.020 s65.968 s
Corkscrew peak sideslip14.4°9.4°
Corkscrew minimum speed79.9 km/h84.2 km/h
Lap damage00

The last 0.9 seconds

Cumulative effect of each optimisation step on the stock car (repository README and documentation)
StepOfficial lap (s)Change (s)
Starting point for this series66.906—
1,528 m corner window66.780-0.126
770 m corner window66.686-0.094
1,042 m corner window66.526-0.160
2,700 m corner window66.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.

Limits

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.

P1 validation runs published in the repository
RunStart orderLap (s)DamageTimeoutsCounted
Repository run 1repository validation script65.96800Yes
Repository run 2repository validation script65.96800Yes
Repository run 3repository validation script65.96800Yes
Repository run 4repository validation script65.96800Yes
Repository run 5repository validation script65.96800Yes
  • 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

The blue IBM race car on the Corkscrew circuit in TORCS at 256 km/h, with the speed and rpm gauges, track map and timer on screen.
Simulator
TORCS, Corkscrew
Start
Standing start
Damage
0
Recording
Full lap
Final recorded time
01:05:96

The final P1 controller driving one standing-start lap of the Corkscrew circuit in TORCS: 65.968 s with zero damage. A single recording of the race, with a title card before the start and a credit card after the results.

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

Public repository

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.

Open the repository on GitHub (opens in a new tab)
Disclosures

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.