Katkat

Autopilot a Thruster Drone Through Randomized Canyon Walls

AqrData Scientist · Online Assessment

Last updated

Write a per-tick controller that fires a drone's thruster so it clears wall openings on unseen, randomized canyons. Tests modeling deterministic physics, depth-limited lookahead search, and choosing a horizon that generalizes.

A survey drone flies through a canyon from left to right at a fixed horizontal speed. Gravity pulls it down every tick, and its only control is a single thruster: firing it sets the vertical velocity to a fixed upward value (it does not add to it). The canyon contains a series of rock walls, each with one rectangular opening the drone must pass through. Hitting a wall, the canyon floor, or the canyon roof ends the flight.

Your job is to write the decision function that runs once per tick and returns whether to fire the thruster. It will be scored on many randomly generated canyons you never see: openings differ in height and in vertical position from wall to wall, and consecutive openings may be far apart vertically. Hard-coded timings or thresholds tuned to one canyon will fail.

Rules (known to your code)

each tick:
    vy = LIFT                         if thrust
    vy = max(vy - GRAVITY, MAX_FALL)  otherwise
    y  = y + vy
    x  = x + SPEED

GRAVITY = 0.6   LIFT = 4.5   MAX_FALL = -8.0   SPEED = 3.0
drone = disc of RADIUS 3.0;   canyon floor y = 0, roof y = 120
crash if: y - RADIUS <= 0, y + RADIUS >= 120, or the disc's x-range
          overlaps a wall [x0, x1] while y - RADIUS < low or y + RADIUS > high

Interface

@dataclass(frozen=True)
class Wall:
    x0: float; x1: float      # left and right faces
    low: float; high: float   # vertical extent of the opening

@dataclass(frozen=True)
class Drone:
    x: float; y: float; vy: float

class Autopilot:
    def decide(self, drone: Drone, walls: list[Wall]) -> bool: ...

walls is sorted by x0 and includes every wall still ahead of the drone.

Example

start: Drone(x=0, y=60, vy=0)
walls: Wall(60, 75, low=80, high=110)    # high opening
       Wall(120, 135, low=10, high=40)   # immediately followed by a low one
       Wall(180, 195, low=85, high=113)  # and a high one again
expected: the drone clears all three walls (about 69 ticks)

Constraints

  • Each decision should take well under 10 ms.
  • Openings are at least 26 units tall; walls are 18 units thick and 60 to 90 units apart.
  • Your controller must be deterministic.

Deliver the controller plus a small harness that generates random canyons and reports how many it clears.

Hints

Hint 1

The physics is deterministic and fully known. Instead of a threshold rule, can you simulate what each choice leads to?

Hint 2

Search both actions a fixed number of ticks ahead. Memoize on (ticks left, rounded y, vy) to avoid exponential blowup.

Hint 3

Try coasting first and stop searching once any path survives the whole horizon.

Hint 4

Make sure the horizon spans the next two walls. Test on a high opening followed closely by a low one.

Follow-up questions

  • How would you adapt the controller if the thrust strength had random noise each tick?
  • If decisions had a hard 1 ms budget, how would you trade horizon length against state resolution?
  • How would you build a test generator that produces the hardest feasible canyons?
  • Could you precompute a policy table offline instead of searching online? What does it depend on?