I am trying to make a python maze generator but I keep getting an IndexError: list index out of range. Any ideas? I'm kinda new to this stuff so I was using the code from rosetta code on maze generation. I am not painting the maze right now I just want the algorithm to work right now.
from random import shuffle, randrange
maze_rows = 10
maze_columns = 10
maze = [[0 for rows in range(maze_rows)] for columns in range(maze_columns)]
def maze_generation(x,y):
maze[y][x] = 1
walk = [(x - 1, y), (x, y + 1), (x + 1, y), (x, y - 1)]
shuffle(walk)
for (xx, yy) in walk:
if maze[yy][xx]: continue
if xx == x:
maze[max(y,yy)][x] = 1
if yy == y:
maze[y][max(x,xx)] = 1
maze_generation(xx,yy)
maze_generation(randrange(maze_rows),randrange(maze_columns))