-
Notifications
You must be signed in to change notification settings - Fork 0
/
mazCreator.py
70 lines (55 loc) · 2.04 KB
/
mazCreator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
objectType = "BraitenbergSound";
def main():
filename = "maze.txt"
line = 0;
column = 0;
f = open(filename, "r")
#Reads the limits of the maze.
numbers = f.readline()
columnLimit = int(numbers.split(" ")[1])
lineLimit = int(numbers.split(" ")[0])
print lineLimit, columnLimit
#Reads the maze itself.
text = f.readlines()
#Iterates over the lines.
for i in xrange(len(text)):
for t in xrange(len(text[i])):
if (text[i][j] == "*"):
self.obj = breve.createInstances ( breve.BraitenbergSound, 1)
self.obj.move( breve.vector(i*10, 2, j*10))
# if (isHorizontal(line, column, lineLimit, columnLimit, i)):
# printHorizontal(line, column)
# else:
# printVertical(line, column)
# column += 1
# line += 1
# column = 0;
print text
#Find if this wall is to be drawn as an horizontal or vertical one.
def isHorizontal(line, column, lineLimit, columnLimit, lineRead):
#We are defining the top walls.
if (line == 0 or line == lineLimit - 1):
return True;
#We are defining the side walls.
elif (column == 1 or column == columnLimit - 1):
return False;
#Now, we have to look at the interior symbols.
#This wall is side by side with another wall on the horizontal.
#It means it's horizontal too.
if (lineRead[column+1] == "*" or lineRead[column-1] == "*"):
return True;
#In all other cases, it's a vertical wall.
return False;
#Prints an horizontal wall.
def printHorizontal(line, column):
i = 0
text = "for i in range(1,4):\n\tself.obj = breve.createInstances ( breve." + objectType + ", 1)\n\tself.obj.move( breve.vector(i*"+ "4,0," + str(line) + "))"
print text
#Prints a vertical wall.
def printVertical(line, column):
'''
for i in range(10,14):
self.block = breve.createInstances( breve.BraitenbergSound,1)
self.block.move( breve.vector(i*4,0,5))'''
if __name__ == "__main__":
main()