WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-13-2011, 03:33 AM
IOEPsych IOEPsych is offline
Member
 
Join Date: Apr 2011
Posts: 2
how do I put two exits in a maze?

I have designed a Vizard maze with an 'exit' that when you move into this area of the maze you hear a 'yipee' sound and the programme closes. I now need to be able to have the option to have two separate exits (so that the maze can be solved in two ways) but I cannot seem to do this as when I put another 'E' into my text file ('E' = END) then the programme opens but doesn't run properly. Any thoughts!???

This bit of my script looks like this:

def allTimers(event):

if (event == LOG_POSITION):
logPosition()
if (event == JOYSTICK_MOVE):
doMove()
if (event == CHECK_KEYBOARD):
checkKeyboard()
if (event == CHECK_END):
checkIfAtEnd()
if (event == STOP):
viz.quit()

def checkIfAtEnd():
''' Checks if the current position is in the end square of the maze.
'''
global endPos
pos = viz.MainView.getPosition()
euler = viz.MainView.getEuler()
lowEndX = endPos[0]*mazeExptParams.XSCALE
highEndX = (endPos[0]+1)*mazeExptParams.XSCALE
lowEndY = endPos[1]*mazeExptParams.YSCALE
highEndY = (endPos[1]+1)*mazeExptParams.YSCALE
x = pos[0]
y = pos[2]

if (x >= lowEndX and x <= highEndX) and (y >= lowEndY and y <= highEndY):
viz.playsound('yipee.wav')
viz.killtimer(CHECK_END)
viz.starttimer(STOP, 2)
Reply With Quote
  #2  
Old 04-13-2011, 11:54 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Sorry, the question is not so clear to me. Are you setting the endpoints of the maze from values taken from a text file? Where is your code to read in the file data?
Reply With Quote
  #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
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 04:15 PM.


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