Now we need a Maze class that holds all the cells in the maze in a 2-dimensional grid: a list of lists.
def __init__(
self,
x1,
y1,
num_rows,
num_cols,
cell_size_x,
cell_size_y,
win,
):
self.__cells data member to an empty list (this will hold list of lists of cells)self.__create_cells() to create the cells in the maze (we're about to create this method)__cells data member: a 2-dimensional list of Cell objects. It should use the number of columns and rows to figure out how many Cell objects to create.self.__cells[0][0] is the top left cell, and self.__cells[1][0] is the cell to the right of it.self.__draw_cell() method to draw them on the screen (we're about to create this method)Cell's draw() methodself.__animate() method to animate the drawing of the cell (we're about to create this method)redraw() method0.05 seconds) so that we can actually see the pretty animationThe animate method is what allows us to visualize what the algorithms are doing in real time. It's not exactly performant, but its nice to be able to see what's happening as its happening. Its not only pretty, but its good for debugging! You can speed it up or slow it down by changing the sleep time.
Login to Complete
Login to view solution