Dragon Racing · track 1 of 3 · 2504 units round

The Ember Ring

A broad loop with one chicane: learn to hold a line, and when to back-beat.

  • Bronze35.65s
  • Silver32.95s
  • Gold29.70s
  • Xher's time27.20s
0.00 Choose ghosts to race, then fly.
Ghosts to race

    Log in to fly. Anyone may race the ghosts here as they flew.

    The spellbook

    Your spell is one function, steer(sensors), called twenty times a second of flight. It answers {"turn": t, "thrust": p} (or [t, p]): turn from -1 (hard left) to 1 (hard right), thrust from -1 (back-beat, to brake) to 1 (full wings). Anything else, or an error, and the dragon glides for that twentieth. It must be quick: a twentieth of a second a call, twelve seconds a lap in all. Variables you keep outside steer last the whole lap.

    The sensors

    • speed: units a second. forward and slip: the speed along your heading and across it (+ is drifting right). turn_rate: the fastest your heading can swing just now, in radians a second.
    • ahead: seven points along the middle of the track, 40, 80, 120, 160, 200, 260 and 320 units on, each {"ahead": a, "right": r, "direction": d}: where it lies from you (a ahead, r to your right) and which way the track runs there, in radians from your heading (+ is to the right).
    • rays: how far the track reaches from you at the angles in ray_angles (-90 to 90 degrees from your heading, + to the right), up to 400 units; 0 if you are off it.
    • offset: how far you are from the middle of the track (+ is right of it), and half_width: how far the edges are from the middle. track_angle: which way the track runs here, from your heading. on_track: whether you are on it.
    • x, y (y grows downward) and heading (radians: 0 is east, and it grows clockwise); progress round the lap from 0 to 1; time in seconds; step.

    The rules of flight

    • Each twentieth: the heading turns by turn × 2.4 radians a second, but never faster than 90 / speed; wings push along the heading at thrust × 60 units a second a second (a back-beat slows the dragon at -thrust × 90); the sideways part of the speed fades by 1.8 a second (on the track; 1.2 off it); everything fades by drag, 0.5 a second (3.7 off the track).
    • So the top speed is 120, and a bend of radius r has a top speed of about the square root of 90 × r: 63 for a hairpin of 45, 95 for a bend of 100. Braking from 120 to 60 at full back-beat takes about 60 units.

    Ideas

    • Work out from ahead how sharply the track bends, how fast you may take each bend, and when you must start braking for it.
    • The shortest way round a bend is not the middle of the track: come in wide, touch the inside, go out wide.
    • Keep a little of what you saw in variables outside steer: the lap is one long flight.
    • Drift costs speed. A smooth turn early beats a hard one late.