Kiff
- 6
- 0
I'm doing the movement part of the wumpus game. I'm sure many of you are familiar with it, but if not; basically the player starts out in room 1 and s allowed to move into any adjacent room, then from that room into any adjacent room and so on .
The map files that are organized as such:
1
275
2
567
and so on
so lines 1 and 3 are the room numbers and lines 2,4 are adjacent rooms
This is what I have so far. btw the map files are text format.
The attempt at a solution
Am I on the right track here? I worked out the problem on paper, and it seems like I have all the right concepts in code. I'm just confused about the arrangement. (integrating the loop and movement function)
Thanks in advance
The map files that are organized as such:
1
275
2
567
and so on
so lines 1 and 3 are the room numbers and lines 2,4 are adjacent rooms
This is what I have so far. btw the map files are text format.
The attempt at a solution
Code:
from wumpglobal import *
f = open("map1", "r")
i = 0
everything = f.readlines()<-----This turns all map elements into a list
start_room = everything[i]<---room player is in
close_rooms = everything[i+1]<-----adjacent rooms to start_room
def movement(i):
if room != item in list(close_rooms):<-----Whats the correct syntax for this?
return room + "is not an adjacent room"
else:
i = room + 2
while room != "quit":<----This is the loop that runs until user inputs "quit"
print "You are in room: " + start_room
print "Adjoining rooms: " + close_rooms
room = raw_input("Enter a room number to move, or q) quit")
print movement(i)
Am I on the right track here? I worked out the problem on paper, and it seems like I have all the right concepts in code. I'm just confused about the arrangement. (integrating the loop and movement function)
Thanks in advance