How to solve any maze
Skills:
ML Pipelines70%
Key Takeaways
The video demonstrates the flood fill algorithm, depth-first search, and breadth-first search to solve mazes, highlighting their strengths and weaknesses in finding the shortest path.
Full Transcript
You can solve a maze with your eyes closed. If you just put one hand along one wall, you will eventually reach the end of most common mazes. After a simple wall following mouse took home gold in the first finals, the goal of the maze was moved away from the edges and freestanding walls were added. Your next instinct might be to run through the maze, taking note of every fork in the road. Whenever you reach a dead end or a loop, you can go back to the last intersection and try a different path. If your last left turn got you nowhere, you'd come back to that intersection and go right instead. You can think of this strategy as the one a headstrong mouse might use, running as deep into the maze as it can and turning back only when it can't go any further. This search strategy known as depth first search will eventually get the mouse to the goal. The problem is it might not be the shortest route. The sibling to this search algorithm, breadth first search, would find the shortest path. With this strategy, the mouse runs down one branch of an intersection until it reaches the next one. Then it goes back to check the path it skipped before moving on to the next layer of intersections. So the mouse checks every option it reaches. But all that backtracking means that it's rerunning paths dozens of times. At this point, even searching the whole maze often takes less time. So why not just do that? A meticulous mouse could search all 256 cells of the maze, testing every turn and corner to ensure it has definitely found the shortest path. But searching so thoroughly isn't necessary either. Instead, the most popular micro mouse strategy is different from all of these techniques. It's a search algorithm known as flood fill. This mouse's plan is to make optimistic journeys through the maze. They simply draw the shortest path to the goal and go. When their optimistic plan inevitably hits a wall that wasn't on their map, they simply mark it down and update their new shortest path to the goal. Under the hood of the algorithm, what the micro mouse is marking on their map is the distance from every square in the maze to the goal. To travel optimistically, the mouse follows the trail of decreasing numbers down to zero. Whenever they hit a wall, they update the numbers on their map to reflect the new shortest distance to the goal. This strategy of following the numerical path of least resistance gives the floodfill algorithm its name. The process resembles flooding the maze with water and updating values based on the flow. While this algorithm isn't guaranteed to find the best path on first pass, it takes advantage of the fact that micro mice need to return to the start to begin their next run. So if the mouse treats its return as a new journey, it can use the return trip to search the maze as well. Between these two attempts, both optimized to find the shortest path from start to finish, it's extremely likely that the mouse will discover it. And the mouse will have done it efficiently, often leaving irrelevant areas of the maze entirely untouched.
Original Description
By following this algorithm you can solve any maze in the world.
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Veritasium · Veritasium · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Scientific Notation - Explained!
Veritasium
I'm Atoms (Scientific Cover of Jason Mraz's I'm Yours)
Veritasium
Scientific Notation - Example
Veritasium
What is a Force?
Veritasium
Khan Academy and the Effectiveness of Science Videos
Veritasium
Supercooled Water - Explained!
Veritasium
Galileo the Scientific Parrot
Veritasium
Radiation vs Radioactive Atoms
Veritasium
What Is Electricity? (Are You Gonna Be My Girl?)
Veritasium
Why Is Ice Slippery?
Veritasium
Impress Her With Nanodiamonds
Veritasium
Chain Drop Experiment
Veritasium
What Colour Is Most Attractive?
Veritasium
States of Matter
Veritasium
Slinky Drop Answer
Veritasium
Slinky Drop
Veritasium
Atomic Rant
Veritasium
What Is The Magnus Force?
Veritasium
A Human Being Is A Part Of The Whole
Veritasium
Spinning Tube Trick Explained
Veritasium
Where Do Trees Get Their Mass?
Veritasium
Why Do You Make People Look Stupid?
Veritasium
Gyroscopic Precession
Veritasium
How Does A Slinky Fall?
Veritasium
Spinning Disk Trick Solution
Veritasium
Does a Falling Slinky Defy Gravity?
Veritasium
Northern Lights From 100,000 ft!
Veritasium
The First Meeting of EDUtubers! ft. CGPGrey, Vsauce, Smarter Every Day, Numberphile +more
Veritasium
Free Higgs!
Veritasium
How Can Trees Be Taller Than 10m?
Veritasium
What Now For The Higgs Boson?
Veritasium
How Trees Bend the Laws of Physics
Veritasium
Paralysed Rats Made To Walk Again
Veritasium
What Could Survive An Atomic Bomb?
Veritasium
Heisenberg's Uncertainty Principle Explained
Veritasium
Why Do Venomous Animals Live In Warm Climates?
Veritasium
Veritasium Trailer
Veritasium
What Can Frogs See That We Can't?
Veritasium
World's Roundest Object!
Veritasium
Epic Slow-Mo Drum Implosions!
Veritasium
Empty Space is NOT Empty
Veritasium
Your Mass is NOT From the Higgs Boson
Veritasium
How Does a Transistor Work?
Veritasium
Bullet Block Explained!
Veritasium
How We’re Fooled By Statistics
Veritasium
Facebook Fraud
Veritasium
The Most Common Cognitive Bias
Veritasium
Anti-Gravity Wheel?
Veritasium
Anti-Gravity Wheel Explained
Veritasium
Why Trees Are Taller Than They Need To Be
Veritasium
Misconceptions About the Universe
Veritasium
Why Women Are Stripey
Veritasium
What is NOT Random?
Veritasium
Explained: 5 Fun Physics Phenomena
Veritasium
Climate Change is Boring
Veritasium
13 Misconceptions About Global Warming
Veritasium
CapitolTV's DISTRICT VOICES - District 5: Electric Sparks From Falling Water
Veritasium
Sparks from Falling Water: Kelvin's Thunderstorm
Veritasium
The Most Persistent Myth
Veritasium
The Most Radioactive Places on Earth
Veritasium
More on: ML Pipelines
View skill →Related Reads
📰
📰
📰
📰
Programming Assignments: A Complete Guide to Solving Coding Problems Faster and Smarter
Medium · Programming
Design and Validation of a Lightweight 1D CNN for Affective Touch Classification in Soft Plush Companions
ArXiv cs.AI
How I Auto-Groomed 500 Jira Tickets with ML and LLM
Medium · Machine Learning
Day 161 of Learning Java & DSA: Solving the Largest Rectangle in a Histogram Using Stack
Medium · Programming
🎓
Tutor Explanation
DeepCamp AI