←
Build the decisionSaved automatically
Tutorial · Grade 126. First Sweep

Sweep Sector 7, find the missing vehicle, and report it.

Scenario

The drone knows the boundaries of the search area, but not where the vehicle is.

Problem statement

A vehicle has gone missing somewhere in Sector 7, a 6×6 kilometre block of open ground.

You are writing the drone's autonomy. Nobody is flying it — once it lifts off the pad, every decision is yours. It does not know where the vehicle is. All it has is a downward sensor that covers the ring of cells around it, a memory of everywhere that sensor has already looked, and enough battery for a patient search.

Your job is to turn that hardware into behaviour: sweep the sector until the sensor picks the vehicle up, close in on it, and radio the find in.

A complete working policy is already loaded, so you can press Apply & Run and watch the whole mission play out before changing anything.

The drone's senses do the bookkeeping. Its sensor covers every neighbouring cell each tick and remembers what it has seen, so it always knows which way the nearest unsearched ground lies — that is what fly toward unsearched ground follows. The moment the vehicle falls under the sensor, targetDetected flips on and fly toward the vehicle becomes available.

That makes the whole policy three rules, and their order is the entire answer. Report sits first, so the drone radios in the instant it is overhead. Closing in sits above searching, so a found vehicle always wins. Searching is the fallback that runs when neither of the others applies.

Read it, run it, then take it apart: drag the search rule above the close-in rule and watch the drone map the whole sector and never radio in.

What this teaches

Write an agent that switches between two modes — searching unknown ground, then homing in on a target once it is detected.

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
WHEN
DO
⋮⋮2
Folder
WHEN
DO
⋮⋮3
Folder
WHEN
DO