Coding Challenge #10.1: Maze Generator with p5.js - Part 1

391,830
0
Published 2016-05-02
Choo choo! In this multi-part coding challenge, I create a maze generator using a depth-first search algorithm with recursive backtracking. The idea is to walk through a grid of cells, removing walls as we go to build a maze. Code: thecodingtrain.com/challenges/10-dfs-maze-generato…

🕹️ p5.js Web Editor Sketch: editor.p5js.org/codingtrain/sketches/EBkm4txSA

Other Parts of this Challenge:
📺 Part 2: Visiting Neighboring Cells:    • Coding Challenge #10.2: Maze Generato...  
📺 Part 3: Removing Walls:    • Coding Challenge #10.3: Maze Generato...  
📺 Part 4: Backtracking:    • Coding Challenge #10.4: Maze Generato...  

🎥 Previous video:    • Coding Challenge #9: Solar System in ...  
🎥 Next video:    • Coding Challenge 11: 3D Terrain Gener...  
🎥 All videos:    • Coding Challenges  

References:
🌐 Maze Generation Algorithm: en.wikipedia.org/wiki/Maze_generation_algorithm#Ra…

Videos:
🔴 Live Stream Archive:    • Coding Train Live 35: 3D Solar System...  

Related Coding Challenges:
🚂 #51 A* Pathfinding Algorithm:    • A* Pathfinding Algorithm (Coding Chal...  
🚂 #76 10Print:    • Coding Challenge #76: 10PRINT in p5.js  
🚂 #171 Wave Function Collapse:    • Coding Challenge 171: Wave Function C...  

Timestamps:
00:00 Introduction
01:15 What are we Building?
03:18 Create a Grid of Cells
08:10 Draw the 4 Walls Separately
11:03 The Anal Retentive Coder
12:30 Store the State of Walls for each Cell
15:07 Recap, See You in Part 2!

Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound

🚂 Website: thecodingtrain.com/
👾 Share Your Creation! thecodingtrain.com/guides/passenger-showcase-guide
🚩 Suggest Topics: github.com/CodingTrain/Suggestion-Box
💡 GitHub: github.com/CodingTrain
💬 Discord: discord.gg/hPuGy2g
💖 Membership: youtube.com/thecodingtrain/join
🛒 Store: standard.tv/codingtrain
🖋️ Twitter: twitter.com/thecodingtrain
📸 Instagram: www.instagram.com/the.coding.train/

🎥 Coding Challenges:    • Coding Challenges  
🎥 Intro to Programming:    • Start learning here!  

🔗 p5.js: p5js.org/
🔗 p5.js Web Editor: editor.p5js.org/
🔗 Processing: processing.org/

📄 Code of Conduct: github.com/CodingTrain/Code-of-Conduct

This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecodingtrain.com/issues/n…

#maze #recursion #backtracking #depthfirstsearch #p5js #javascript

All Comments (21)
  • @DePistolero
    5 seconds into the video, liked, 6 seconds, subscribed, 7 seconds noticed the amount of the videos suggested on the right... Where have you been all my life :) ?? Thank you.
  • From the future here! This is f**ing good man! Honestly your way of teaching is fabulous.
  • @RedsBoneStuff
    I really like the fact that you generate a maze where with actual walls for walls, rather than one with squares for walls.
  • @KDChenStudio
    Man, i feel so much fun following the way how you approach the solution.
  • @Danicker
    16 minutes and he creates a gird... Jks it would take me 16 minutes to get the line to be white. You are very talented!
  • @WoodyPembs
    Your video (its the first one I've seen) is really helping wake up my 'programming brain'. I used to write code pretty much as easily as writing a shopping list, but that was thirty years ago! I've set myself the task of creating a dungeon game and been thinking about maze generation. Books are fine but your clear presentation style (particularly the shared thought processes) are getting my head back into gear better than hours of reading have done. Thanks!
  • @Insanesurf
    Haha I almost died when you went "top, middle, right, wait...", despite having done the silly song trying to remember the correct order xD. Great videos BTW, subscribed.
  • @BlueDayReborn
    Subbed, you sir are the most amazing programming mentor! Thanks!
  • @khineaindray
    Your video did really help me. I wish I would have watched this first before finding in somewhere else. And the way you explain was amazing and it's easy to understand. Thank you so much.
  • @ScienceGuides
    Returning to this video long after seeing it the first time. :-) I really enjoy your library of videos. It helps being creative with programming, to see your examples, and in this case, I actually needed a way to generate mazes. THANK YOU! Best regards - Søren
  • @SkyenNovaA
    A simple and fun way to explain maze generation, thanks!
  • @ResetBox15
    You're exactly what I look for. Explain only what to explain and quickly, without mince words
  • While I primarily code in Java, I've been drawn to these because you're just so energetic! You always describe what you're doing so well, but I was wondering if you could do a series on Java programming? I'm inexperienced with coding in general, and I've been using your videos to learn. Thank you!
  • I love these Coding Challenges, I don't know how to code, but It's still very fun to watch!
  • @milkyroad9593
    Hey Daniel. Greetings from Germany. I love your videos. Programming + humor. "We're getting somewhere - eventually" hahaha. Keep doing your videos please.
  • Daniel your videos are just awesome. You are the reason i switched from electrical engineering to computer science. Love you man, keep up the good work :).