-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path6.day_Escaping_the_maze.py
35 lines (29 loc) · 1.05 KB
/
6.day_Escaping_the_maze.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Final Project
# Lost in a maze
# Reeborg was exploring a dark maze and the battery in its flashlight ran out.
# Write a program using an if/elif/else statement so Reeborg can find the exit. The secret is to have Reeborg follow along the right edge of the maze, turning right if it can, going straight ahead if it can’t turn right, or turning left as a last resort.
# What you need to know
# The functions move() and turn_left().
# Either the test front_is_clear() or wall_in_front(), right_is_clear() or wall_on_right(), and at_goal().
# How to use a while loop and if/elif/else statements.
# It might be useful to know how to use the negation of a test (not in Python).
def turn_right():
turn_left()
turn_left()
turn_left()
def jump():
turn_right()
while front_is_clear():
move()
while wall_on_right():
move()
while right_is_clear():
turn_right()
move()
else:
turn_left()
while not at_goal():
if wall_in_front():
jump()
else:
move()