Assuming your maze looks like a grid, the position in the maze can be represented as a tuple (line, col). When you build a dictionary, create an entry for each position in the maze, the initial value is an empty list. In each actual position (r, c) in the maze, you can find out if you can get (r-1, c), (r, c-1), (r + 1, c) and (r, c + 1) . If you can, add this tuple to the list. So, let's say that I can get to (r-1, c) and (r, c + 1) from (r, c), the entry in the dictionary will look like
maze_dict[(r,c)] = [(r-1,c), (r,c+1)]
To create an empty dictionary, you should use:
maze_dict = {}
You should also familiarize yourself with the dictionaries in the python lesson.
seggy source share