←
Build the decisionSaved automatically
Hard · Grade 2027. Recovery Run

Run the mission loop until every crate is home and the drone has landed — then tune it for speed and a landing reserve.

Scenario

Eight crates of known weight and value, a carry limit of 9, a battery that drains faster the more the drone is holding, and a depot that can refuel it.

Problem statement

Eight crates are scattered across a 6×9 sector after a supply drop went wrong. Your drone has to bring them all home to the depot in the corner — but it cannot take everything in one trip, and every unit of weight it carries burns extra battery on every move.

The manifest is known before takeoff:

CrateCell (col,row)WeightValue
A5,046
B2,235
C5,369
D1,422
E4,557
F2,636
G5,844
H0,723

Total weight 29, total value 42. The drone carries 9 at a time and starts with 140 battery. The depot refuels it, so there is no excuse for leaving cargo behind: the mission ends when every crate is home and the drone is on the pad. Value decides which crates ride together on a trip, not which ones get abandoned.

This is the drone-autonomy problem in miniature: a real stack does not decide crate by crate. It selects a load on the ground, plans a route through it, flies the route, comes home when the battery says so, and then does it all again for what is left. That loop is already wired for you and it already clears the sector — your job is to make it fly well.

This level gives you the two solvers as actions you must call yourself. run-knapsack picks the best-value set of remaining crates that fits the carry limit and writes it to the plan. plan-route orders that plan into the shortest tour through the chosen crates and back to the depot. Neither moves the drone, and both cost a tick.

Nothing runs them for you. fly-to-plan-target refuses to fire unless a plan exists and has been routed, so the pipeline order is yours to get right — and a plan that has been collected is stale until you clear it and select again.

The scaffold is a complete working mission. Press Apply & Run and it brings all eight crates home in 144 ticks with 95 battery left. That is the bar, not the ceiling: it takes the reserve bonus and misses the speed one.

The two bonuses pull against each other, which is the whole exercise. grab-it fires on atPlanTarget && canPickHere, so the drone ignores crates it flies over and comes back for them on a later trip — safe, and slow. Loosening it to canPickHere alone pockets them as it passes and cuts about fifteen ticks, but it costs a planned stop the capacity it needed, so the loop has to replan around the mess. That extra scrambling burns battery, which puts the reserve bonus at risk unless you also raise the charge threshold in top-up and keep-charging. Get both right and you take both bonuses; drop the threshold too low and the drone dies in the field.

What this teaches

Assemble an autonomous mission pipeline from planning primitives: invoke a selection step, invoke a routing step, execute the resulting plan, and close the loop with recharging and replanning — deciding in your policy when each stage runs.

Scroll down to build and test your solution.

Active controller

Apply & Run executes only the selected controller.

How a rule works

A rule has two parts:

WHEN <something is true> → DO <this action>

  • WHEN is a question about what is happening right now. For example: "Is it raining?" or "Is there a wall ahead?"
  • DO is what happens when the answer is yes.
  • The simulation runs one step at a time.
  • On each step, the rules are checked from top to bottom.
  • The first rule that is true wins. The rules below it are skipped for that step.
  • To change which rule wins, move it up or down the list.
  • If no rule is true, nothing happens on that step.
  • Some actions have more than one step, like "turn right, then move". You build these in the Functions tab.
  • Once a multi-step action starts, it finishes all its steps before the rules are checked again. It only stops early if the next step is not safe.
See an example

Two rules for deciding about an umbrella:

1  WHEN isRaining  → take an umbrella
2  WHEN always     → leave the umbrella at home
  • It is raining. Rule 1 is true, so you take an umbrella. Rule 2 is skipped.
  • It is sunny. Rule 1 is false, so rule 2 is checked next. Rule 2 is always true, so you leave the umbrella at home.
  • Order matters. If rule 2 were on top, it would be true every day, and you would never take an umbrella.

Rule folders

Categorise cards without changing their global execution order.

⋮⋮1
Folder
In state
WHEN
DO
Then switch to
⋮⋮2
Folder
In state
WHEN
DO
Then switch to
⋮⋮3
Folder
In state
WHEN
DO
Then switch to
⋮⋮4
Folder
In state
WHEN
DO
Then switch to
⋮⋮5
Folder
In state
WHEN
DO
Then switch to
⋮⋮6
Folder
In state
WHEN
DO
Then switch to
⋮⋮7
Folder
In state
WHEN
DO
Then switch to
⋮⋮8
Folder
In state
WHEN
DO
Then switch to
⋮⋮9
Folder
In state
WHEN
DO
Then switch to
⋮⋮10
Folder
In state
WHEN
DO
Then switch to
⋮⋮11
Folder
In state
WHEN
DO
Then switch to
⋮⋮12
Folder
In state
WHEN
DO
Then switch to
⋮⋮13
Folder
In state
WHEN
DO
Then switch to