Coding Challenge #10.4: Maze Generator with p5.js – Part 4

[ad_1]
In the final part of the Maze Generator Challenge, using p5.js, I cover the concept of a “stack” and how it’s going to help us generate a maze using the Depth-First Search Recursive algorithm

Support this channel on Patreon:

Send me your Coding Challenge ideas!

Contact:

Nature of Code class on Kadenze:

Source Code for this project:

p5.js:
Algorithm for Maze Generators:

For more Coding Challenges:

To learn more about javascript:

Help us caption & translate this video!


Posted

in

by

Tags:

Comments

25 responses to “Coding Challenge #10.4: Maze Generator with p5.js – Part 4”

  1. Atone SB Avatar

    This is the first one I've followed along with. I implemented this in Lua with Löve2D and had a blast doing so. You've earned a subscriber. I have the day off tomorrow and I think I'm gonna try to implement a different maze algorithm from the wiki page in the morning.

  2. Carlos Escobar Avatar

    I love the way you talk to the people of the future. *robots
    min 6:50 🙂

  3. TheCoolSquare Avatar

    I got the idea that a similar algorithm to this could be used for rudimentary map generation in a game. Perhaps with a much smaller size overall (Maybe around 10×10) and a few adjustments that deliberately avoid visiting every cell to complete the maze. Then the generated maze could be read by a more advanced generator that creates the actual playable map by replacing each cell with different rooms, either hand-crafted or procedurally generator by another process.

  4. Jitesh Bohra Avatar

    came here after a* search algorithm, loving it!

  5. TILE- MAKER Avatar

    how do you create a restart function that when it is done, it creates a new maze?

  6. Jack Jones Avatar

    I don't even know how to code but this stuff interests me so much! The videos are super interesting. Anyone know of any good free programmes that i can use to learn the basics and build my knowledge??

  7. morphman86 Avatar

    You said in Part 1 that you could use this algorithm to get a maze with an in and out point, but you only showed with just the in point. How would you use this particular algorithm to make a maze with an exit as well?

    The way I can figure out is to just say "This cell right here is the exit" and colour it differently, but there's nothing in this particular code that prevents the algorithm to make that exact cell into a part of a corridor rather than an endpoint.

    I guess you could add something that figures out if that cell already has a wall removed and treat the remaining 3 neighbours as visited or something…

  8. morphman86 Avatar

    I was lucky. When I started fiddling with stacks, I had already played Magic: The Gathering for 5 years. The word stack is used there too, in exactly the same way, to keep track of the order certain card effects have.

    When a player plays a card, its effects are added to the stack. If another card is played, its effects goes on the stack above the previous card effects and so on and so forth. Then you simply go backwards from the top of the stack and resolve each effect in the reverse order of which they were played.

    For most players, this doesn't matter too much, but in tournaments, using (or abusing) the stack has turned the tide for many players.

  9. curtsher11 Avatar

    I think one optimization for the back tracking part would be to only add a cell to the stack if it has multiple candidates to be the chosen cell.

  10. Eli Mana Avatar

    6:58 You aren't just back on track, you could say that you are coding the "backtrack" functionality

  11. VIT3Z Avatar

    Can anyone help me? I want to add an element to this maze generator where the user defines the width of the cell, but I cannot get it to work properly… Changing the value only causes the maze to zoom in or out, and the walls don't get properly destroyed.

  12. Hamza Biyuzan Avatar

    you are like a 100000000 times more better than all my teachers combined together
    thank you so much 😀

  13. Diego Rodriguez Avatar

    Ok, here i make a maze, but, i mean, there is no sense. You need an ending cell, right? So how can u make ONLY one cell at the end? You need to force that cell to have 3 wall closed (the one you choose). How could you do that?

  14. Jarno Piironen Avatar

    I you can, Do! If you know, Teach. You do that very professional. Thank you, i am visual person i learn much just watchin, listening, reading is my weakness. You level up me!

  15. Erik Bach Ryhl Avatar

    "I'm back on track" Backtracking 😀

  16. randy hill Avatar

    Great tutorials, I tried my hand at this maze generator, using python and pygame. Made a quick video of the result

    https://www.youtube.com/watch?v=ml_kBevMnc0

  17. Calz20Videos Avatar

    Who made it all the way?

  18. Edmund Korley Avatar

    I took a stab at this and using Krusal's algorithm for maze generation (want to take a stab at the rest of the algorithms on the Wikipedia), check it out!

    https://edmundkorley.com/mazes

  19. Marco Antônio Avatar

    Always when I see your videos in p5 I try to program the same thing but in processing because I'm learning java, and I couldn't figure out how to push, pop in java. Can anybody help me?

  20. Something Stupid Avatar

    how to make this thing start all over if all cube is visited??
    **sorry my bad english..and my new in your channel 🙂

  21. Magnus Hegdahl Avatar

    I like that you go off track sometimes. it makes it easier to follow when it is not a constant stream of information for 30 min. Best code teaching channel on the internet.

  22. cimmik Avatar

    Nice. I tried making my own without watching the tutorial and then watch it when I was done. It's very instructive to come up with own solutions and then see an alternative way to do it.
    I've tried adding several "walkers" just for fun.
    The next step is to make it 3D. I think about making a "two-layer-maze". In other words something like a 40x40x2. However, I'm not sure what the best way to visualize it is.
    Do you have any suggestions for how to visualize it?

  23. RedsBoneStuff Avatar

    Listening to this while building a huge underground maze in Minecraft 😛

  24. Newbie MC Avatar

    Hey, i need 10 minute to open the app

Leave a Reply

Your email address will not be published. Required fields are marked *