Project 03 / 04 · Game AI · Java · University
An AI driver for a racing game
A bot that drives a car around TORCS, the open racing simulator, on its own: steering, braking, cornering and changing gear.
- Game AI
- Java
- Reflex agent
- Tuned weights

(01) Why I built it
Why I built it
TORCS is an open-source racing simulator. In the competition setup the bot runs as a separate client that only sees what the car's sensors report, so every driver gets the same information. Our job was to write that driver. I built it with Ali Jarrar and Shehroz Khan at FAST.
(02) How it works
How it works
- 01
A client talking to the race
The driver is a Java client. A build script compiles it and a run script connects it to the race server on localhost, port 3001. Every tick the server sends the car's sensor readings and the client answers with steering, throttle, brake and gear.
- 02
Everything tunable in one place
A Config class holds the parameters: top speed, top speed in corners, how early to start braking before a turn, brake strength, and the weights that scale each action. A singleton evaluator hands the current configuration to the driver.
- 03
The driver's decisions
MyDriver steers using the track edges and the car's angle to the track, caps speed in corners, handles obstacles, and shifts gear by RPM: up at 5,000, 6,000, 6,500 and 7,000, and down at 2,500, 3,000 and 3,500.
- 04
Neural network first, then something that worked
We tried a neural network first and it didn't drive well. We switched to a simple reflex agent: clear conditions, with constants multiplied into each action. Then we ran a tool that searched for better weights and plugged them back in, which made the car noticeably sharper.
Stack · Java · TORCS · Client and server over UDP · Reflex agent · Weight optimisation
What it taught me
What it taught me
The cleverest approach isn't always the one that ships. A well-tuned set of simple rules beat our neural network, and tuning the numbers did more than adding new behaviour.
Next project
Peer-to-peer file sharing over UDP