summaryrefslogtreecommitdiff
path: root/cell.py
diff options
context:
space:
mode:
authoryuzu-eva <stevenhu@web.de>2024-11-11 18:20:58 +0100
committeryuzu-eva <stevenhu@web.de>2024-11-11 18:20:58 +0100
commit7abdccd59f1bdb831cd2a8f6c92ad1e99f2eb5de (patch)
tree9d7cdfa18c49a252228c1ea93147ade24cdc7491 /cell.py
parent696199a0227cfccb2247978b1ba8c1b03f1ae26d (diff)
finished maze solver
Diffstat (limited to 'cell.py')
-rw-r--r--cell.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/cell.py b/cell.py
index c2f763b..9aed822 100644
--- a/cell.py
+++ b/cell.py
@@ -11,6 +11,7 @@ class Cell:
self.twall = twall
self.rwall = rwall
self.bwall = bwall
+ self.visited = False
def draw(self, x1, y1, x2, y2):
if self._win is None:
@@ -26,8 +27,11 @@ class Cell:
self._win.draw_line(Line(Point(x1, y2), Point(x2, y2))) if self.bwall else self._win.draw_line(Line(Point(x1, y2), Point(x2, y2)), "white")
def draw_move(self, to_cell, undo=False):
- center_start = Point((self._x1+self._x2)>>1, (self._y1+self._y2)>>1)
- center_end = Point((to_cell._x1+to_cell._x2)>>1, (to_cell._y1+to_cell._y2)>>1)
+ half_length_start = abs(self._x2 - self._x1) // 2
+ center_start = Point(self._x1 + half_length_start, self._y1 + half_length_start)
+
+ half_length_end = abs(to_cell._x2 - to_cell._x1) // 2
+ center_end = Point(to_cell._x1 + half_length_end, to_cell._y1 + half_length_end)
fill_color = "red"
if undo:
fill_color = "gray"