def drawMaze(self):
for y in range(self.rowsInMaze):
for x in range(self.columsnInMaze):
if self.mazelist[y][x] == OBSTACLE:
self.drawCenteredBox(x + self.xTranslate,
-y + self.yTranslate,
'tan')
self.t.color('black', 'blue')
def drawCenteredBox(self, x, y, color):
tracer(0)
self.t.up()
self.t.goto(x - .5, y - .5)
self.t.color('black', color)
self.t.setheading(90)
self.t.down()
self.t.begin_fill()
for i in range(4):
self.t.forward(1)
self.t.right(90)
self.t.end_fill()
update()
tracer(1)
def updatePosition(self, row, col, val=None):
if val:
self.mazelist[row][col] = val
self.moveTurtle(col, row)
if val == PART_OF_PATH:
color = 'green'
elif val == OBSTACLE:
color = 'red'
elif val == TRIED:
color = 'black'
elif val == DEAD_END:
color = 'red'
else:
color = None
if color:
self.dropBreadcrumb(color)
def isExit(self, row, col):
return (row == 0 or
row == self.rowsInMaze or
col == 0 or
col == self.columsnInMaze)