Answered step by step
Verified Expert Solution
Question
1 Approved Answer
My code isn't working. My rooms still don t connect, I ve tried multiple times too and it doesn t work. For example, you start
My code isn't working. My rooms still dont connect, Ive tried multiple times too and it doesnt work. For example, you start out in the living room and go up north to the hallway then east to the kitchen but then when you try to go east to the pantry it doesnt There seem to be lots of bugs like you start out in the living room and go south but the new room desc doesnt print either. Also so make it so the input can handle north south west east as well as n e s w for input. When you start your game, it also doesnt print a room desc either which it should do as how would the player know where they are. Please do multiple test runs to make sure each room works because Ive seen people fix one thing and then break another thing!! Thank you Ive pasted the code below.
# Creating the empty room list
roomlist
# Creating rooms
# Format: Description North, East, South, West
# Living Room
room You are in a major modern living room. You can go either north or south", None, None
roomlist.appendroom
# Dining Room
room You are in a petite dining room. You can only go north", None, None, None
roomlist.appendroom
# Hallway
room You are in a modern hallway. Choose between east, west, or south.", None,
roomlist.appendroom
# Kitchen
room You are in a brand new kitchen. You can go west to the hallway or east to the pantry.", None, None,
roomlist.appendroom
# Bedroom
room Youre in the biggest master bedroom. There's a hallway to the east and a bathroom to the north.", None, None
roomlist.appendroom
# Pantry
room You are in a small pantry. You can only go west back to the kitchen.", None, None, None,
roomlist.appendroom
# Bathroom
room You are in a clean bathroom. You can only go south back to the bedroom.", None, None, None
roomlist.appendroom
# Starting in the living room
currentroom
# Main game loop
done False
while not done:
# Print the room description
print
roomlistcurrentroom
# Get the player's choice of direction
direction inputWhere do you want to golower
# Move the player based on input and room connections
if direction n and roomlistcurrentroom is not None:
currentroom roomlistcurrentroom
elif direction e and roomlistcurrentroom is not None:
currentroom roomlistcurrentroom
elif direction s and roomlistcurrentroom is not None:
currentroom roomlistcurrentroom
elif direction w and roomlistcurrentroom is not None:
currentroom roomlistcurrentroom
else:
printYou can't go that way!"
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