Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new mazes #38

Merged
merged 1 commit into from
Feb 5, 2025
Merged

Add new mazes #38

merged 1 commit into from
Feb 5, 2025

Conversation

daphnedemekas
Copy link
Contributor

@daphnedemekas daphnedemekas commented Feb 5, 2025

Prim's algorithm:

The algorithm starts at an initial cell and builds the maze by collecting all walls adjacent to the current passage cells. It then repeatedly selects a random wall from this list, and if the cell on the opposite side hasn't been visited, it removes the wall to create a new passage, adding the new cell’s adjacent walls to the list. This process continues until all cells are visited, resulting in a maze with a more organic, branched structure that tends to have many short corridors and less bias toward long, straight passages.

Screenshot 2025-02-04 at 10 10 04 PM

Kruskal's algorithm:

Each cell starts as its own set and walls between adjacent cells act as potential edges, which are then shuffled randomly. The algorithm checks each wall in turn, and if the cells on either side belong to different sets, it removes the wall and merges the sets. This continues until all cells are connected in a perfect maze with a unique path between any two points, after which start and end markers are placed and the maze is finalized with bordering walls.

Screenshot 2025-02-04 at 10 17 58 PM

┆Issue is synchronized with this Asana task by Unito

@daveey daveey merged commit c964012 into main Feb 5, 2025
1 check passed
@daveey daveey deleted the new_mazes branch February 5, 2025 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants