I have to make a maze with three different levels that allows you to quit at any time. I've tried inserting my quit()
call everywhere but I can't seem to get it to work. Can someone tell me what I'm doing wrong? Is it something easy I can fix or is my logic just way off? Thanks! :(
def start():
print('Welcome to the Maze!')
choose_level()
def choose_level():
level = input('Select a level: Easy, Average, or Difficult \n')
if level == 'Easy' or 'easy' or 'EASY' or '1':
return easy()
elif level == 'Average' or 'average' or 'AVERAGE' or '2':
return average()
elif level == 'Difficult' or 'difficult' or 'DIFFICULT' or '3':
return difficult()
def easy():
maze1_list = []
# [Description, North, East, South, West]
maze1_list.append(['Available Directions: East', None, 1, None, None]) #0
maze1_list.append(['Available Directions: East, South, West', None, 2, 3, 0]) #1
maze1_list.append(['Available Directions: West', None, None, None, 1]) #2
maze1_list.append(['Available Directions: North, East', 1, 4, None, None]) #3
maze1_list.append(['Available Directions: South, West', None, None, 5, 3]) #4
current_tile = 0
done = False
directions = {'North' or 'north' or 'NORTH':1, 'East' or 'east' or 'EAST':2, 'South' or 'south' or 'SOUTH':3, 'West' or 'west' or 'WEST':4}
#Source: obtained from <https://stackoverflow.com/questions/46511833/how-do-you-make-a-simple-3x3-maze-on-python-using-lists/46517061#46517061>
#Date: <October 2, 2017>
#Name of Author/Programmer: <Anton vBR>
while not done:
print('')
print(maze1_list[current_tile][0])
x = '0'
available = False
while not available:
while not directions.get(x.title()): #Source: obtained from <http://programarcadegames.com/index.php?chapter=lab_adventure>
#Date: <October 2, 2017>
#Name of Author/Programmer: <Paul Vincent Craven>
if x!='0':
print('Please choose an available direction. ')
x = input('Which direction will you take? \n')
next_move = directions.get(x.title()) #Source: obtained from <http://programarcadegames.com/index.php?chapter=lab_adventure>
#Date: <October 2, 2017>
#Name of Author/Programmer: <Paul Vincent Craven>
next_tile = maze1_list[current_tile][next_move]
if next_tile:
available = True
current_tile = next_tile
elif x == 'quit':
quit()
else:
print('Please choose an availble direction.')
x = '0'
if current_tile == 5:
print('Congratulations! You found the exit. \nGoodbye.')
done = True
# i'm going to cut off the average and difficult levels of my code here
since they're the same concept as the easy level