Lava Trail Backtracker
A lava wall blocks the island trail! Teach the explorer to remember every choice, undo a dead end, and try a new path.
π§ Before we start
At the Koi Garden, your program remembered its current state. Now it will remember a whole trail of choices. When a path fails, it undoes the newest choice and tries another. Programmers call this backtracking.
Arrange the trail recipe
Tap four visual instruction blocks in the order a backtracking program uses them.
Escape the lava maze
Try the ash trail first. It ends at lava, so undo each newest trail mark. Then try the palm trail.
Unwind the memory pile
The newest choice sits on top. Tap the trail cards from newest to oldest, just like a backtracking program.
Debug the stuck explorer
This routine sees a dead end but keeps the bad choice in memory. Tap the pulsing bug, then add the missing action.
π What you learned
- Backtracking tries one choice at a time.
- The program remembers every choice in its current trail.
- A dead end means the newest choice must be undone.
- After going back, the program can try a different choice.
- This idea helps programs solve mazes, puzzles, and matching games.