Answered step by step
Verified Expert Solution
Question
1 Approved Answer
# Sandra Duffany # Function to display instructions def game _ instructions ( ) : # display Intro Instructions print ( ' Congrats you found
# Sandra Duffany
# Function to display instructions
def gameinstructions:
# display Intro Instructions
printCongrats you found a clue!
printCollect all six clues to be able to catch, and arrest the robber!
printMove Commands: North, East, South, and West',
printAdd to bag: Pick up "item Name"
printQuit Game: EXIT'
Gameinstructions
#define rooms and items
rooms
'Living Room': North: 'Bedroom', 'South':'EntrywayOffice
'Kitchen': East:'Living room''item''Flour HandPrints'
'Bedroom':South: 'Living room','East':'Bathroom'
'Bathroom':West:'Bedroom', "item":'Dropped glove'
'Storeroom':South:'Master Bedroom', "item":'Muddy Footprints'
'Master bedroom': North:'Storeroom','West':'Living room',"item": 'Cellphone'
'Entrywayoffice: North:'Living room','East':'Gaming room',"item": 'Ripped TShirt Piece'
'Gaming room': West:'EntrywayOffice
#Set player in beginning of the crime scene home, and give them an empty inventory
currentroom 'Living Room'
inventory
#function to get the new room based off of the current room and the players direction
def getnewroomcurrentroom:
newroom currentroom
for i in rooms:
if i currentroom
return newroom
#function to get the item in the current room
def getitemcurrentroom
if 'item' in roomscurrentroom:
return roomscurrentroomitem
if 'item' not in roomscurrentroom:
return 'This room has no item!
# Main game loop
while currentroom:
#Display current room and the things in inventory
printYou are in the current room
printInventory: Inventory
# Get the items in the current room
item getitemcurrentroom
if item:'Muddy footprints'
if currentroom 'Living room'
printThere is nothing to collect in this room'
if currentroomBedroom
if item in inventory:
printyou have collected this clue!
else:
printYou have already collected this clue'
pickup input
pickup pickup.title
if pickup strGet item:
inventory.appenditem
printYou picked up item
if pickup 'EXIT':
printGoodbye thank you for playing!
break
if item 'Robber':
if leninventory:
printSuccess You collected all the clues to catch and arrest the robber!
break
if leninventory:
printyou have not collected enough clues to arrest the robber, he now gets to walk free'
break
#Get player input for next direction
direction inputEnter the direction you would like to go
direction direction.capitalize
if direction 'EXIT':
printGoodbye
break
if direction 'North' or direction 'South' or direction 'East' or direction 'West':
#Get new room based on the direction
newroom getnewroomcurrentroom,direction
if newroom currentroom:
printYou cannot go that way'
else:
currentroom newroom
else:
printyou cannot go that way'
Can someone help make this code work on pycharm?
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