I\'m not sure how to finsih this lab... I\'ve attached what i\'ve done so far ht
ID: 3779652 • Letter: I
Question
I'm not sure how to finsih this lab... I've attached what i've done so far
http://programarcadegames.com/index.php?chapter=lab_adventure&lang=en
current_room = 0
room_list = []
room = ["You are is a dusty castle room. Passeges lead to north and east", 3, 1, None, None]
room_list.append(room)
room = ["You are in the South Hall. Passages lead to the north,east, and west", 4, 2, None, 0]
room_list.append(room)
room = ["You are in the Dining Room. Passages lead to the north, and west", 5, None, None, 1]
room_list.append(room)
room = ["You are in Bedroom 1. Passages lead to the south and east", None, 4, 0, None]
room_list.append(room)
done = False
while not done:
print
print room_list[current_room] [0]
answer = raw_input ("What direction? ")
if answer == "n":
next_room = room_list [current_room] [1]
print(room_list[next_room][0])
elif answer == "e":
next_room = room_list[current_room][2]
print(room_list[next_room][0])
'''
print next room
elif answer == "e":
next_room = room_list(current_room)[2]
elif answer == "None":
print "Yoou can't go that way."
else:
current_room == next_room
'''
Explanation / Answer
room_list = []
room = [] * 5
room = ["You are in room 0 bedroom 2 There is a passage to the North",3,1,None,None]
room_list.append(room)
room =["you are in room 1 South hall",4,2,None,0]
room_list.append(room)
room = ["you are in room 2 dining room",5, 1,None,None]
room_list.append(room)
room = ["you are in room 3 Bedroom 1",None,4,0,None]
room_list.append(room)
room = ["room 4 North hall",6,5,1,3]
room_list.append(room)
room = ["room 5 Kitchen",None,None,2,4]
room_list.append(room)
room = ["room 6 balcony",None,None,4,None]
room_list.append(room)
current_room= 0
done = False
while done == False:
print (room_list[current_room][0])
x=input("what do you want to do?")
if x.upper() == "go north".upper() or x.upper() == "n".upper():
next_room=room_list[current_room][1]
if next_room == None:
print("You Can't go that way")
else:
current_room = next_room
elif x.upper() == "go east".upper() or x.upper() == "e".upper():
next_room=room_list[current_room][2]
if next_room == None:
print("You can't go that way")
else: current_room = next_room
elif x.upper() == "go south".upper() or x.upper() == "s".upper():
next_room=room_list[current_room][3]
if next_room == None:
print("You can't go that way")
else: current_room = next_room
elif x.upper() == "go west".upper() or x.upper() == "w".upper():
next_room=room_list[current_room][4]
if next_room == None:
print("You can't go that way")
else: current_room = next_room
elif x.upper() == "quit".upper():
end = input("Are you sure you want too quit? :")
if end.upper()== "yes".upper():
done = True
else: print("I don't understand what you are trying too do. ")
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.