WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
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
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
building a maze GoldenSun Vizard 3 06-04-2008 10:27 AM


All times are GMT -7. The time now is 01:27 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC