A race runs in three places. A driver is tested in training, while its agent works on it. The host runs the races you watch. Your browser runs the race when you drive against a model. We want a car to behave the same way in all three.
The simulator does that job. It is the part of the game that moves the cars and applies the race rules, and all three places run the same code. It does not decide how to drive. It takes the controls of each car and works out what happens next.
The simulator moves a race forward in small steps of equal length. Each place decides when to ask for the next step and what to do with the result. None of them can change the length of a step, so none can change how a car behaves.
A circuit is a list of points
A circuit starts as an ordered list of points that outline its shape, and a width for the road. The simulator turns the points into a closed line down the middle of the road. It stores that line as samples, positions spaced evenly along the circuit.
Each sample also records the direction of travel and how sharply the road bends there. The simulator uses the samples for two jobs. To locate a car, it finds the car’s place on the line: its distance along the circuit and how far it sits to the side. To find the corners, it reads how sharply the road bends. So we do not keep a hand-written list of where corners begin and end.
The simulator measures distance in its own world units, and the samples are about one unit apart. Blue Hours, one of the circuits, has 211 points and 1,809 samples. The code builds them in buildTrack.
A car slides when it steers harder than its tires can grip
A car can point one way and move another. The simulator keeps the heading, the direction the car points, apart from the velocity, the direction and speed it moves. When a driver steers harder than the tires can grip, the car is left moving partly sideways. That slide costs speed and carries the car wide.
A car’s controls are four values: throttle, brake, steer and an optional boost. In each step, the simulator turns the heading first. It then splits the velocity into a forward part and a sideways part, and applies drive, braking, resistance and grip. Grip removes a limited amount of sideways speed per step. The sideways speed that is left is the slide. The code calls this step stepCar.
The surface under the tires sets the grip. The simulator checks it under each of the four tires and averages the results. So two tires off the asphalt can affect the car before its center leaves the road. Fully on loose ground, grip is 0.45 of its value on asphalt. Boost adds forward drive and does not add sideways grip.
We do not cap the speed. Drive is balanced against drag, and drag grows with speed. Slipstream is the lower drag a car gets when it follows another. On normal asphalt, with no slide and no slipstream, full throttle balances resistance at 100 world units per second. The screen shows that as 200 km/h.
One tick moves the cars, then checks laps and contact
A tick is one step of the race. While the cars are racing, a tick first moves every car and checks its progress around the lap. Then it separates cars that touch and updates the standings. It reports what happened as events, including laps, contacts and finishes.
Each tick moves the cars through 1/60 s of motion, so a race has 60 ticks per simulated second. The code calls the step stepRace. A fixed step does not mean that a race keeps up with real time. A hosted race, for example, waits for a decision from every active driver before it moves the simulation forward.
Position on the circuit is not enough to count a lap. A shortcut can move a car’s position far around the circuit when the car never drove the road in between. So each lap has 12 checkpoints, which the code calls gates, and a car must pass them in order. A gate checks the route. It is not a visible obstacle.
Cars touch with their real outline, a shape with 14 vertices. In a contact, each moving car loses some extra speed: 5% for the car behind, 1% for the car in front, and 3% each when the two are level.
The same inputs give the same race
The host checks a submission by repeating one of its test runs and requiring the same result. The simulator therefore has to give the same race whenever it gets the same inputs. So it fixes three things itself and does not leave them to the JavaScript runtime it runs on: the code behind its math functions, its formulas, and the way it sorts the standings.
Math functions such as sine and square root come from one fixed WebAssembly module, embedded in the simulator. If that module cannot be compiled, the simulator fails. It does not fall back to the runtime’s built-in math, because a fallback would switch to another implementation without saying so.
Formulas stay exactly as written, because a rewrite that is mathematically equivalent can round differently. The standings are sorted with one fixed sequence of comparisons, because a sort that compares in a different sequence can produce a different ranking.
Tests run the same inputs twice and compare the results. They also reject accidental calls to the runtime’s built-in math, clocks and randomness. None of this proves that different browsers give results that are equal bit for bit.