Lesson 11: Escape the cave
이 페이지는 최신 브라우저(SharedArrayBuffer 지원)가 필요합니다. Chrome, Edge, Firefox 또는 Safari를 최신 버전으로 업데이트해 주세요.
English
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 |
English
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.
English
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.
난이도 3/5 · 200코인 + 오늘 첫 완료 시 작은 보너스 추가
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°.
출력을 보려면 '실행'을 클릭하세요.
난이도 4/5 · 280코인 + 오늘 첫 완료 시 작은 보너스 추가
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.
출력을 보려면 '실행'을 클릭하세요.