Answered step by step
Verified Expert Solution
Question
1 Approved Answer
def show _ instruction ( ) : print ( ' Welcome Player' ) print ( ' You woke up in a hospital alone. You need
def showinstruction:
printWelcome Player'
printYou woke up in a hospital alone. You need to find items in the nine rooms.
printThere is a mutant zombie in one the rooms so be weary.
printMove commands: North, East, South, West'
printAdd to Inventory: Get Items'
print
def showstatus:
printfYou are in the currentroom
printfInventory: inventory
printYou look around and see', roomscurrentroomitem
rooms
'Bathroom': East: 'Room Six', 'item': 'Shoes'
'Room Six': West: 'Bathroom', 'South': 'Hallway', 'item': 'Clothes'
'Hallway': North: 'Room Six', 'East': 'Backdoor Room 'South': 'Staircase', West': Front Room', 'item': 'Gun'
'Front Room': East: Hallway', 'item': 'Backpack'
'Backdoor Room': West: 'Hallway', 'North': 'Morgue Room', 'item': 'Parking Lot key'
'Morgue Room': South: Backdoor Room', 'item': 'Car Key'
'Staircase': North: 'Hallway', 'East': 'Basement', 'item': 'Extra bullets'
'Basement': West: 'Staircase', 'East': 'Parking Lot', 'item': 'Canned food and water'
'Parking Lot': West: 'Basement', 'item': 'Mutant Zombie'
def getnewstatedirectionfromuser, currentroom :
newlocation currentroom
if directionfromuser in roomscurrentroom:
newlocation roomscurrentroomdirectionfromuser
else:
printYou hit the wall. Try again'
return newlocation
showinstruction
currentroom 'Room Six'
inventory
while True:
showstatus
directionfromuser inputEnter a command' title
if directionfromuser in North 'East', 'South', 'West':
newlocation getnewstatedirectionfromuser,currentroom
currentroom newlocation
elif directionfromuser Get roomscurrentroomitem:
if roomscurrentroomitem not in inventory:
inventory.appendroomscurrentroomitem
printYou picked up and put in your inventory'.formatroomscurrentroomitem
else:
printItem already picked up
elif currentroom 'Parking Lot':
printCONGRATULATION You successfully got the items, beat the Mutant Zombie, and got out of the hospital'
break
else:
printInvalid
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started