Conversation
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Massive Generation Refactor! ✅
Some large improvements have been made to the generation algorithm that impact both the speed, representation, and look of the maze. Since this is such a big change. I am going to try to detail it well in this PR. Don't hesitate to ask if you have any questions or suggestions for improvement!
Closes #17
Maze Cell Representation
Each maze cell is now represented by an object. This object can be found in
/lib/MazeCell.jsand looks like the following:To go along with this new class, a new 2D array creation function has been made that fills and array with these objects. This can be found in
/utils/arrayUtiland looks like the following:As you can see, we are setting all walls to be on by default. This is because it is easier to go through and remove the walls later, rather than adding them back in.
Maze Generation Algorithm
The algorithm itself has also been completely changed. I am now using a stack to track cell positions as we randomly walk through the maze. This stack is a last-in-first-out system. This allows for items to be popped (
.pop()) off the stack to backtrack to the previous position.While this is happening, we use the new objects to track which walls should be removed. When one cell is connected to another, that wall is removed. The
breakWalls()function in/components/NewGenerator.vuehandles this task. Part of that function looks like the following:At the end of the function, we can loop through all of the cells and style them according to the object they contain. The
styleMaze()function in/components/NewGenerator.vuehandles this task. Part of that function looks like the following:Generation Times
I wanted to ensure the generation happens within a reasonable amount of time. To me, this is ~1sec. As you can see below, we are well within that time window.
Screenshots