Games & simulation

jev-autopilot

@arielweinberger4TypeScriptupdated 2026-09-17runnable

This demo uses Jev from TypeSafe AI to autonomously fly a drone in a random city from point A to point B, avoiding obstacles along the way. A trip costs $0.01.

arielweinberger/jev-autopilot

Where it calls Jev

$('jev').hidden = mode !== 'auto';

src/hud.ts:37

The link points at the commit we read, so the line number still holds.

What it asks Jev

These question sets are lifted from this project's source exactly as written.

from server/pilot.ts:143

  1. throttlechoice

    Which left-stick vertical input should the pilot apply right now to manage altitude? Consider `altitude`, `verticalMotion`, `obstacles` and `position`. Take off by climbing. Cruise at cruise altitude and never below the tallest building on the path. Only descend when over the pad. When over the pad, descend gently; descend faster when high, slower when close to the ground. On the ground after landing, hold.

    • climb_fastPush the left stick fully up. For takeoff, for climbing over a building, or when far below cruise altitude.
    • climbPush the left stick halfway up. For a gentle climb when a bit below cruise altitude.
    • hold_altitudeCenter the left stick. Keep the current altitude: at cruise altitude while flying to the pad, or when already on the ground.
    • descendPull the left stick down a little. A gentle descent for landing when over the pad and within a few meters of the ground, or to correct being slightly above cruise altitude.
    • descend_fastPull the left stick well down. A brisk descent when over the pad and still high up, or when far above cruise altitude and not over buildings.
  2. yawchoice

    Which left-stick horizontal input should the pilot apply to point the nose at the landing pad? Use `heading` and `bearingToPadDegrees`. A positive bearing means the pad is to the right. When the pad is straight ahead, or the drone is over the pad, hold heading. Use hard turns only for large bearings.

    • turn_left_hardFull left. The pad is far to the left or behind.
    • turn_leftSmall left input. The pad is slightly or clearly to the left.
    • hold_headingCenter. The pad is straight ahead, or the drone is over the pad and landing.
    • turn_rightSmall right input. The pad is slightly or clearly to the right.
    • turn_right_hardFull right. The pad is far to the right or behind.
  3. pitchchoice

    Which right-stick vertical input should the pilot apply to cover the distance to the pad? Use `position`, `heading`, `horizontalMotion`, `obstacles` and `altitude`. Do not fly forward while on the ground or barely off the ground, or while the nose points well away from the pad, or while a building is ahead and the drone is not above it. Slow down when close to the pad. When over the pad, use small inputs to stay centered, using `padOffset`.

    • full_forwardPush the right stick fully forward. The pad is far away and straight ahead, the path is clear, and the drone is at cruise altitude.
    • forwardPush the right stick forward a little. The pad is a medium or close distance ahead, or the drone is over the pad but the pad center is ahead of the nose.
    • neutralCenter the right stick. Hovering over the pad center, climbing on takeoff, turning the nose toward the pad, or on the ground.
    • pull_backPull the right stick back a little. The drone is close to the pad and moving forward too fast, or the pad center is slightly behind the nose.
    • brake_hardPull the right stick fully back. The drone is moving fast and about to overshoot the pad, or a building is directly ahead and collision is imminent.
  4. rollchoice

    Which right-stick horizontal input should the pilot apply to correct sideways position? Use `padOffset` and `horizontalMotion`. Only use this when close to or over the pad; otherwise stay neutral and let yaw and pitch do the work. Counter sideways drift.

    • slide_leftRight stick left. The pad center is to the left of the nose while close, or the drone is drifting right.
    • neutralCenter. No sideways correction needed, or the drone is far from the pad.
    • slide_rightRight stick right. The pad center is to the right of the nose while close, or the drone is drifting left.
  5. commitToLandingtrue/false

    Should the pilot commit to landing now? True only when the drone is over the landing pad, moving slowly with no large sideways drift, and pointing roughly toward the pad center. See `position`, `horizontalMotion`, `padOffset`.

  6. cutMotorstrue/false

    Has the drone touched down on the landing pad so the motors should be stopped? True only when `altitude` says it is on the ground AND `position` says it is over the landing pad.

Run it on your own text

The code
import { experimental_evaluate as evaluate } from 'ai';

const { answers } = await evaluate({
  model: 'typesafe-ai/jev',
  state,
  questions: {
    throttle: { type: 'choice', instructions: 'Which left-stick vertical input should the pilot apply right now to manage altitude? Consider `altitude`, `verticalMotion`, `obstacles` and `position`. Take off by climbing. Cruise at cruise altitude and never below the tallest building on the path. Only descend when over the pad. When over the pad, descend gently; descend faster when high, slower when close to the ground. On the ground after landing, hold.',
      criteria: { climb_fast: 'Push the left stick fully up. For takeoff, for climbing over a building, or when far below cruise altitude.', climb: 'Push the left stick halfway up. For a gentle climb when a bit below cruise altitude.', hold_altitude: 'Center the left stick. Keep the current altitude: at cruise altitude while flying to the pad, or when already on the ground.', descend: 'Pull the left stick down a little. A gentle descent for landing when over the pad and within a few meters of the ground, or to correct being slightly above cruise altitude.', descend_fast: 'Pull the left stick well down. A brisk descent when over the pad and still high up, or when far above cruise altitude and not over buildings.' } },
    yaw: { type: 'choice', instructions: 'Which left-stick horizontal input should the pilot apply to point the nose at the landing pad? Use `heading` and `bearingToPadDegrees`. A positive bearing means the pad is to the right. When the pad is straight ahead, or the drone is over the pad, hold heading. Use hard turns only for large bearings.',
      criteria: { turn_left_hard: 'Full left. The pad is far to the left or behind.', turn_left: 'Small left input. The pad is slightly or clearly to the left.', hold_heading: 'Center. The pad is straight ahead, or the drone is over the pad and landing.', turn_right: 'Small right input. The pad is slightly or clearly to the right.', turn_right_hard: 'Full right. The pad is far to the right or behind.' } },
    pitch: { type: 'choice', instructions: 'Which right-stick vertical input should the pilot apply to cover the distance to the pad? Use `position`, `heading`, `horizontalMotion`, `obstacles` and `altitude`. Do not fly forward while on the ground or barely off the ground, or while the nose points well away from the pad, or while a building is ahead and the drone is not above it. Slow down when close to the pad. When over the pad, use small inputs to stay centered, using `padOffset`.',
      criteria: { full_forward: 'Push the right stick fully forward. The pad is far away and straight ahead, the path is clear, and the drone is at cruise altitude.', forward: 'Push the right stick forward a little. The pad is a medium or close distance ahead, or the drone is over the pad but the pad center is ahead of the nose.', neutral: 'Center the right stick. Hovering over the pad center, climbing on takeoff, turning the nose toward the pad, or on the ground.', pull_back: 'Pull the right stick back a little. The drone is close to the pad and moving forward too fast, or the pad center is slightly behind the nose.', brake_hard: 'Pull the right stick fully back. The drone is moving fast and about to overshoot the pad, or a building is directly ahead and collision is imminent.' } },
    roll: { type: 'choice', instructions: 'Which right-stick horizontal input should the pilot apply to correct sideways position? Use `padOffset` and `horizontalMotion`. Only use this when close to or over the pad; otherwise stay neutral and let yaw and pitch do the work. Counter sideways drift.',
      criteria: { slide_left: 'Right stick left. The pad center is to the left of the nose while close, or the drone is drifting right.', neutral: 'Center. No sideways correction needed, or the drone is far from the pad.', slide_right: 'Right stick right. The pad center is to the right of the nose while close, or the drone is drifting left.' } },
    commitToLanding: { type: 'boolean', instructions: 'Should the pilot commit to landing now? True only when the drone is over the landing pad, moving slowly with no large sideways drift, and pointing roughly toward the pad center. See `position`, `horizontalMotion`, `padOffset`.' },
    cutMotors: { type: 'boolean', instructions: 'Has the drone touched down on the landing pad so the motors should be stopped? True only when `altitude` says it is on the ground AND `position` says it is over the landing pad.' },
  },
});

Other projects in this category