Questions & AnswersPython Programming

#A dictionary for the simplified dragon text game #The dictionary...

Question
Answered step-by-step
Asked by ChancellorFlower6377 on coursehero.com

#A dictionary for the simplified dragon text game #The dictionary...

#A dictionary for the simplified dragon text game
#The dictionary links a room to other rooms.
rooms = {
'Great Hall': {'South': 'Bedroom'},
'Bedroom': {'North': 'Great Hall', 'East': 'Cellar'},
'Cellar': {'West': 'Bedroom'},
'Exit': {'Exit': 'Exit'}
}

def main_menu():
print('\nWelcome to the Moving Around the Rooms game')
print('move Commands: North, South, West, East, Exit.')
print(' _ _ _ _ _ _ _ _ ')

def move_between_rooms(current_room,move,rooms):
current_room = rooms[current_room][move]
return current_room

def main():
s = ' '
inventory = []
current_room = 'Great Hall'
main_menu()

while current_room != 'exit':
print('You are in the %s.' % current_room)
print(' _ _ _ _ _ _ _ _ _ ')
available_moves = rooms[current_room]
print('You can move to:')

for move in available_moves:
print('%s --> %s' % (move, available_moves[move]))
print('_ _ _ _ _ _ _ _ _ _ _ _ ')

move_command = input('Enter your move or exit the game. -> ')
print('_ _ _ _ _ _ _ _ _ _ _ _ _ ')
if move_command.lower() =='exit':
current_room = 'Exit'
print('Thank You for playing! Come back again :)')

elif move_command.capitalize() in available_moves.keys():
current_room = available_moves[move_command]
print('You moved to the %s.' % current_room)
print(' _ _ _ _ _ _ _ _ ')

else:
print('Error. Try again!')
print(' _ _ _ _ _ _ _ _ _ _ _ ')

main()
my output

Welcome to the Moving Around the Rooms game
move Commands:  North,  South,  West,  East, Exit.
_ _ _ _ _ _ _ _ 
You are in the Great Hall.
_ _ _ _ _ _ _ _ _ 
You can move to:
South --> Bedroom
_ _ _ _ _ _ _ _ _ _ _ _  
Enter your move or exit the game. -> Exit
_ _ _ _ _ _ _ _ _ _ _ _ _ 
You are in the Great Hall.
_ _ _ _ _ _ _ _ _ 
You can move to:
South --> Bedroom
_ _ _ _ _ _ _ _ _ _ _ _  
 

it will tell me to enter my move or exit but it keeps me in the same room Great Hall. 

what we are suppose to do is just move around the rooms and exit. showing invalid directions.

Answer & Explanation

Solved by verified expert
Answered by GeneralRiver8709 on coursehero.com


 

sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem

sectetur adipiscing elit. Nam
CliffsNotes Logo

Unlock access to this and over
10,000 step-by-step explanations

Unlock Explanation

Have an account? Log In

<p style="margin-left:0px;">sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus</p><p style="margin-left:0px;">sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, cong</p><pre><code class="language-plaintext">sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque</code></pre><p style="margin-left:0px;">sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac mag</p><p style="margin-left:0px;">sectetur adipiscing elit.</p><pre><code class="language-plaintext">sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, cong</code></pre><p>sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Do</p><pre><code class="language-plaintext">sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus e</code></pre>

Step-by-step explanation

sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis.

sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem

Get unstuck with a CliffsNotes subscription

Example CliffsNotes Question and Answer
Unlock every step-by-step explanation, download literature note PDFs, plus more.Get Access

Related Q&A