Function Repository Resource:
Random Labyrinth
Generate random labyrinths
ResourceFunction["RandomLabyrinth"][n] generates a random labyrinth based on n × n grid graph. | |
ResourceFunction["RandomLabyrinth"][{m,n}] generates a random labyrinth based on a grid graph with m rows and n columns. | |
ResourceFunction["RandomLabyrinth"][size,prop] gives the specified property prop for the labryinth. |
Details and Options
Examples
Basic Examples (1) 
Make a random rectangular grid labyrinth:
| In[1]:= |
| Out[2]= |
Scope (2) 
Make a random hexagonal grid labyrinth:
| In[3]:= |
| Out[3]= |
RandomLabyrinth can be given different properties:
| In[4]:= |
| Out[4]= |
If the properties argument is All, then an association with all properties is returned:
| In[5]:= |
| Out[5]= |
Options (1) 
GridLayout (1) 
The option "GridLayout" specifies the type grid graphs used to make the labyrinth. It takes the values "Rectangular" and "Hexagonal":
| In[6]:= |
| Out[6]= |
Applications (3) 
Make a rectangular grid labyrinth and show it together with a solution:
| In[7]:= |
| Out[8]= |
Make a hexagonal grid labyrinth and show it together with a solution:
| In[9]:= |
| Out[10]= |
Generate 100 labyrinths:
| In[11]:= |
| Out[12]= |
Show the histogram of the shortest path solution lengths:
| In[13]:= |
| Out[13]= |
Show the labyrinths with the smallest and largest shortest paths solutions:
| In[14]:= |
| Out[14]= |
Possible Issues (2) 
For larger size values the labyrinth generation might be slow, especially, for hexagonal labyrinths:
| In[15]:= |
| Out[15]= |
The making of rectangular labyrinths with same size parameters is faster:
| In[16]:= |
| Out[16]= |
Neat Examples (3) 
Larger rectangular grid maze:
| In[17]:= |
| Out[18]= |
A larger hexagonal grid maze with its largest connected components colored:
| In[19]:= |
| Out[21]= |
A grid of tiny labyrinths:
| In[22]:= |
| Out[23]= |