I'm working on a text-based adventure game where the player moves between rooms and collects items. 'items' is a duplicate key. When I run my program, it's pulling the last value of 'item', instead of the one that pairs to the location. Here is my code:
#Stephanie Rivera
rooms = {
'Foyer': {'North': 'Kitchen', 'item': 'Pocket Watch', 'East': 'Library', 'item': 'Diary Page'},
'Library': {'West': 'Foyer'},
'Kitchen': {'West': 'Living Room', 'item': 'Ripped Photo', 'East': 'Bedroom',
'North': 'Turret', 'South': 'Foyer'},
'Living Room': {'East': 'Kitchen'},
'Bedroom': {'North': 'Attic', 'item': 'The Shadow Man', 'West': 'Kitchen'},
'Attic': {'South': 'Bedroom', 'item': 'Book of Matches'},
'Turret': {'East': 'Cellar', 'item': 'Ouija Board', 'South': 'Kitchen'},
'Cellar': {'West': 'Turret', 'item': 'Lantern'}
}
print('Welcome to The Shadow Man Text Adventure Game.')
print('Collect 6 items to win the game, or be defeated by The Shadow Man.')
print('Move commands: North, South, East, West.')
print("To add items to inventory, enter: Get 'item'.")
location = 'Foyer'
inventory = []
player_move = ''
item = ''
def show_instructions():
#print instructions
print('You are in the', location)
print('Inventory:', inventory)
print('___________')
def player_location():
#print player's location on the map
print('You are in the', location)
def player_inventory():
#print player's inventory
print('Inventory:', inventory)
print('___________')
def player_input():
print('Enter a move:')
player_move = input()
show_instructions()
print('You are lost in the woods. You see a house with a light on up ahead. You decide to enter the house.')
while len(inventory) < 6:
player_move = input('Enter a move: ' )
for k in rooms[location].keys():
if player_move == k:
value = [rooms[location].get('item')[]]
location = rooms[location][player_move]
player_location()
print('You see a', *value)
player_input()
First of all, there cannot be duplicate keys in a dictionary.
So, if you want to store multiple values, use a list and keep appending to that list.
rooms = {
...
...
'Cellar': {'West': 'Turret', 'item': ['Lantern', 'Book', 'blah', 'blah']}
}
Related
I'm a total python newbie in a beginner programming class, and I'm stuck on one of our assignments. I'm supposed to be creating the bare bones start of a text game in which I move around rooms. I've managed to get the movement to work, but the "invalid command" and "exit game" commands aren't working.
rooms = {
'Foyer': {'name': 'Foyer', 'South': 'Dining Hall', 'North': 'Hallway', 'West': 'Courtyard', 'East': 'Grand Hall'},
'Dining Hall': {'name': 'Dining Hall', 'South': 'Servants Quarters', 'East': 'Kitchen', 'North': 'Foyer',
'West': 'Drawing Room'},
'Servants Quarters': {'name': 'Servants Quarters', 'North': 'Dining Hall'},
'Drawing Room': {'name': 'Drawing Room', 'East': 'Dining Hall'},
'Kitchen': {'name': 'Kitchen', 'West': 'Dining Hall'},
'Courtyard': {'name': 'Courtyard', 'East': 'Foyer'},
'Grand Hall': {'name': 'Grand Hall'},
'Hallway': {'name': 'Hallway', 'South': 'Foyer', 'East': 'Private Library'},
'Private Library': {'name': 'Private Library', 'West': 'Hallway', 'East': 'Master Bedroom'},
'Master Bedroom': {'name': 'Master Bedroom', 'West': 'Private Library'}
}
directions = ['North', 'South', 'East', 'West']
player_room = rooms['Foyer']
# turn below into definition that can be called on later
while True:
print()
print('You have entered the {}.'.format(player_room['name']))
command = input('\nEnter a direction: North, South, East, or West')
if command in directions:
if command in player_room:
player_room = rooms[player_room[command]]
else:
print("You face a wall. There is no doorway here.")
elif command == "Exit" or "exit":
print("Play again soon.")
break
else:
print("Type a cardinal direction to move. Directions are case-sensitive.")
This is my code so far. Whenever I test inputting an invalid command, like a number or a random word, it just gives me the 'exit' text and ends the program. I thought the problem was the order of the commands, so I swapped them around and messed with the statements a little, but then it would just repeatedly give me the error text even if I typed "exit". How do I stop one from always taking priority over the other?
The issue is with the condition in your elif statement: command == "Exit" or "exit". What this actually does is always evaluate to True because the string "exit" is always considered a true value.
You can fix this by changing the condition to command == "Exit" or command == "exit". This way, the condition will only be True if the input is either "Exit" or "exit".
You can also store the command inside a list and use the lower() method to convert the user's input to lowercase so that it is not case-sensitive.
change your elif as below
rooms = {
'Foyer': {'name': 'Foyer', 'South': 'Dining Hall', 'North': 'Hallway', 'West': 'Courtyard', 'East': 'Grand Hall'},
'Dining Hall': {'name': 'Dining Hall', 'South': 'Servants Quarters', 'East': 'Kitchen', 'North': 'Foyer',
'West': 'Drawing Room'},
'Servants Quarters': {'name': 'Servants Quarters', 'North': 'Dining Hall'},
'Drawing Room': {'name': 'Drawing Room', 'East': 'Dining Hall'},
'Kitchen': {'name': 'Kitchen', 'West': 'Dining Hall'},
'Courtyard': {'name': 'Courtyard', 'East': 'Foyer'},
'Grand Hall': {'name': 'Grand Hall'},
'Hallway': {'name': 'Hallway', 'South': 'Foyer', 'East': 'Private Library'},
'Private Library': {'name': 'Private Library', 'West': 'Hallway', 'East': 'Master Bedroom'},
'Master Bedroom': {'name': 'Master Bedroom', 'West': 'Private Library'}
}
directions = ['North', 'South', 'East', 'West']
player_room = rooms['Foyer']
# turn below into definition that can be called on later
while True:
print()
print('You have entered the {}.'.format(player_room['name']))
command = input('\nEnter a direction: North, South, East, or West').title()
if command in directions:
if command in player_room:
player_room = rooms[player_room[command]]
else:
print("You face a wall. There is no doorway here.")
elif command == "Exit" or command == "exit":
print("Play again soon.")
break
else:
print("Type a cardinal direction to move. Directions are case-sensitive.")
I have a key:value pair == 'item': energy potion. I'm trying to add the whole value energy potion to my inventory but only 'energy' gets added. I know it has to do with obj = command.lower().split()[1] as this just adds the value at location 1. I don't know how to get both words.
import time
def instructions():
directions = 'North, East, South, or West'
print(f'\nYou may go {directions}.')
print('\nEquip item: get \'item name\'')
print('\nTo exit, type \'quit\'.')
def player_status(rooms, current_room, inventory):
print(f'\nYou are at {current_room}.')
if 'item' in rooms[current_room]:
print('There is a ' + rooms[current_room]['item'])
print('You have:', inventory)
def main():
inventory = []
rooms = {
'your apartment': {'West': 'occult bookstore', 'South': 'McDally\'s Pub'},
'occult bookstore': {'East': 'your apartment', 'item': 'Skull'},
'McDally\'s Pub': {'North': 'your apartment', 'East': 'Shedd Aquarium', 'South': 'Wrigley Field',
'item': 'energy potion'},
'Wrigley Field': {'North': 'McDally\'s Pub', 'West': 'your office', 'item': 'wizard\'s staff'},
'your office': {'East': 'Wrigley Field', 'item': 'Faerie Queen'},
'Shedd Aquarium': {'West': 'McDally\'s Pub', 'North': 'Field Museum of Natural History',
'item': 'enchanted duster'},
'Field Museum of Natural History': {'South': 'Shedd Aquarium', 'North': 'Saint Mary of the Angels church',
'item': 'blasting rod'},
'Saint Mary of the Angels church': {'South': 'Field Museum of Natural History', 'item': 'shield bracelet'}
}
current_room = 'your apartment'
instructions()
player_status(rooms, current_room, inventory)
time.sleep(3)
# sets up user command to move player between rooms.
command = input('\nWhat do you want to do?\n>').title().strip()
if command in rooms[current_room]:
current_room = rooms[current_room][command]
time.sleep(1)
# to move item into inventory and remove it from dict.
elif command.lower().split()[0] == 'get':
obj = command.lower().split()[1]
if obj in rooms[current_room]['item']:
del rooms[current_room]['item']
inventory.append(obj)
else:
print("I don't see that here.")
# a command to quit the game.
elif command.lower() in ('q', 'quit'):
time.sleep(1)
print('\nThanks for playing.')
break
# if player inputs an invalid command.
else:
time.sleep(1)
print('\nYou can\'t go that way!')
if __name__ == "__main__":
main()
here is how the game runs at current.
Any help would be greatly appreciated!
You are at McDally's Pub.
There is a energy potion
You have: []
What do you want to do?
>get energy potion
You may go North, East, South, or West.
Equip item: get 'item name'
To exit, type 'quit'.
You are at McDally's Pub.
You have: ['energy']
What do you want to do?
>
Update:
I have made changes with maxsplit=1 but now I cannot add an item with only one value to inventory. ex. skull cannot be added.
elif command.lower().split()[0] == 'get':
obj = command.lower().split(maxsplit=1)[1]
if obj in rooms[current_room]['item']:
del rooms[current_room]['item']
inventory.append(obj)
else:
print("I don't see that here.")
code outputs:
You are at occult bookstore.
There is a Skull
You have: ['energy potion']
What do you want to do?
>get skull
I don't see that here.
Use the optional maxsplit=1 argument to split, so that it will only split on the first space. Any spaces after that will not be split.
If command is "get energy potion", then command.split(maxsplit=1) will return ['get', 'energy potion'].
So below is my current code for a text based game that I have to finish for a school project:
# The dictionary links a room to other rooms as well as listing the item in the room
rooms = {
"Crew Quarters": {'East': 'Ship Storage', 'South': 'Operations Deck'},
"Ship Storage": {'West': 'Crew Quarters', 'South': 'Power and Oxygen Control', 'Item': 'Spare O2 Tank'},
"Operations Deck": {'North': 'Crew Quarters', 'East': 'Power and Oxygen Control',
'South': 'Crew Training Chamber', 'West': 'Captain Quarters', 'Item': 'Head Lamp'},
"Power and Oxygen Control": {'North': 'Ship Storage', 'West': 'Operations Deck',
'South': 'Infirmary'},
"Captains Quarters": {'East': 'Operations Deck', 'South': 'Armory', 'Item': 'Key to POC'},
"Armory": {'North': 'Captains Quarters', 'East': 'Crew Training Chamber', 'Item': 'Laser Rifle'},
"Crew Training Chamber": {'North': 'Operations Deck', 'East': 'Infirmary',
'West': 'Armory', 'Item': 'Space Suit'},
"Infirmary": {'North': 'Power and Oxygen Control', 'West': 'Crew Training Chamber', 'Item': 'Med-kit'}
}
# List of commands for movement or to exit the game
directions = ['North', 'South', 'East', 'West']
exit_game = ['e', 'exit']
inv = ['inv']
inv_list = []
# Current / starting room
c_room = 'Crew Quarters'
# print the game name, commands, and objectives.
print("Spaceship Text Adventure")
print("There's been a breach in the Power and Oxygen Control room on the ship!",
"Take care of the threat!")
print("Collect 6 items to defeat the anomaly or let the ship be taken over!")
print("Move commands: go South, go North, go East, go West")
print("Add to Inventory: get 'item name'")
print("To check your inventory: 'inv'")
print("To exit the game: 'e' or 'exit'")
# Game Loop
while True:
print('\nYou are in the', c_room)
command = input("\nWhere would you like to go? ")
if command in directions:
if command in rooms[c_room]:
c_room = rooms[c_room][command]
print(c_room)
# 1
else:
print('You cannot go that way')
elif command in inv:
print(inv_list)
elif command in exit_game:
print('You have exited the game. Thank you for playing!')
break
else:
print('Invalid command, try again!')
So what I want/need to do is whenever the player enters a room with an item in it, I need it to display the item that is in that room. If the player already has the item in the inventory, and they go back into the room, i need it to display "You've already taken the item from this room."
Where I placed my #1 is where I feel like the code should go, but I honestly have no idea. Any help would be appreciated as I'm struggling with calling upon lists and printing different statements. TYIA!
In helping out someone else with a similar room navigation game, I had added an inventory list that acquired a copy of the items selected in the various rooms. Following is the sample code.
# data setup
rooms = {'Great Hall': {'name': 'Great Hall', 'item': ['none'], 'south': 'Vendetta Room', 'east': 'Kitchen',
'north': 'Potion Lab', 'west': 'Armory',
'text': 'You are in the Great Hall.'},
'Armory': {'name': 'the Armory', 'item': ['Fire Sword'], 'east': 'Great Hall', 'north': 'Treasure Room',
'text': 'You are in the Armory.'},
'Treasure Room': {'name': 'the Treasure Room', 'item': ['Magic Ring'], 'south': 'Armory',
'text': 'You are in the Treasure Room.'},
'Potion Lab': {'name': 'the Potion Lab', 'item': ['Healing Potion'], 'east': 'Bedroom', 'south': 'Great Hall',
'text': 'You are in the Potion Lab.'},
'Bedroom': {'name': 'the Bedroom', 'item': ['Magic Key'], 'west': 'Potion Lab',
'text': 'You are in the Bedroom.'},
'Kitchen': {'name': 'the Kitchen', 'item': ['Sandwich'], 'south': 'Storage', 'west': 'Great Hall',
'text': 'You are in the Kitchen.'},
'Storage': {'name': 'Storage', 'item': ['Shield'], 'east': 'Mystery Room',
'text': 'You are in Storage.'},
'Mystery Room': {'name': 'The Mystery Room', 'item': ['none'], 'west': 'Storage', 'north': 'Kitchen',
'text': 'You are in the Mystery Room.'},
# villain
'Vendetta Room': {'name': 'the Vendetta Room', 'item': ['none'], 'west': 'Dungeon', 'north': 'Great Hall',
'text': 'You are in the Vendetta Room.'},
# Princess
'Dungeon': {'name': 'the Dungeon', 'item': ['none'], 'east': 'Vendetta Room',
'text': 'You are in the Dungeon.'}
}
directions = ['north', 'south', 'east', 'west']
add_items = ['get item']
current_room = rooms['Great Hall']
inventory = []
def status():
print('-' * 20)
print('You are in the {}'.format(current_room['name']))
print('Your current inventory: {}\n'.format(inventory))
if current_room['item']:
print('Item in room: {}'.format(', '.join(current_room['item'])))
print('')
# game loop
while True:
status()
if current_room['name'] == 'The Mystery Room':
if ['Magic Key'] not in inventory:
print("Oh No! As soon as you entered, the doors locked behind you.")
print("You don't have the Magic Key to open the door and end up trapped forever.")
print("GAME OVER")
break
elif ['Magic Key'] in inventory:
print("Oh No! As soon as you entered, the doors locked behind you.")
print("Luckily you found the Magic Key and could unlock the doors to continue your journey.")
if current_room['name'] == 'the Vendetta Room' and len(inventory) > 5:
print("You used all your items to defeat King Nox! Proceed to the next room to save the Princess.")
elif current_room['name'] == 'the Vendetta Room' and len(inventory) < 6:
print("You have found the Demon King but have no weapons.")
print("You have been defeated and the Princess has perished.")
print("GAME OVER")
break
elif current_room['name'] == 'the Dungeon':
print('Congratulations! You have reached the Dungeon and saved the Princess!')
print("You gave the Princess your healing potion and escorted her to the castle.")
print("Thank you for playing!")
break
command = input('Enter Move:')
# movement
if command == 'quit': # Moved this ahead of the directional and acquisition commands
print('Thanks for playing')
break
if command in directions:
if command in current_room:
current_room = rooms[current_room[command]]
elif command != add_items:
# bad movement
print('Invalid entry. Try again.')
# adding inventory
elif command in add_items:
if current_room['item'] != ['none']:
if current_room['item'] in inventory: # No need to acquire an item a second time
print("You already have this item")
else:
inventory.append(current_room['item'])
print("You acquired : ", current_room['item'])
elif current_room['item'] == ['none']:
print("No items to collect in this room")
else:
print('Invalid entry. Try again.')
I probably did not need to copy in the whole bit. Mainly you would want to focus in on the block of code at the end that checks to see if the player has already picked up an item and if so, remind the player that they already possess the item.
Give that a try and see if it meets the spirit of your project.
Try:
# The dictionary links a room to other rooms and provides info if there
# is an item in the room along with its status ('noItm':True means item
# was already taken):
rooms = {
"Crew Quarters" : {'East' : 'Ship Storage',
'South': 'Operations Deck',
'noItm': True},
"Ship Storage" : {'West' : 'Crew Quarters',
'South': 'Power and Oxygen Control',
'Item' : 'Spare O2 Tank',
'noItm': False},
"Operations Deck" : {'North': 'Crew Quarters',
'East' : 'Power and Oxygen Control',
'South': 'Crew Training Chamber',
'West' : 'Captain Quarters',
'Item' : 'Head Lamp',
'noItm': False},
"Power and Oxygen Control": {'North': 'Ship Storage',
'West' : 'Operations Deck',
'South': 'Infirmary',
'noItm': True},
"Captains Quarters" : {'East' : 'Operations Deck',
'South': 'Armory',
'Item' : 'Key to POC',
'noItm': False},
"Armory" : {'North': 'Captains Quarters',
'East' : 'Crew Training Chamber',
'Item' : 'Laser Rifle',
'noItm': False},
"Crew Training Chamber" : {'North': 'Operations Deck',
'East' : 'Infirmary',
'West' : 'Armory',
'Item' : 'Space Suit',
'noItm': False},
"Infirmary" : {'North': 'Power and Oxygen Control',
'West' : 'Crew Training Chamber',
'Item' : 'Med-kit',
'noItm': False}
}
# List of commands for movement or to exit the game
directions = ['North', 'South', 'East', 'West']
exit_game = ['e', 'exit', 'q', 'quit']
inv = ['i', 'inv']
get_item = ['get']
inv_list = []
# Current / starting room
c_room = 'Crew Quarters'
# print the game name, commands, and objectives.
print("Spaceship Text Adventure")
print("There's been a breach in the Power and Oxygen Control room on the ship!",
"Take care of the threat!")
print("Collect 6 items to defeat the anomaly or let the ship be taken over!")
print("Move commands: go South, go North, go East, go West")
print("Add to Inventory: get 'item name'")
print("To check your inventory: 'inv'")
print("To exit the game: 'e' or 'exit'")
# Game Loop
while True:
print('\nYou are in the', c_room)
command = input("\nWhat would you like to do? ")
if len(command) >= 2 and command[0:2] == 'go':
direction = command[3:]
if direction in directions:
if direction in rooms[c_room]:
c_room = rooms[c_room][direction]
if rooms[c_room]['noItm'] is False:
print(c_room)
print(f"There is '{rooms[c_room]['Item']}' in this room.")
else:
if 'Item' in rooms[c_room]:
print("You've already taken the item from this room.")
else:
print('You cannot go that way')
elif len(command) > 10 and command[0:3] in get_item:
item_in_room = rooms[c_room]['Item'] if 'Item' in rooms[c_room] else None
item_to_get = command[5:-1]
if rooms[c_room]['noItm'] is False and item_to_get == item_in_room:
inv_list.append(item_in_room)
rooms[c_room]['noItm'] = True
print(f"You have got '{item_in_room}'")
else:
print(f"There is no '{item_to_get}' in this room")
elif command in inv:
print(inv_list)
elif command in exit_game:
print('You have exited the game. Thank you for playing!')
break
else:
print('Invalid command, try again!')
I have added a new key about the existence of an item to the dictionaries in rooms dictionary allowing to add the code for taking items from a room.
So I have been working on this text based game in python for a project and I have gotten it where I can move around but can not get it where it will pick up the item itself. any help would be greatly appreciated. I am no expert as I am current going to school for programming and still learning.
def game_instructions(): # print a main menu and the commands
print("Killer Clown Text Adventure Game")
print("You must collect all six items to win the game or be killed by the Killer Clown!!")
print("Move commands: go South, go North, go East, go West, Exit")
print("Add to Inventory: get 'item name'")
rooms = {
'Front Gates': {'South': 'Games Area', 'East': 'Ticket Booth', 'item': 'none'},
'Games Area': {'North': 'Front Gates', 'East': 'Prize Area', 'West': 'Food Court', 'South': 'Storage Shed',
'item': 'Big Mallet'},
"Food Court": {'East': 'Games Area', 'item': 'pie'},
'Prize Area': {'West': 'Games Area', 'North': 'Fun House', 'item': 'Net'},
'Fun House': {'South': 'Prize Area', 'item': 'none'},
'Storage Shed': {'North': 'Games Area', 'East': 'Parking Lot', 'item': 'Flash Light'},
'Ticket Booth': {'West': 'Front Gates', 'item': 'Clown-B-Gone Book'},
'Parking Lot': {'West': 'Storage Shed', 'item': 'Keys'}
}
def room_movement(current_room, move, rooms):
current_room = rooms[current_room][move]
return current_room
def user_info():
print('You are in the {}'.format(current_room))
print('Inventory: ', inventory)
print('*' * 25)
def get_item(current_room):
if 'item' in rooms[current_room]: # if statement
return rooms[current_room]['item'] # return statement
else:
return 'This room has no item!' # return statement
game_instructions()
input('Press Enter to Continue')
inventory = []
current_room = 'Front Gates'
move = ''
while current_room != 'Fun House':
user_info()
move = input('Enter your next move.\n').title().split()
item = get_item(current_room)
print('There seems to be an item nearby')
if move == 'take':
move = input('What do you want to take? ').title().split()
if move in rooms[current_room]['item']:
inventory.append(item)
else:
print(f"There's no {item} here.")
if len(move) >= 2 and move[0].lower() == 'go' and move[1].capitalize() in rooms[current_room].keys():
current_room = room_movement(current_room, move[1].capitalize(), rooms)
continue
elif len(move) == 1 and move[0].lower() == 'exit':
current_room = 'exit'
else:
print('Invalid command')
I have to make a text based game for a final project. The goal is to pick up 6 items and to move from room to room. I'm still very new at this and would like some help! I can't seem to call the functions and I don't know how to add an inventory. Here is my current code:
def show_instructions():
#print a main menu and the commands
print("Thousand Year Vampire")
print("Collect 6 items to defeat the vampire or be destroyed by her.")
print("Move commands: go South, go North, go East, go West")
print("Add to Inventory: get 'item name'")
def showStatus(current_room, inventory, rooms):
#print the player's current location
#print the current inventory
#print an item if there is one
def main():
#define inventory and dictionary linking other rooms
rooms = {
'Entry Way': { 'North': 'Stalagmite Cavern'},
'Stalagmite Cavern': {'North': 'Grand Cavern', 'South': 'Entry Way', 'item': 'torch'},
'Grand Cavern': {'North': 'Hallway', 'East': 'Armory', 'West': 'Bedroom', 'South': 'Stalagmite Cavern', 'item': 'cross'},
'Armory': {'North': 'Treasure Trove', 'West': 'Grand Cavern', 'item': 'Stake'},
'Treasure Trove': {'South': 'Armory', 'item': 'silver'},
'Bedroom': {'North': 'Storage', 'East': 'Grand Cavern', 'item': 'elaborate comb'},
'Storage': {'South': 'Bedroom', 'item': 'mirror'},
'Hallway': {'North': 'Cliff Top', 'South': 'Grand Cavern'},
'Cliff Top': {'South': 'Hallway', 'item': 'Orla'}
}
# setting up inventory
inventory = []
# setting the starting room
starting_room = 'Great Hall'
# set current room to starting room
current_room = starting_room
while True:
print("\nYou are currently in {}".format(current_room))
move = input("Enter 'go North/South/East/West' to move or 'Exit': ").split()[-1].capitalize()
# user to exit
if move == 'Exit':
current_room = 'exit'
break
# a correct move
elif move in rooms[current_room]:
current_room = rooms[current_room][move]
# incorrect move
else:
print("You can't go that way. There is nothing to the {}".format(move))
#loop forever
#show game instructions
show_instructions()
This is not the final answer but I wanted to show you the changes you can make to the code to get the program to work.
This is just restructuring your code. It is not the solution. Once we understand what the problem is, I can help add to this to solve for it.
def show_instructions():
#print a main menu and the commands
print("Thousand Year Vampire")
print("Collect 6 items to defeat the vampire or be destroyed by her.")
print("Move commands: go South, go North, go East, go West")
print("Add to Inventory: get 'item name'")
def showStatus(current_room, inventory, rooms):
#print the player's current location
#print the current inventory
#print an item if there is one
#define inventory and dictionary linking other rooms
rooms = {
'Entry Way': { 'North': 'Stalagmite Cavern'},
'Stalagmite Cavern': {'North': 'Grand Cavern', 'South': 'Entry Way', 'item': 'torch'},
'Grand Cavern': {'North': 'Hallway', 'East': 'Armory', 'West': 'Bedroom', 'South': 'Stalagmite Cavern', 'item': 'cross'},
'Armory': {'North': 'Treasure Trove', 'West': 'Grand Cavern', 'item': 'Stake'},
'Treasure Trove': {'South': 'Armory', 'item': 'silver'},
'Bedroom': {'North': 'Storage', 'East': 'Grand Cavern', 'item': 'elaborate comb'},
'Storage': {'South': 'Bedroom', 'item': 'mirror'},
'Hallway': {'North': 'Cliff Top', 'South': 'Grand Cavern'},
'Cliff Top': {'South': 'Hallway', 'item': 'Orla'}
}
# setting up inventory
inventory = []
# setting the starting room
starting_room = 'Hallway'
# set current room to starting room
current_room = starting_room
#show game instructions
show_instructions()
while True:
print("\nYou are currently in {}".format(current_room))
move = input("Enter 'go North/South/East/West' to move or 'Exit': ").split()[-1].capitalize()
# user to exit
if move == 'Exit':
current_room = 'exit'
break
# a correct move
elif move in rooms[current_room]:
current_room = rooms[current_room][move]
# incorrect move
else:
print("You can't go that way. There is nothing to the {}".format(move))
#loop forever