Maze Creator is a program created to automatically generate solvable mazes. The only required input from a user is a size (number of rows and columns) of a maze.
- Every maze (generated by the program) has exactly one entry and exit point.
- Every maze (generated by the program) is a rectangle.
- You cannot collide with an obstacle or a wall.
- You cannot move diagonally.
- Create a grid filled with paths inside of the grid and with obstacles on the grid's borders. Size of the grid is provided by the user. Class
GridCreator
is responsible for this. - Generate an entry and exit point on borders of the grid. Class
EntryExitGenerator
is responsible for this. - Create a solution path, a path which connects the entry and exit point. Class
SolutionPathCreator
is responsible for this. - Add internal walls into the grid. Class
InternalWallsCreator
is responsible for this. - Connect disjointed paths. Class
PathConnector
is responsible for this. - Make sure that the solution path is the optimal path from start to finish. Class
SolutionPathOptimalMaker
is responsible for this. - Remove isolated paths. Class
IsolatedPathsRemover
is responsible for this. - (Optional) Display generated maze. Class
GridDisplay
is responsible for this. - (Optional) Save all data of the generated maze. Class
SaveData
is responsible for this.
MazeGenerator.__init__(self, rows, columns, display_maze=True, save_data=True)
rows
- (int) a desired number of rows of a maze. Must be greater or equal to 6, however values below 20 are not recommended.columns
- (int) a desired number of columns of a maze. Must be greater or equal to 6, however values below 20 are not recommended.display_maze
- (bool) display the maze after generation process. Default = True.save_data
- (bool) save all necessary data about the generated maze. Default = True.
MazeLoader.__init__(self, filename, display_maze=True)
filename
- (str) full name of a file which contains data about a generated maze. Currently the formats.csv
and.pickle
are supported.csv
save file stores only the data about a grid.pickle
save file stores all data.display_maze
- (bool) display the maze after data load. Default = True.
Tests were based on 10 attempts.
- 40 x 40 - 17 seconds
- 50 x 50 - 41 seconds
- 60 x 60 - 2 minutes 29 seconds
- 70 x 70 - 5 minutes 13 seconds
- 80 x 80 - 10 minutes 36 seconds
- To generate a new maze use the
MazeCreator
class and launch thegenerate_maze
method. - To load data of a previously generated maze use the
MazeLoader
class and launch theload_grid_from_csv
or theload_data_from_pickle_file
method.
Python
3.8numpy
1.19.4pandas
1.1.5matplotlib
3.3.3
- A* algorithm explanation video: https://www.youtube.com/watch?v=-L-WgKMFuhE
a yellow square - a path
a green square - an obstacle or a wall