Log inGet started
World

Torque Valley: Driving, Drift and Crash Sandbox

README.md

aiDrivers

Checks the AI drivers' data, the path maths they plan by and the component's API:

  • Personalities: five built-ins in order, each a complete table. They differ as described: the commuter is slower, brakes earlier, keeps a lane and leaves a bigger gap; the racer uses the full road; the drifter drifts with assists off; the tourist misses turns and stops; the aggressive driver tailgates. extend copies without touching the base, and an unknown base raises.
  • Paths: resample makes even 2 m spacing on an open line (51 points over 100 m) and a splined loop (no repeated start). distances measures loop and open lengths. normals point right of travel and offset slides lanes. curvatures are ±1/R on circles (sign follows direction) and 0 on a line. nearest returns the closest index and squared distance. speedProfile respects the cornering limit √(latG·g/|k|), maxSpeed and the braking constraint, and ends an open route nearly stopped. racingLine stays within ±halfWidth, uses the width and lowers Σk² and peak curvature on the test track.
  • Track: 36 control points, a ~1.2 km closed centreline, an origin shift and alternating grid slots.
  • AiDriver: on a script-controlled torqueCars hatchback (skipped without torqueCars): setPersonality switches the driver and refuses unknown names, setPath / clearPath take a route, laps() starts empty, stats().rate follows the personality and state() gives the full read-out.

It leaves alone actual driving (steering, pedals, overtaking, drifting, recovery, lap timing), which needs physics running in play, as well as the showcase scene and define(). define() registers a personality for the rest of the session, which a repeatable suite must not do. The test car is spawned far below the play area and despawned after the test.

Run it in edit mode:

return asset.resolve("aiDrivers", "testSuite"):run()