游戏与仿真
该项目使用 TypeSafe AI 的 Jev 自动驾驶无人机,在随机城市中从点 A 飞到点 B,途中避开障碍物,单次飞行费用为 0.01 美元。
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.
$('jev').hidden = mode !== 'auto';链接指向我们抓取当天的那个 commit,行号是准的。
下面是从这个项目源码里原样取出来的 question 组合。
throttle选项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_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选项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_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选项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_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选项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_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是/否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是/否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.
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.' },
},
});