-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaze.py
86 lines (74 loc) · 3.03 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
def main():
#welcome user to the program.
print("Welcome to a basic maze. ")
#user begins in room one with one door.
room1()
def room1():
#this is the room1 function
print("You are at the beginning. You are in a room with one door.")
startMaze = input("Do you choose to go through the door? Type yes or type any key to exit. ")
if startMaze.lower() == "yes":
room2()
else:
exit()
def room2():
#start room 2 with while loop in case user doesn't type forward or back
continueMaze2 = ""
while continueMaze2 != "forward" and continueMaze2 != "back":
#this is the room2 function
print("You are in room 2. There is one door in front of you and one behind you.")
continueMaze2 = input("Do you choose to go through the door in front of you? If yes then type forward, or type back to return to room 1. Type exit to escape. ")
if continueMaze2.lower() == "forward":
room3()
elif continueMaze2.lower() == "back":
room1()
elif continueMaze2.lower() == "exit":
exit()
else:
print("I'm sorry I don't understand what you typed. Choose either 'forward', 'back', or 'exit'. ")
def room3():
#start room 3 with while loop in case user doesn't type right or back
continueMaze3 = ""
while continueMaze3 != "right" and continueMaze3 != "back":
#this is the room3 function
print("You are in room 3. There is one door to your right and one behind you.")
continueMaze3 = input("Choose right to go to the next room, or choose back to return to room 3. Type exit to escape. ")
if continueMaze3.lower() == "right":
room4()
elif continueMaze3.lower() == "back":
room2()
elif continueMaze3.lower() == "exit":
exit()
else:
print("I'm sorry I don't understand what you typed. Choose either 'right' or 'back'. ")
def room4():
#start room 4 with while loop in case user doesn't type forward or back
continueMaze4 = ""
while continueMaze4 != "right" and continueMaze4 != "back":
#this is the room4 function
print("You are in room 4. There is one door in front of you and one behind you.")
continueMaze4 = input("Choose right to go to the next room, or choose back to return to room 4. Type exit to escape. ")
if continueMaze4.lower() == "right":
room5()
elif continueMaze4.lower() == "back":
room3()
elif continueMaze4.lower() == "exit":
exit()
else:
print("I'm sorry I don't understand what you typed. Choose either 'right' or 'back'. ")
def room5():
#start room 5 with while loop in case user doesn't type trapdoor or back
continueMaze5 = ""
while continueMaze5 != "trapdoor" and continueMaze5 != "back":
#this is the room5 function
print("You are in room 5. There is a trapdoor in the floor and the door behind you just came through.")
continueMaze5 = input("Type trapdoor to move forward or choose back to return to room 4. Type exit to escape. ")
if continueMaze5.lower() == "trapdoor":
room1()
elif continueMaze5.lower() == "back":
room4()
elif continueMaze5.lower() == "exit":
exit()
else:
print("I'm sorry I don't understand what you typed. Choose either 'trapdoor' or 'back'. ")
main()