Maze Generator #2

Use graphics.py for this project. Click HERE for more information. (download, install, documentation, ...)

Maze Generator #2

New Maze Generating Algorithm (Origin Shift) (YouTube)

To try out the algorithm click HERE .

To dowload the code click HERE .

#!/usr/bin/python # ============================================================== # maze generator # ============================================================== # rules that define a perfect maze # # 1. every node except the origin node must point to exactly # one neighboring node. # 2. every node must be connected to the origin node. # ============================================================== # # ----------------------- # goals for the algorithm # ----------------------- # # 1. as simple logic as possible # 2. decent run time # 3. results in a perfect maze # (no loops, or isolated areas) # # ------------- # the algorithm # ------------- # # 1. Start with a grid of nodes. Each has a direction property # that can point nowhere, or to one of its neighbors. # # 2. Initialize the grid to be any perfect maze, that being # a maze with no loops or isolated areas. Each node should # point to one neighboring node, with a single node, the # origin node, pointing nowhere. # # 3. Repeat the following steps for as many iterations as # you'd like: # # 3a. Have the origin node, point to a random neighboring # node. # # 3b. That neigboring node becomes the new origin node. # # 3c. have the new origin node point nowhere. # # ============================================================== import sys import math import random import graphics as gr

Links

Information About Maze Generation/Algorithms

How to Generate Completable Mazes In P5.JS (YouTube)

JavaScript (Wikipedia)

p5js.org (JavaScript graphics library)