From 7abdccd59f1bdb831cd2a8f6c92ad1e99f2eb5de Mon Sep 17 00:00:00 2001 From: yuzu-eva Date: Mon, 11 Nov 2024 18:20:58 +0100 Subject: finished maze solver --- cell.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'cell.py') 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" -- cgit v1.2.3