Write your first Collector loop in Harsh
In Savebot: The Last Garden, use the game’s Harsh syntax and start with a three-way decision. In the official example the Collector recharges when battery is low, recycles when full, and collects in the remaining case. Keep those decisions inside the repeating loop.
Full Steam release unless a source specifies the demo. Evidence checked . Guide updated .
Enter the developer’s Harsh example
Choose a Collector and open its Workshop in Harsh. Enter this example in Savebot’s editor. It uses the game’s own actions and tests. The developer’s Steam description shows the program. If your interface suggests a different spelling, use the Workshop’s insert control to see the names available to the selected robot.
while True:
if battery_low():
recharge()
elif full():
recycle()
else:
collect()Line up if, elif and else under while True:. Indent each action one level deeper than its test. Each turn through the loop chooses one action. The game checks cargo only after the battery test is false, so a full Collector with low power still goes to recharge first.
Test all three paths on the same Collector
| Situation | Line to watch | What to verify |
|---|---|---|
| Enough battery, space left in cargo | collect() | The Collector makes a pickup. |
| Enough battery, cargo full | recycle() | The load is delivered for recycling. |
| Low battery, with or without a full load | recharge() | The recharge branch takes priority. |
- Start with room to collect. Watch the highlighted line as the robot reaches a usable pickup. A moving robot gives you less information than seeing the active instruction and a change in cargo on that same Collector.
- Look for recycling while there is still enough charge. If the battery becomes low before you see a full load, take the recharge as its own test. Then watch a separate full-cargo case with enough power. With both tests true, this program deliberately chooses recharge.
- Follow the next turn after a delivery. Once the cargo has space again and power is adequate, the loop should return to collecting. This catches a misplaced action that runs once and never returns to the decision.
Use a breakpoint if the line changes before you can read it. Put it on the cargo decision to check what the Collector sees there. When the battery test selects recharge, a stop on the cargo decision will be skipped. Put the breakpoint on the earlier battery decision if you need to see why the program never reaches cargo.
The loop works when you can predict the active line in each of the three situations and the Collector resumes collection after its state allows it.
Fix the first mismatch you can see
- A line appears in red before the robot runs
- Read the line number and the closest command suggested by the editor. If the rejected word is the recycling action, compare it with
recycle()above and use the red-line check before rearranging the branches. - The Collector runs both recycle and collect on the same turn
- Check whether
collect()is indented underelse:. If it lines up withelse:, the action can sit after the decision but still inside the loop. Test the full-load case again after fixing its placement. - The recycle line runs but the robot keeps its load
- Watch where the Collector goes and whether it finishes the delivery. The active line establishes that this branch was selected. Follow the cargo and delivery checks to identify where the load stopped moving. The example supplies no universal battery percentage to use in place of
battery_low().