Lesson 11: Escape the cave
Lost in the cave
- The robot is deep in a cave. It cannot see the whole cave, only the wall in front of it.
- There is a green exit somewhere. The tunnels are different on every map, so a fixed route never works.
- The robot has to look, then decide, one square at a time. Each square is 250 mm.
Words for this lesson
| Word | Meaning |
|---|---|
| tunnel | a long, narrow way through rock |
| maze | tunnels that split, with dead ends |
| dead end | a tunnel that is closed at the end |
| open / closed | there is room ahead / a wall is close in front |
| rule | a short plan the robot follows again and again |
Is the way open?
from vexcode_vr import *
def main():
for i in range(4):
if front_distance.get_distance(MM) > 200:
brain.print("open")
else:
brain.print("closed")
brain.new_line()
drivetrain.turn_for(RIGHT, 90, DEGREES)
vr_thread(main)
- The robot looks in all four directions. In a square of the cave, a wall in front is only about 35 mm away.
- When the next square is free, the distance is more than 280 mm. So 200 mm is a good line between open and closed.
The right-hand rule
- Put your right hand on the wall of a maze and never take it off. Walk, and you will reach the exit.
- For the robot this is three steps in every square:
- Turn right.
- While the way ahead is closed, turn left.
- Drive one square.
- It is not the shortest way. But it never goes round in a circle, and it comes back out of every dead end.
In the exam
Past paper 0478/12/F/M/23 Q6(d): a robot must find its way through puzzles with dead ends, using artificial intelligence (AI). (i) Characteristics of AI (mark scheme): it collects data, stores rules, can reason, and can learn: it changes its own rules or data from mistakes. (ii) How it uses AI: it stores where it has been and which routes worked or failed, so it does not repeat a wrong route next time.
- Your right-hand rule is not AI: it follows one fixed rule and makes the same choices every time. An AI robot would remember the dead ends and get faster with each puzzle.
Dificultad 3/5 · 200 monedas + un pequeño bono en el primer intento de hoy
The robot is in a dark tunnel. Drive to the green exit. The tunnel bends, and it is different on each map. In a loop: if the way ahead is open (more than 200 mm), drive one square (250 mm). If not, turn right and look again. If that way is closed too, turn left 180°.
Haz clic en Ejecutar para ver la salida aquí.
Dificultad 4/5 · 280 monedas + un pequeño bono en el primer intento de hoy
Now the tunnels split, and some end in a dead end. The tunnel program can go round in circles here. Use the right-hand rule: in every square, first turn right. While the way ahead is closed, turn left. Then drive one square. Stop on the green exit.
Haz clic en Ejecutar para ver la salida aquí.