Coding Challenge #10.3: Maze Generator with p5.js – Part 3

In part 3 of the Maze Generator Challenge, using p5.js, I cover steps 3 and 4 of the recursive backtracker algorithm to generate a maze: Removing walls and marking current cell as visited.

Part 4:

Support this channel on Patreon:

Send me your Coding Challenge ideas!


Nature of Code class on Kadenze:

Source Code for this project:

Algorithm for Maze Generators:

For more Coding Challenges:

To learn more about javascript:

Help us caption & translate this video!






29 responses to “Coding Challenge #10.3: Maze Generator with p5.js – Part 3”

  1. Marcus Parsons Avatar

    I love your videos, Dan! I just found you the other day, and I've been watching nonstop all weekend haha But a much, much easier way to keep track of which wall is which (instead of tracking 0, 1, 2, or 3) is to make "walls" an open object with text based keys and set a "top", "right", "bottom", and "left" property that you can call to set a wall to false: i.e.
    a.walls.left = false;

  2. Christopher Pilcher Avatar

    A minor optimization that would probably speed this up a lot, is to only check the top and bottom walls if and only if x === 0. So you could do:

    // check x
    if (x > 0){}
    else if (x < 0){}
    // Now check y
    This way you wouldn't have to even calculate the y value if you've used x to delete some walls. This speeds the runtime up quite a bit.

  3. TeunLammerts Avatar

    Woulden't it be eazier to delete the wal in the find neighbours function Inside the if statement that determines what the function will return

  4. Le Li  Mao Avatar

    Can you do this in processing? I would love to see this in processing!!!!!

  5. Tymski Avatar

    const TOP = 0;
    const RIGHT = 1;
    const BOTTOM = 2;
    const LEFT = 3;

  6. mathis peyronne Avatar

    +The Coding Train to do the coding challenge before to see your video and then see how you do it is a great way to be better in programming,  🙂 it helped me a lot thank you very much

  7. Abdulrhman Sulaiman Avatar

    Just great!. about the walls indices you could've an enum for it or vars just to not be confused 🙂

  8. David Sayers Avatar

    Great stuff. Thank you so much for this. I was banging my head against a wall putting together a DFS assignment, and this video helped incredibly.

  9. Oguzhan Ozdemir Avatar

    I tried for the whole day trying to solve a maze that generated from here with a* pathfinding. and I'm really stuck. are you going to come back to this subject and merge these two algorithms?

  10. Calz20Videos Avatar

    me: makes a grid

    I am the one.

  11. misode Avatar

    What's the difference between triple '=' and double '='?

  12. Pavan Bansal Avatar

    When you make fun during the videos, people can't be bored of study. So don't stop having fun making these videos.
    Awesome tutorials (y)

  13. kleines filmröllchen Avatar

    at 1:30 i fully understood the algorithm without having him explain it completely

  14. Darren Hundt Avatar

    If you haven't discovered it, Atom does have a "Scroll down past last line option":)
    love the channel

  15. Jesse Llona Avatar


  16. TheWGBbroz Avatar

    That moment when you waste 30 minutes finding out that you put a '=' instead of '-' ………………………………….. #ProgrammersLife

  17. Jooyung Han Avatar

    I enjoyed the video a lot 🙂 Thank you! ← I followed the same algorithm for hexagon grid

  18. _-_ _-_ Avatar

    Love this channel, never stop! 🙂

  19. Tsuru OniNo Avatar

    Hey so on my sketch on line 39 removeWalls is not defined removeWalls( current, next); is the line under draw function

  20. Pickens Incorporated Avatar

    Thanks for this. However, my p5 is going very slowly, and I haven't altered the framerate at all. Is there something wrong? Thanks.

  21. Pedro G. Macedo Avatar

    your channel is now my favorite one on yt. you're pretty damm good! cheers from brazil!

  22. get fun Avatar

    //white space hhhhhhhhhhhhh

  23. Spen Hanley Avatar

    I tried using this but converting the code into python as the tutorial went on and it just seems to pick any random cell on the grid, I can't seem to work it out

  24. Basile Henry Avatar

    Great video! 🙂 I wanted to try it myself so I made a maze generator that works on a hexagonal grid:

  25. San Coca Avatar


  26. Irohin Avatar

    Couldn't you just create variables for each wall and assign the respectable number to the var. Instead of cooking your brain trying to remember which number is what wall hehe 😛

  27. Matthew Hoiland Avatar

    Atom has a scroll past end setting.

  28. zedjadark94 Avatar

    Not going to lie, this series has got to be one my favourite series on youtube currently, keep it up!

  29. Petar Kaser Avatar

    It doesnt seem now that way but this channel will be huge! Dont stop having fun making these videos

Leave a Reply

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