teniendo en cuenta este laberinto haz que el algoritmo crearlo sea mejor para no crear laberintos tan sencillos: "import tkinter as tk
import random
import time

class MazeApp:
    def __init__(self, master):
        self.master = master
        self.master.title("Generador y Resolver Laberinto")
        self.canvas = tk.Canvas(master, width=525, height=525)
        self.canvas.pack()

        self.rows = 21  # Debe ser impar
        self.columns = 21  # Debe ser impar
        self.cell_size = 25
        self.grid = None
        self.start = (1, 1)
        self.end = (self.rows - 2, self.columns - 2)
        self.solution_path = []

        self.create_maze()
        self.draw_maze()

        self.solve_button = tk.Button(master, text="Resolver Laberinto", command=self.solve_maze)
        self.solve_button.pack(side='left')

        self.reset_button = tk.Button(master, text="Generar Nuevo Laberinto", command=self.reset_maze)
        self.reset_button.pack(side='right')

    def create_maze(self):
        self.grid = [[1 for _ in range(self.columns)] for _ in range(self.rows)]
        self.grid[self.start[0]][self.start[1]] = 0
        self._generate_maze(self.start[0], self.start[1])

    def _generate_maze(self, r, c):
        directions = [(0, -1), (1, 0), (0, 1), (-1, 0)]
        random.shuffle(directions)

        for dr, dc in directions:
            new_r, new_c = r + dr*2, c + dc*2

            if (0 < new_r < self.rows - 1) and (0 < new_c < self.columns - 1) and (self.grid[new_r][new_c] == 1):
                self.grid[r + dr][c + dc] = 0
                self.grid[new_r][new_c] = 0
                self._generate_maze(new_r, new_c)

    def draw_maze(self):
        self.canvas.delete("all")
        for r in range(self.rows):
            for c in range(self.columns):
                color = "black" if self.grid[r][c] == 1 else "white"
                self.canvas.create_rectangle(c * self.cell_size, r * self.cell_size,
                                             (c + 1) * self.cell_size,
                                             (r + 1) * self.cell_size, fill=color, outline='gray')

        # Marca el inicio y el final
        self.canvas.create_rectangle(self.start[1] * self.cell_size, self.start[0] * self.cell_size,
                                     (self.start[1] + 1) * self.cell_size,
                                     (self.start[0] + 1) * self.cell_size, fill="green")  # Inicio

        self.canvas.create_rectangle(self.end[1] * self.cell_size, self.end[0] * self.cell_size,
                                     (self.end[1] + 1) * self.cell_size,
                                     (self.end[0] + 1) * self.cell_size, fill="red")  # Fin

    def solve_maze(self):
        self.solution_path = []
        visited = set()
        if self._solve_dfs(self.start[0], self.start[1], visited):
            self.animate_solution()
        else:
            print("No hay solución para el laberinto.")

    def _solve_dfs(self, r, c, visited):
        if (r, c) == self.end:
            self.solution_path.append((r, c))
            return True

        if (r < 0 or r >= self.rows or
            c < 0 or c >= self.columns or
            self.grid[r][c] == 1 or
            (r, c) in visited):
            return False

        visited.add((r, c))
        self.solution_path.append((r, c))

        # Explorar en cada dirección
        if (self._solve_dfs(r + 1, c, visited) or
            self._solve_dfs(r - 1, c, visited) or
            self._solve_dfs(r, c + 1, visited) or
            self._solve_dfs(r, c - 1, visited)):
            return True

        self.solution_path.pop()
        return False

    def animate_solution(self):
        for r, c in self.solution_path:
            if (r, c) != self.start and (r, c) != self.end:
                self.canvas.create_rectangle(c * self.cell_size, r * self.cell_size,
                                             (c + 1) * self.cell_size,
                                             (r + 1) * self.cell_size, fill="blue")
                self.master.update()
                time.sleep(0.02)

    def reset_maze(self):
        self.solution_path = []
        self.create_maze()
        self.draw_maze()

if __name__ == "__main__":
    root = tk.Tk()
    app = MazeApp(root)
    root.mainloop()"