import { type CircuitPlan } from "./circuits.ts"; import { type PaceProfile } from "./circuits.pace.ts"; import { type RaceDriver, type RaceTeam } from "./circuits.race.field.ts"; import type { Circuit } from "./circuits.types.ts"; /** What a race is made from: the circuit, and a seed, laps and cars of your own. */ export interface RaceOptions { /** The circuit's key: `las-vegas`. */ circuit: string; /** The seed every choice of the race is drawn from: a whole number, 1 by default. Another seed is another race. */ seed?: number; /** How many laps: by default a full race distance, the fewest laps that make 305 km (`raceLaps`). 1 to 200. */ laps?: number; /** How many cars: 2 to 20, 20 by default. */ cars?: number; } /** A car of the race: its driver and team (made up) and where it started. */ export interface RaceCar { /** The driver's code in lower case: `hlv`. */ id: string; driver: RaceDriver; team: RaceTeam; /** Its place on the grid, 1 for pole. */ grid: number; } /** A pit stop: the lap it ends, the time the car left the track and joined it again, and how long it stood still. */ export interface RaceStop { lap: number; in: number; out: number; stop: number; } /** A race worked out: the cars, and each one's distance at every second, its laps, stops and finish. */ export interface CircuitRace { circuit: Circuit; plan: CircuitPlan; seed: number; laps: number; cars: readonly RaceCar[]; /** The lap's length along the drawn line, in metres, and how far round it from the line's first point the timing line (the finish) is. */ lapLength: number; lineAlong: number; /** The pit lane: where it leaves the lap and joins it again (metres round the lap from the line's first point), and its length in metres. */ pitLane: { entry: number; exit: number; length: number; }; /** The lap's speeds the cars run. */ pace: PaceProfile; /** Seconds between two samples, the time the chequered flag fell and the time the race ends (every car home and slowed). */ sample: number; flag: number; duration: number; /** Each car's race distance at every sample, in metres: 0 at the timing line, a lap is done at each `lapLength`. A car on the grid behind the line starts below 0. */ distance: readonly Float64Array[]; /** Each car's distance along the pit lane at every sample, in metres, or NaN while it is on the track. */ pit: readonly Float32Array[]; /** The time each car completed each lap, from the start. */ crossings: readonly (readonly number[])[]; stops: readonly (readonly RaceStop[])[]; /** The time a car took the chequered flag, or retired: `undefined` for neither. */ finish: readonly (number | undefined)[]; out: readonly (number | undefined)[]; } /** The distance of a race: the fewest laps that make more than 305 km, as a Grand Prix's is set. */ export declare const RACE_DISTANCE = 305000; /** The laps of a full race distance on a circuit: 50 at Las Vegas. */ export declare const raceLaps: (circuit: Pick) => number; /** * A race on a circuit, worked out from a seed: made-up cars from the grid to the flag over a full race distance (50 laps of Las Vegas, about an hour and a half), with the gaps, overtakes, pit stops and retirements * the model gives. The same options always give the same race; the last few asked for are kept. * @example * ```ts * import { simulateRace } from "@johnmorrisdotca/kyogijo-stadiums/circuits"; * const race = simulateRace({ circuit: "las-vegas", laps: 5, cars: 6, seed: 7 }); * console.log(race.laps, race.cars.length, race.flag > 5 * 90 && race.flag < 5 * 110); * // 5 6 true * ``` */ export declare function simulateRace(options: RaceOptions): CircuitRace;