INNER CODE UNIT · Python
solve_maze
Kushal997-das/Project-Guidance · Desktop Application/Basic/Python/Maze Solver/main.py:195
def solve_maze(self):
if self.maze:
try:
self.maze.solve()
self.stats_label.config(text=f"States Explored: {self.maze.num_explored} \n Understanding pigmentation:\nBlue: Starting Point\tGreen: Ending Point\nYellow: Solution path of the maze\tRed: Incorrect path traversed by the program\nWhite: All possible path in the maze\tBlack: Walls")
self.display_solution()
except Exception as e:
messagebox.showerror("Error", f"Failed to solve maze: {str(e)}")
else:
messagebox.showwarning("Warning", "Please load a maze first.")
def display_solution(self):
self.maze.output_image("solved_maze.png", show_solution=True, show_explored=True)
self.image = Image.open("solved_maze.png")
self.image = self.image.resize((500, 500), Image.LANCZOS)
self.photo = ImageTk.PhotoImage(self.image)
self.canvas.create_image(0, 0, anchor=tk.NW, image=self.photo)