I can't figure out what is wrong with my code it won't output directions, prompts for direction or get items and I need an exit as well but nothing is working can you please help me find a solution. def show_instructions(): # print main menu and how to move print('Escape to Another Galaxy Text Game') print('Collect 6 items to escape and win the game, or be annihilated by the evil alien Goobert') print('Move Command:go south, go north, go east, go west, Exit') print('get Alien Blaster. get Spare Parts. get fuel.') print('get space snacks. get map.') def show_status(current_room, inventory, room, rooms): print('---------------------') # make another line after each move print('You are in the' + current_room) # print players current location print('inventory:' + str(inventory)) # print player current inventory if "Item" in rooms[current_room]: # print an item if there is one print("I can get the" + rooms[current_room]["Item"]) def main(): Inventory = [] # define inventory empty # a dictionary linking rooms together rooms = { 'Central Station': {'south': 'Parts and Service', 'north': 'Navigation Room', 'east': 'Cafeteria', 'west': 'Milky Way'}, 'Parts and Service': {'north': 'Central Station', 'east': 'Experiment', 'Item': 'Alien Blaster'}, 'Experiment': {'west': 'Parts and Service', 'Item': 'Spare Parts'}, 'Navigation Room': {'south': 'Central Station', 'east': 'Control Room', 'Item': 'Goobert'}, 'Control Room': {'west': 'Navigation', 'Item': 'Fuel'}, 'Cafeteria': {'west': 'Central Station', 'north': 'Orbit Room', 'Item': 'Net'}, 'Orbit Room': {'south': 'Cafeteria', 'Item': 'Space Snacks'}, 'Milky Way': {'east': 'Central Station', 'Item': 'Map'} } current_room = "Central Station" show_instructions() while True: show_status(current_room, Inventory, rooms) if "Item" in rooms[current_room]: if rooms[current_room]["Item"] == "Goobert": #Player will be annihilated and the game will end print("You have been annihilated......Game over!") print("Come back and play again!") break if len(Inventory) == 6: print("You have collected all items and are able to escape!!!") print("You have won the game!!!") break print("Enter which way to move:") # Player is prompted which direction to move move = "" while move == "": move = input() move = move.split() if len(move) != 2: print("Invalid move, try another direction.") continue elif move[0] == "go": continue if move[1] in rooms[current_room]: current_room = rooms[current_room][move[1]] # main of program else: print("Wrong way, try again!") elif move[0] == "get": if "Item" in rooms[current_room] and move[1] in rooms[current_room]["Item"]: Inventory += [move[1]] print(move[1] + "!") else: print("Can't get" + move[1] + "!") else: print("Invalid move") if __name__ == '__main__': main()

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I can't figure out what is wrong with my code it won't output directions, prompts for direction or get items and I need an exit as well but nothing is working can you please help me find a solution.


def show_instructions():
# print main menu and how to move
print('Escape to Another Galaxy Text Game')
print('Collect 6 items to escape and win the game, or be annihilated by the evil alien Goobert')
print('Move Command:go south, go north, go east, go west, Exit')
print('get Alien Blaster. get Spare Parts. get fuel.')
print('get space snacks. get map.')


def show_status(current_room, inventory, room, rooms):
print('---------------------') # make another line after each move
print('You are in the' + current_room) # print players current location

print('inventory:' + str(inventory)) # print player current inventory
if "Item" in rooms[current_room]: # print an item if there is one
print("I can get the" + rooms[current_room]["Item"])

def main():

Inventory = [] # define inventory empty
# a dictionary linking rooms together
rooms = {
'Central Station': {'south': 'Parts and Service', 'north': 'Navigation Room', 'east': 'Cafeteria',
'west': 'Milky Way'},
'Parts and Service': {'north': 'Central Station', 'east': 'Experiment', 'Item': 'Alien Blaster'},
'Experiment': {'west': 'Parts and Service', 'Item': 'Spare Parts'},
'Navigation Room': {'south': 'Central Station', 'east': 'Control Room', 'Item': 'Goobert'},
'Control Room': {'west': 'Navigation', 'Item': 'Fuel'},
'Cafeteria': {'west': 'Central Station', 'north': 'Orbit Room', 'Item': 'Net'},
'Orbit Room': {'south': 'Cafeteria', 'Item': 'Space Snacks'},
'Milky Way': {'east': 'Central Station', 'Item': 'Map'}
}

current_room = "Central Station"

show_instructions()

while True:
show_status(current_room, Inventory, rooms)
if "Item" in rooms[current_room]:
if rooms[current_room]["Item"] == "Goobert": #Player will be annihilated and the game will end
print("You have been annihilated......Game over!")
print("Come back and play again!")
break

if len(Inventory) == 6:
print("You have collected all items and are able to escape!!!")
print("You have won the game!!!")
break
print("Enter which way to move:") # Player is prompted which direction to move

move = ""
while move == "":
move = input()
move = move.split()
if len(move) != 2:
print("Invalid move, try another direction.")
continue
elif move[0] == "go":
continue
if move[1] in rooms[current_room]:
current_room = rooms[current_room][move[1]] # main of program

else:
print("Wrong way, try again!")
elif move[0] == "get":
if "Item" in rooms[current_room] and move[1] in rooms[current_room]["Item"]:
Inventory += [move[1]]
print(move[1] + "!")
else:
print("Can't get" + move[1] + "!")
else:
print("Invalid move")

if __name__ == '__main__':
main()

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY