View Single Post
  #3  
Old 04-14-2011, 03:48 AM
IOEPsych IOEPsych is offline
Member
 
Join Date: Apr 2011
Posts: 2
Sorry, I didn't put that bit in. I have a text file with the layout of my maze which I import from a separate .py file that has the name of the specific .txt file that I am using e.g. INPUT_FNAME='Maze 2c.txt'

I then have a 'maze dictionary' in which 'E' is assigned as the END position. This part of the file is below. Sorry, I'm not sure if this makes sense explaining it like this...
This is my other .py file that I import in to run the maze:

def transposeMatrix(mazeMatrix):
''' Transposes the given rectangular matrix, such that [i][j] becomes [j][i]
'''
mazeMatrixTransformed = []
for i in range(len(mazeMatrix[0])):
mazeMatrixTransformed.append([])
for i in range(len(mazeMatrix)):
line = mazeMatrix[i]
for j in range(len(line)):
mazeMatrixTransformed[j].append(mazeMatrix[i][j])
return mazeMatrixTransformed

def getMazeInfo(mazeMatrix):

mazeMatrixTransformed = transposeMatrix(mazeMatrix)
print 'transformed maze matrix is',mazeMatrixTransformed,'xLength=',len(mazeMatri xTransformed),'; yLength=',len(mazeMatrixTransformed[0])

rowMatrix=[]
colourMatrix=[]
columnMatrix=[]
objectMatrix=[]
items=[]
redballs=[]
startPos=[]
endPos=[]
item=False

#find start/end/objects
for x in range (len(mazeMatrixTransformed)):
for y in range(len(mazeMatrixTransformed[x])):
char=mazeMatrixTransformed[x][y]

if char=='S':
if startPos!=[]: raise Exception('multiple starts found')
startPos=[x,y]
elif char=='E':
if endPos!=[]: raise Exception('multiple ends found')
endPos=[x,y]


Someone else created this for me who is no longer available and they have set it to disallow multiple ends. Does this make sense? I need to allow two different ends of the maze to be put it. Sorry I'm new to Python!
Reply With Quote