Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generate a maze based on the Sierpinski carpet
ResourceFunction["RandomSierpinskiMaze"][scale] returns the ArrayPlot of a maze drawn by connecting dots on a square fragment of the Sierpiński carpet fractal, whose length dimension roughly equals 3scale+1. | |
ResourceFunction["RandomSierpinskiMaze"][scale, AdjacencyGraph] returns a primitive Graph of the maze, which determines allowable moves on the corresponding ArrayPlot. |
Depict a basic unit of the randomized maze:
| In[1]:= |
| Out[2]= | ![]() |
Scale up the basic unit by areal factors of 9:
| In[3]:= | ![]() |
| Out[3]= | ![]() |
Compare the ArrayPlot with its primitive Graph:
| In[4]:= | ![]() |
| Out[4]= | ![]() |
Display the same Graph coordinate-free and highlight a shortest path between corners:
| In[5]:= | ![]() |
| Out[5]= | ![]() |
Depict the path in an ArrayPlot:
| In[6]:= | ![]() |
| Out[6]= | ![]() |
The measured complexity is super-exponential with regard to input scale, but it is possible to obtain mazes up to scale=4 in reasonable time:
| In[7]:= | ![]() |
| Out[7]= | ![]() |
Use ArrayMesh to build a maze out of voxels:
| In[8]:= | ![]() |
| In[9]:= | ![]() |
| Out[9]= | ![]() |
Transform output Graph to a knight's walk graph:
| In[10]:= |
| In[11]:= | ![]() |
| In[12]:= |
| Out[12]= | ![]() |
Draw the knight's walk Graph over the maze adjacency Graph:
| In[13]:= |
| Out[13]= | ![]() |
Depict a knight's shortest path between corners:
| In[14]:= | ![]() |
| Out[14]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License