#Initialise#set up dictionariesMAP = {'foyer_forward':'kitchen','foyer_right':'lounge','foyer_backward':'front door','foyer_left':'bedroom','bedroom_right':'foyer', 'front door_forward':'foyer','kitchen_backward':'foyer','lounge_left': 'foyer' }DESC = {'foyer':'You are in the foyer. It is dark and scary. You want to get out! ','back door':'Congratulations, you have escaped via the back door! ','bedroom':'You are in the bedroom. There is a dragon.','lounge':'You are in the lounge. There is a lamp.','front door':'The front door is locked!','kitchen':'You are in the kitchen. There is no light. It is too dark to see.' }#set up list of items that end the gameFINISH = ['front door','quit','dead','end' ]#set up a list of itemsITEMS = {'knife':False,'key':False,'lamp':False }#starting locationroom = 'foyer'#Start of game codename = input('What is your name? ')print ('Hello',name)print ('You are in a castle with many rooms. ')print ('Your challenge is to escape the castle without being eaten by the dragon')#loops continuously until a break. Note capital letter in boolean value TruewhileTrue:print (DESC[room])# Check to see if the room decription contains the word knifeif'knife'in DESC[room]:# set the ITEMS value for knife to be True ITEMS['knife'] = True# and inform the userprint('You now have knife')if'lamp'in DESC[room]: ITEMS['lamp'] = True# Change the desciption of rooms now you have a lamp. DESC['kitchen'] = 'You are in the kitchen. There is a knife.' DESC['foyer'] = 'You are in the foyer. You can now see.'print('You now have lamp')if'dragon'in DESC[room]:if ITEMS['knife'] == True:print('You killed the dragon with your knife')print('The dragon was sitting on a key')print('You now have the key') ITEMS['key'] = True DESC['front door'] = 'You use your key and leave the castle'else:print('The dragon eats you') room = 'dead'if room in FINISH:break direction = input( 'Enter a direction? Choose from forward, backward, left, right or quit ')if direction in FINISH:break key = room + '_' + directionif key in MAP: room = MAP[key]else :print ('You can\'t go ' +direction+'. ' )print ('Game over!')