The Lightning Algorithm - Numberphile

Поделиться
HTML-код
  • Опубликовано: 30 сен 2024
  • Matt Henderson is making lightning in mazes.
    Check out www.kiwico.com... and get 50% off your first month of any subscription.
    More links & stuff in full description below ↓↓↓
    More videos with Matt: bit.ly/MattHen...
    Follow his work on Twitter at: / matthen2
    Maze solving on our sister channel, Computerphile: • Maze Solving - Compute...
    Numberphile is supported by the Mathematical Sciences Research Institute (MSRI): bit.ly/MSRINumb...
    We are also supported by Science Sandbox, a Simons Foundation initiative dedicated to engaging everyone with the process of science. www.simonsfoun...
    And support from Math For America - www.mathforame...
    NUMBERPHILE
    Website: www.numberphile...
    Numberphile on Facebook: / numberphile
    Numberphile tweets: / numberphile
    Subscribe: bit.ly/Numberph...
    Videos by Brady Haran
    Patreon: / numberphile
    Numberphile T-Shirts and Merch: teespring.com/...
    Brady's videos subreddit: / bradyharan
    Brady's latest videos across all channels: www.bradyharanb...
    Sign up for (occasional) emails: eepurl.com/YdjL9

Комментарии • 1 тыс.

  • @numberphile
    @numberphile  3 года назад +90

    Check out www.kiwico.com/Numberphile and get 50% off your first month of any subscription.
    Previous video with Matt (Chaotic Balls): ruclips.net/video/6z4qRhpBIyA/видео.html

    • @scurvydog20
      @scurvydog20 3 года назад +4

      You could make this simulate lightning more accurately by giving the grid squares different weights to represent conductivity.

    • @jitgtij
      @jitgtij 3 года назад +1

      If you know both gates and approach from both sides, that will have even faster convergence.

    • @Typical.Anomaly
      @Typical.Anomaly 3 года назад +2

      Have you guys ever heard of a game called "Plinko" on the US game show "The Price Is Right"?
      If so then you should know why I mentioned it lolol
      (Always remember to have your pets spayed or neutered!) 😁

    • @picobyte
      @picobyte 3 года назад +1

      Real lightning an actually branch out both at ground level and the clouds as main channel sets up, cascades of charge want to flow there, it's like kicking a huge bucket of charged capacitors resistors and coils.

    • @alanthesuperhero
      @alanthesuperhero 3 года назад

      Why did you put an amogus in the thumbnail???

  • @Pulsar77
    @Pulsar77 3 года назад +1812

    Back in the day when we needed screen savers, this would've been really nice.

    • @bretscofield
      @bretscofield 3 года назад +38

      My thought was this would be a great like Windows 95 or Windows 98 screensaver.

    • @Pulsar77
      @Pulsar77 3 года назад +7

      @@bretscofield Yep, brings back memories.

    • @exod4
      @exod4 3 года назад +44

      Screen savers are gonna make a come back with oled monitors

    • @xxgn
      @xxgn 3 года назад +45

      As-is I don't think this would be a suitable screen-saver. This would risk burning in the walls since they're both high intensity and positioned inconsistently. Also, the middle of the monitor is exercised more than the left and right edges.
      Mind you, it wouldn't be hard to tweak this to remove those issues.

    • @feandil666
      @feandil666 3 года назад +22

      the CPU would have been at 20% all the time trying to do the calculation in a reasonable time :)

  • @wouterlahousse9637
    @wouterlahousse9637 3 года назад +445

    Just watching numberphile not to miss out on the cat and dog cameos

    • @vigilantcosmicpenguin8721
      @vigilantcosmicpenguin8721 3 года назад +25

      The channel is made to feature mathematicians, but we know who the real special guests are.

  • @onion013
    @onion013 3 года назад +1190

    "This was done in Mathematica" - I was half-expecting the code to be something like PlotLightning2D[100, 100] given how extensive Mathematica's libraries are :)

    • @PhilBoswell
      @PhilBoswell 3 года назад +55

      Give it a bit and it might well be ;-)
      Is there an open-source equivalent to Mathematica? I feel like there should be, and this should be part of it.

    • @cybisz2883
      @cybisz2883 3 года назад +17

      @@PhilBoswell GNU Octave is the closest thing I know of.

    • @timseguine2
      @timseguine2 3 года назад +40

      @@PhilBoswell Sage is kind of like Mathematica. GNU Octave that was suggested is more like MATLAB.

    • @gcewing
      @gcewing 3 года назад +8

      There's probably a command for it in Emacs.

    • @timseguine2
      @timseguine2 3 года назад +6

      @@combatcorgiofficial For what the guy in this video uses it for, I agree. But it is actually pretty great as a computer algebra system.

  • @hawsroy
    @hawsroy 3 года назад +792

    this looks like it should be in a science museum somewhere in high detail on a huge wall, accompanied by huge flashes. i’d pay to see that

    • @gamen8209
      @gamen8209 3 года назад +7

      Make it!! And put it in a modern art Museum instead 🤩

    • @mayabartolabac
      @mayabartolabac 3 года назад +16

      @@gamen8209 as much as i want to, those snobs will never appreciate art that actually took effort

    • @t.c.bramblett617
      @t.c.bramblett617 3 года назад +5

      I'd like it to be a screensaver!

    • @kingk2405
      @kingk2405 3 года назад

      Or in my shower .

    • @SlampthChompth
      @SlampthChompth 3 года назад +8

      Dude that's genius. Have a continuous cycle of randomly generated mazes, and just have them keep going like that, and make it look even more like lightning. Just like a digital portrait on the wall that keeps going, producing lightning. And the occasional null ones would just amount to a few seconds of no lightning. Which would also emulate the incontinence of real world lightning strikes. Should also randomize the time between rolls.
      Dude build this I'll buy one.

  • @Arctic_Narwhal
    @Arctic_Narwhal 3 года назад +268

    Animations of search algorithms are always so fun to watch

    • @pvic6959
      @pvic6959 3 года назад +2

      I agree!!

    • @GRAYgauss
      @GRAYgauss 3 года назад

      thats why i like doing acid

    • @trinidad17
      @trinidad17 3 года назад +2

      Yeah and the hard part here is actually making the animation.

    • @poppop-oj6by
      @poppop-oj6by 3 года назад

      I like animations of sorting algorithms even more

  • @greatquux
    @greatquux 3 года назад +612

    Perhaps a “tie” in the real world leads to forked lightning

    • @OriginalPiMan
      @OriginalPiMan 3 года назад +81

      Kinda. Because of how electrical resistance works, the energy will mostly travel on the shortest path (or rather, the path of least resistance), including splitting equally between equal paths, but energy will also follow less efficient paths albeit a lower magnitude of energy.
      In the end, the energy will follow every path to some degree, as long as the resistance is not too great such that the travel is impossible.
      (Or at least, that's what I remember from science classes and electronics classes years ago).

    • @RFC-3514
      @RFC-3514 3 года назад +57

      Doesn't have to be a tie; lightning isn't binary like in these animations (i.e., it doesn't follow a single path), some of it discharges into the air itself, and a lot of "side paths" never actually light up (there is always a lot of forking, most of it is just hard to see).

    • @OriginalPiMan
      @OriginalPiMan 3 года назад +24

      @@RFC-3514
      Yeah, and even when two forks visibly hit something, there will usually be one brighter one and one dimmer one.

    • @CallousCoder
      @CallousCoder 3 года назад +5

      That’s true, electricity takes the path of least resistance. So when two paths are equal, the same amount of current goes left and right. If a path is more resistant, less current can- and will move through that path. When there’s no way to ground, there will be no current going that way.

    • @EebstertheGreat
      @EebstertheGreat 3 года назад +29

      Also, just in general, the physics of lightning are not very similar to the mathematics of maze solving by breadth-first search. This algorithm is really a demonstration of a breadth-first search, not of lightning, but it looks a bit like lightning so that makes for a catchy name.
      Lightning strikes are much more complicated and involve the formation of "leaders" connecting adjacent regions of different charge. For instance, a more negatively charged part of the cloud adjacent to a more positively charged part can form a leader between them, equalizing the charge. If the charge is still not equalized, these leaders can continue to spread, and to branch, repeatedly equalizing charges of adjacent areas. If the leader escapes the cloud and there is still a large charge separation, it can travel between the cloud and the ground. Usually, the leader comes down from the cloud and up from the ground at the same time. In some conditions, it can also form between the two in the lower troposphere. Once a connection is made between the ground and the cloud, air is so ionized that an extremely low-resistance channel is created, and a huge current is produced, which heats the air into a glowing plasma that looks like lightning. So it's a lot more chaotic than a breadth-first search, and it isn't just going from one end to the other.
      Lightning that strikes the ground is not branched (though branched lightning can get relatively close to the ground, so this isn't always obvious visibly). Typically, once the downward and upward streamers attach, a single connection is made and that's where you see the bolt. There are usually several flashes in close proximity (a couple tenths of a second), as the same ionized channel is used again and again to discharge different parts of the cloud. Until the ionized channel disperses, it will always be by far the lowest resistance path to the ground, and the current will follow it almost exclusively.

  • @florianlipp5452
    @florianlipp5452 3 года назад +285

    the effect of different values for p and q would have been interesting.
    Higher q values in particular might lead to more twisted paths, detours (going back up for some time) etc.

    • @alpardal
      @alpardal 3 года назад +10

      He did mention he uses different values for p and q to make it so vertical paths are more likely than horizontal ones

    • @MrDoctorDen
      @MrDoctorDen 3 года назад +1

      Should p+q = 1 tho?

    • @faelyn5770
      @faelyn5770 3 года назад +14

      @@MrDoctorDen No not at all, p and q are probability for two different things that are not really connected. p+q only needs to be one if p and q are probabilities for opposite events.

    • @MrRyanroberson1
      @MrRyanroberson1 3 года назад +5

      Though you don't want the probability too high in total, so maybe p+q=1 is a nice constraint in the first place

    • @gcewing
      @gcewing 3 года назад

      An interesting challenge would be to find the probablity of the maze being unsolvable for a given p and q.

  • @chris9012
    @chris9012 3 года назад +257

    I'd love to see a version with hexagon-tiling.

    • @R_V_
      @R_V_ 3 года назад +32

      Or 3D space tiling.

    • @BooyahL
      @BooyahL 3 года назад +14

      He showed the code (maybe on his Twitter he even shared it!) so you can try it yourself :)

    • @LittleKitBirkl
      @LittleKitBirkl 3 года назад +19

      You could try looking for A* pathfinding in hexagonal space. You might have some luck there.
      In essence (or rather in code) a hex grid is a square grid where every second row is offset by 1/2 (I think) and you have to then treat 6 cells as neighbours instead of just 2.

    • @damien4197
      @damien4197 3 года назад +30

      Well, they are the bestagons, after all.

    • @FINALLYQQQQAVAILABLE
      @FINALLYQQQQAVAILABLE 3 года назад +3

      @@LittleKitBirkl The same A* search algorithm works on any graph. Rectangular, hexagonal, 3D, whatever. A skilled programmer would write the search algorithm once and then just apply it for different kind of graphs.

  • @penny3577
    @penny3577 3 года назад +159

    I can only assume CGP is somewhere screaming: "make them hexagons, not squares!"

    • @spv420
      @spv420 3 года назад +2

      CGP*

    • @HoSza1
      @HoSza1 3 года назад +1

      what is a cgp?

    • @leadnitrate2194
      @leadnitrate2194 3 года назад +20

      @@HoSza1youtuber cgp grey, he's a big fan of hexagons

    • @spv420
      @spv420 3 года назад +1

      @@HoSza1 cgp grey

    • @penny3577
      @penny3577 3 года назад +1

      @@spv420 yep...thank you, didn't realise I spelt it wrong lol

  • @krakenwarrior3237
    @krakenwarrior3237 3 года назад +44

    They could have called this the "Following the Droplet Down the Car Window as a Child" Algorithm, but I guess it doesn't have the same ring to it.

    • @realitant
      @realitant 3 года назад +2

      The droplet doesn't go up though

    • @david203
      @david203 3 года назад +2

      @@realitant It can if the car or the surrounding air is moving! Usually, all of the droplets move in a common path modified by an interesting randomness.

    • @Just_a_user3
      @Just_a_user3 3 года назад +1

      Thank you for reminding me of this. I had forgotten how much I enjoyed watching the droplets slide down.

    • @esquilax5563
      @esquilax5563 3 года назад

      The droplet would use a greedy algorithm

    • @david203
      @david203 3 года назад

      @@esquilax5563 Are you referring to how moving droplets combine with stationary droplets to increase in size? Yes, that is interesting.

  • @TheOcram2000
    @TheOcram2000 3 года назад +125

    I'm a chemist and this is fairly accurate actually. The electrical charge has to pick the oxygen molecules with the proper alignment of their double bonds (pi orbital) to create ozone and still reach the ground ASAP

    • @ebrelus7687
      @ebrelus7687 3 года назад +7

      Quite educative comment for a komunist! Well done! Like communisation of the most individuals by fear while murdering as many on road as possible in shortest time!

    • @ImaginaryMdA
      @ImaginaryMdA 3 года назад +28

      @@ebrelus7687 Have fun with your capitalist "healthcare". ;)

    • @RFC-3514
      @RFC-3514 3 года назад +30

      It's not _accurate_ at all. Real lightning forms a lot of forked paths, and starts discharging through all of them, at varying rates. The drop in resistance eventually causes one path (sometimes with some visible forking) to heat up, become dominant, and form plasma, but these animations aren't even trying to simulate that. Also, there are no hard barriers forming a predefined path in the air; the formation of the lightning strike itself rearranges the "maze" dynamically.
      It's a nice-looking approximation that gets across the point of "path of least resistance", but it doesn't even attempt to simulate the real-world mechanisms involved in lightning strikes, let alone do it accurately.

    • @idkman-rr3bm
      @idkman-rr3bm 3 года назад +7

      Spoken like a true chemist..ry student.

    • @Frosty-oj6hw
      @Frosty-oj6hw 3 года назад +1

      It is actually surprisingly accurate in a few ways. Lightning doesn't just strike immediately, it has Leaders which kind of explore the environment much the same way as the code checking for the fastest route, many of them fork through the air finding a path from one pocket of charged ions to another (normally cloud to ground). The leader which connects a path first is where the full discharge actually travels. With one minor difference, when leaders get near pockets of opposite charges on the ground it causes leaders of opposite charge to actually leave the ground and travel up, where they eventually connect forming the whole path, and the full discharge happens along that path.

  • @strangeWaters
    @strangeWaters 3 года назад +97

    I wonder if the lightning strikes end up normally distributed along the bottom

    • @drakoz254
      @drakoz254 3 года назад +4

      This is a really interesting question. Seems like modelling the maze as a random graph is your best bet to approach a solution.

    • @vezepheros3895
      @vezepheros3895 3 года назад +6

      My intuition tells me the points in the middle would be more likely to be the solution than the side points

    • @krzysztofq7420
      @krzysztofq7420 3 года назад

      I guess so

    • @drakoz254
      @drakoz254 3 года назад +3

      The algorithm preferentially chooses the shortest path, right? So if we suppose that each "bottom" node is acessible with probability a, and in every round, the algorithm chooses the acessible node with the shortest distance to the top (and therefore, the node closest to the center on average), does that process lead to a normal distribution? Sure feels like it does, but we have abstracted away the maze in the middle here so maybe that plays a bigger role.

    • @pyglik2296
      @pyglik2296 3 года назад +3

      It may be binomial, just like in galton board, where at each level you're equally likely to turn left or right.

  • @Truth-Spoken
    @Truth-Spoken 3 года назад +4

    from "301 views" video

  • @ciscoortega9789
    @ciscoortega9789 3 года назад +39

    This looks amazing! Such simple ideas but the combination of them together is absolutely brilliant!

  • @31337flamer
    @31337flamer 3 года назад +62

    this is what i do everyday xD making sims that have no purpose but look satisfying :D trying out algorithms

    • @bootje99
      @bootje99 3 года назад +9

      thought you were talking about the Sims (the game) 😂

    • @macronencer
      @macronencer 3 года назад +7

      Can relate to this. I'd do that too if I had the time! I have a busy life, but sometimes I do get to play with code... I spent months on and off working on an algorithm to generate near-optimally-compact patterns that encode words (so basically steganography). In the end, I cracked it using simulated annealing, and it was so satisfying! I made a pattern for my own name and got Vistaprint to put it on a mug. Every time I use that mug I remember the feeling of solving the problem, and it's pretty nice.

    • @asailijhijr
      @asailijhijr 3 года назад

      @@bootje99 that is approximately the source of the name of (the (species of) characters in) that game.
      They were originally the inhabitants of the cities in a different game by the same publisher: Sim City.

    • @Games_and_Music
      @Games_and_Music 3 года назад

      Powder, named after that 90s movie about that guy that got hit by lightning?

    • @david203
      @david203 3 года назад +1

      I used to get software jobs by entering a three-instruction program to simulate a waterfall by displaying a parabola with errors due to overflow.

  • @PW_Thorn
    @PW_Thorn 3 года назад +15

    To improve this algorithm (generating random map), instead of generating randomly a new map in case it is not solvable, you can just add holes, level by level, randomly. It will then end solvable in a deterministic way instead of crossing finger to avoid that bad luck appears continuously. And we can notice that a randomly generated map with random holes added is still a random map !

  • @vanderkarl3927
    @vanderkarl3927 3 года назад +26

    I click on the video, instantly there is a cat. I am satisfied with the content of the video.

    • @seldom_bucket
      @seldom_bucket 3 года назад +4

      Glad it wasn't just me.

    • @teleny2
      @teleny2 3 года назад +1

      @@seldom_bucket It's the view of the cat as well. Showing his nether star, as it were.

  • @yobgodababua1862
    @yobgodababua1862 3 года назад +81

    I'm surprised there was no mention of how A* (The king of pathfinding) basically combines naiive breadth-first with an arbitrary "fitness metric" (just like you used here to color the wavefront) to guide the selection of which border nodes to search next.

    • @leeboehmer6793
      @leeboehmer6793 3 года назад +1

      Eh?

    • @MrRedwires
      @MrRedwires 3 года назад +9

      I was really about to ask in what way this algorithm here is in any way special or interesting.
      It feels like the only thing they really added was a colouration of the search-front, but the algorithm itself is... Really the most basic thing they could've done, and to me it just felt like a more basic A*

    • @MattMcConaha
      @MattMcConaha 3 года назад +10

      @@MrRedwires it wasn't A* at all, it was just a basic breadth first search. A* uses a heuristic measure to only continue searching down paths which have a chance at being the best. In this implementation, the code always follows every path (all paths are always at the same depth, and every instance of that depth is accounted for) and then just stops when one of them finishes. In A*, the heuristic measure would probably just be the height value, and a path would only be continued if its current depth plus height were less than the any other depth plus height combination. Or some similar calculation.
      Off the top of my head I'm not sure if A* is defined in such a way that the heuristic must result in the optimal solution or not, but the heuristic I described would guarantee it. The full breadth first search also guarantees optimality, though with less efficiency.

    • @killerbee.13
      @killerbee.13 3 года назад +2

      @@MattMcConaha A* works (it finds the shortest path) even with a bad heuristic, but it performs worse. In this example, that would mean it explores more of the maze before finding the end. From what I can tell it actually loses its performance guarantees entirely depending on just how bad the heuristic is, though I assume that such bad heuristics are pretty unlikely because one had to be deliberately constructed by computer scientists for their proof, because it had never come up in practice.

    • @framegrace1
      @framegrace1 3 года назад +2

      ​@@MattMcConaha A* guesses and backtracks if can't continue. This follows every path and stops when can't continue... Appart of that, I would say the heart of the algorithm is basically the same. A* doesn't guarantee optimal path, (doing it in linear time like A* would be a Nobel at least...:) )

  • @python-programming
    @python-programming 3 года назад +39

    I love lightning and I love numbers, so this is basically my new jam.

  • @elraviv
    @elraviv 3 года назад +39

    there is an algorithm to generate solvable mazes. you add random length lines one by one vertically and horizontally, but they can connect to other lines only at one point. so basically there are no blocking lines but the way around them can be long.

    • @lonestarr1490
      @lonestarr1490 2 года назад +2

      Yes. But in such a maze a breadth-first search wouldn't look that interesting, I suppose.

  • @cosmo1248
    @cosmo1248 3 года назад +7

    Bottom left of the thumbnail is sus

    • @piyushv5739
      @piyushv5739 3 года назад

      yo wtf how did u see it 😂

    • @propername4830
      @propername4830 3 года назад

      🤮🤮🤮🤮🤮🤮🤮BLEUUURRRGGGHHH

  • @teddyboragina6437
    @teddyboragina6437 3 года назад +3

    CAT! I saw a cat

  • @muffinman2546
    @muffinman2546 3 года назад +14

    I wonder how a hexagonal maze would turn out.
    Given the complexity of having more walls on more sides and given that it will never go straight horizontal and have lots of diagonals.

    • @lonestarr1490
      @lonestarr1490 2 года назад

      I guess the lightnings would turn out like parts of a Sierpinski arrowhead.

  • @XtraZawZ
    @XtraZawZ 3 года назад +3

    Hello 301 veiws

  • @stapler942
    @stapler942 3 года назад +38

    So every time lightning *doesn't* strike the Earth, it's just because the air and charge distribution has been configured as an unsolvable maze...

    • @official-obama
      @official-obama 3 года назад +6

      That’s because the path is long, and the voltage wears off.

    • @sleeptyper
      @sleeptyper 3 года назад +3

      That or the algorithm became sentient and decided that it was better to solve between side boundaries (cloud to cloud).

    • @pinaz993
      @pinaz993 3 года назад +7

      Nah. If you put enough electrons into a make like that, they stop respecting walls.

    • @stetai352
      @stetai352 3 года назад

      So basically weighted walls that need a higher number of ticks to be penetrated (to simulate higher resistance of air that could be overcome if the voltage was high enough)

    • @framegrace1
      @framegrace1 3 года назад +1

      @@stetai352 Or start by a number proportional to the voltage and decrease it on every step instead of increasing it. When the number reaches 0 the search stops. More resistant air would be equivalent to a more complex maze.

  • @Ak47andre
    @Ak47andre 3 года назад +5

    it didn't even freeze at 301 :D

  • @matthenderson1672
    @matthenderson1672 3 года назад +3

    Summary:
    1. A cat! Yes, a cat! I saw Mochi the cat!
    2. Something about lightning

  • @valeriecoronado8713
    @valeriecoronado8713 3 года назад +4

    Pov: your here from the 301 yt vid

  • @johnchessant3012
    @johnchessant3012 3 года назад +26

    Pretty sure I can do that in one line of Python after "import lightning" ;)

    • @jansenart0
      @jansenart0 3 года назад

      Well you can, now.

    • @DaveWhoa
      @DaveWhoa 3 года назад +1

      instead of traversing a maze you could simply select one of three random numbers for each iteration ... eg. 0 = left, 1 = down, 2 = right

    • @mbrusyda9437
      @mbrusyda9437 3 года назад

      @@DaveWhoa sounds like it'll get stuck

    • @Alexander_Grant
      @Alexander_Grant 3 года назад

      @@mbrusyda9437 Don't think it would be as pretty as this animation, but it wouldn't get stuck, it'd have a 1/3 chance to move down each time and wouldn't go back up.

    • @mbrusyda9437
      @mbrusyda9437 3 года назад +1

      @@Alexander_Grant that's the thing, if you get into a square like |__|, you need to go back up

  • @mho9296
    @mho9296 3 года назад +4

    i’m here from the video 301

  • @sussybawka9999
    @sussybawka9999 2 года назад +2

    This particular BFS algorithm is called Lee's algorithm iirc.

  • @buggs4350
    @buggs4350 3 года назад +3

    How is your video still froze on 301

  • @krzysen8255
    @krzysen8255 3 года назад +2

    Only i watched the freeze of 301 views and checked if this channel still alive 🗿

  • @Veptis
    @Veptis 2 года назад +3

    Learned about this guy through twitter. After I followed I searched for any features on Numberphile. And there were some in my watch later. Glad I am here now.
    Making beautiful maths visualizations is really something outstanding and that is the only piece that is missing from some of the lectures I have.
    Therefore for anything I present or teach - having a beautiful visualisation is something I strife for.

  • @RFC-3514
    @RFC-3514 3 года назад +1

    I guess this is why so many scientists just stay in their field and don't even try to communicate with the public.
    Scientist: "I wrote this program to show how a search algorithm works, visually, and I think it looks pretty cool, a bit like lightning."
    Person A: "Hey, look, he made a lightning simulator!"
    Scientist: "No, no, it's not even trying to do that. It's just an animation based on a search algorithm."
    Person B: "Lightning! Cool! I always wondered how it worked."
    Scientist: "No, really, I just said it _looks_ a bit like..."
    Person C: "I work in [insert unrelated but sciency-sounding field here] and this is really accurate."
    Person D: "So many climate scientists wasting taxpayer money and this guy solves it in 12 minutes. Bravo!"
    Person E: "I showed this to my children, now they understand exactly how lightning works."
    Scientist: "I..."
    Everyone: *"Lightning simulator! Lightning simulator!"*

  • @reedplaysgames
    @reedplaysgames 3 года назад +11

    I could watch a bunch of these mazes for hours and not get bored

  • @backpackmc
    @backpackmc 3 года назад +1

    The topic and content are far below the usual level. It's nothing to do with modelling, or lightning. As maze solving goes, there's nothing special here either. OK, Mathematica produced an animation, but it's hardly Mandlebrot is it.
    Really guys, if you're going to do basic Discrete Maths / CompSci, then at least make an effort to really explain what's going on, and -why- searching algorithms are breadth-first, or depth-first, or heuristic-based. Huge scope to explore relevance to AI and machine-learning, optimising logistics and computer networks, and consider how quantum computing algorithms are a whole new paradigm for this topic.

  • @pcfilho425
    @pcfilho425 3 года назад +6

    Numberphile and lightning, what a perfect combination. :)

  • @richmondmagaris2215
    @richmondmagaris2215 3 года назад +2

    oh i thought all of your videos have only 301 views lol😂

  • @audio_collage
    @audio_collage 3 года назад +4

    hey 301 views guy)

  • @Ksorkrax
    @Ksorkrax 3 года назад +1

    In terms of the solveability issue, why not simply make edges not being completely blocking but rather slower to overcome? Like two cells with an edge between having distance two instead of distance one. BFS can easily handle different distances.
    One could even play around with several possible distance values. If they are discrete with a common divider, or even better small whole numbers, the algorithm would stay very simple to implement.
    Another idea: Give the search algorithm an "energy value" it starts with, and everytime it divides at some point, it splits of that value for the different directions. Every cell stores the value it was entered with, and it is used to light the cell during the search.
    This would make it look even more like a real lightning, which is weakly visible during the "search".
    Although I'm not sure whether this really produces this effect. It seems to me that the real lightning doesn't actually try out all paths like BFS does. More like something that begins as a single DFS that at some point branches off, working as two DFSes in parallel, which can branch off themselves recursively. (With all DFSes sharing the same Visited table/set.)
    And another one: If I recall correctly, a real lightning also "searches" from the bottom, to a lesser degree. Maybe also include that, with the algorithm for the bottom only iterating once for several steps of that of the top. Not sure whether that would make a difference for the result, though, but certainly would look differently while searching.

  • @timothywaters8249
    @timothywaters8249 3 года назад +9

    In reality, the "maze" changes as lightning travels to ground. How would you solve it if the maze was also changing randomly at each step?

    • @DaveWhoa
      @DaveWhoa 3 года назад

      instead of traversing a maze you could simply select one of three random numbers for each iteration ... eg. 0 = left, 1 = down, 2 = right

  • @DroseACL
    @DroseACL 3 года назад +2

    POV:you came from the 301 video

  • @gunshotZ712
    @gunshotZ712 3 года назад +3

    Anybody coming here from the 301 veiws video?

  • @VideoNOLA
    @VideoNOLA 3 года назад +1

    If you enclose the maze in a slightly larger square, and use a graphics paint program to "fill" the negative space, you will always find at least one path that connects "in" and "out". Much faster than this technique.

  • @diaz6874
    @diaz6874 3 года назад +7

    *Dude explains the beauty of the visuals created by the algorithm *
    Brady: *C A T*

  • @HotGammiris
    @HotGammiris 3 года назад

    301 channel prodigy

  • @sunongral5605
    @sunongral5605 3 года назад +3

    I can't hardly explain how satisfying I find the animation! With that little sound! I'm a simple person, I see lighting and I'm hooked for as long as physically possible.

  • @asn07
    @asn07 3 года назад +2

    pls tell the total views of the 301 VIEWS video

  • @notmyname327
    @notmyname327 3 года назад +5

    I love Matt's maths visualisations

  • @zostay23
    @zostay23 3 года назад +1

    Ties should fork.

  • @nowandtenofficial
    @nowandtenofficial 3 года назад +23

    Well try making the same with a 3d labyrinth and thereby getting an actual lightening in a 3Dd space

  • @Funnylegend15
    @Funnylegend15 3 года назад +1

    Anybody here after watching the " why do RUclips view freeze at 301?" Video?

  • @4815162342o
    @4815162342o 3 года назад +3

    Нейроны места таким способом находят путь до целевой точки в пространстве.
    In the same way, the place cells find a way to the target point.

  • @skylark.kraken
    @skylark.kraken 3 года назад +1

    Fun fact the difference between a labrynth and a maze is that a labrynth doesn't have dead ends (although the definition is loose, is a dead end with length 1 really a dead end?)

  • @fundayswithfox6706
    @fundayswithfox6706 3 года назад +3

    Seems like the sidewinder algorithm would be helpful for maze generation, there is always at least 1 path that goes downwards so you never get stuck.

  • @Fozorrider420
    @Fozorrider420 3 года назад +1

    🙏 রোজাটা চলে গেলো তবুও নামাজটা ধরে রাখুন তাতে অনেক লাভ আছে ❤️

  • @stephencurry_goldenstatewa6430
    @stephencurry_goldenstatewa6430 3 года назад +3

    I still remember 301 views

  • @deviatefishy
    @deviatefishy 3 года назад +1

    I'd like to hang this on my wall, like moving art.

  • @beirirangu
    @beirirangu 3 года назад +3

    If you've ever seen slow-motion footage of lightning, you'd see it's surprisingly similar

  • @boredianz
    @boredianz 3 года назад +1

    For some reason RUclips views keep on freezing at 301. You should do a video on that, and why it does.

  • @uncountablehey3346
    @uncountablehey3346 3 года назад +3

    Not sure which is more beautiful, the mathematics or the cat.

  • @vvsiva007
    @vvsiva007 3 года назад +1

    At the same time, if you do the bread-first from bottom to top, then try making both these meet at a point, then it will be quickest.

  • @ericvilas
    @ericvilas 3 года назад +7

    I mean it sounds pretty close to how lightning actually works, to be fair, if we consider each step of the process to have a probablility of its neighbors being ionized or not. The only thing that seems to need tweaking is the probabilities and maybe instead of a yes/no wall having something more continuous? But I'm not a meteorologist, so I'm not sure.
    Still, really interesting.

  • @shabeeeb6400
    @shabeeeb6400 3 года назад +2

    You are here to check 301 views :)

  • @bigcountrymower4263
    @bigcountrymower4263 3 года назад +3

    "The cat helps MEOWt". Idk if that pun was intentional, but it was good.

  • @shrteng6856
    @shrteng6856 3 года назад +1

    Bread-First-Search, Death-First-Search, Breakfast-Search.

  • @user-iu1xg6jv6e
    @user-iu1xg6jv6e 3 года назад +3

    Maybe giving each two adjacent boxes a weight to go from each to another, then find the path with the minimum weight!
    I don't know, but in my opinion it seems more likely to how lightning happens!

    • @MrRyanroberson1
      @MrRyanroberson1 3 года назад

      With a large enough grid, it will take on that behavior, I'm pretty sure.

  • @honorablemonkey
    @honorablemonkey 3 года назад +2

    Why does this video have over 301 views?

  • @Fiifufu
    @Fiifufu 3 года назад +3

    Such an interesting character this one. Hope to see more of his stuff✌🏻

  • @sarysa
    @sarysa 3 года назад

    Please believe me when I say I'm not trolling when I say this...I mean it as a genuine critique:
    That sound effect at 4:16, and onward as numbers are revealed, sounds like a burp. I was watching this in the background and thinking to myself, "where are those burps coming from?" First thought it was a game I had running, but nope...it was this video.
    It could be a headphone quality thing...but yeah, not a great sound effect. Though it did take me from annoyance to laughter pretty quickly. ;)

  • @sehr.geheim
    @sehr.geheim 3 года назад +3

    If this is how lightning actually works (he didn't claim it, but let's hypothecise) electricity isn't gnostic, how would it know the path?

    • @millwrightrick1
      @millwrightrick1 3 года назад +1

      The same way a ball held in your hand knows where to fall when released. It is the lowest energy path.

    • @sehr.geheim
      @sehr.geheim 3 года назад

      @@millwrightrick1 kinda makes sense, but I should probably go on r/AskScience to fully get it

    • @OriginalPiMan
      @OriginalPiMan 3 года назад +1

      Electricity follows every path that does not have too much resistance. So if three paths have resistances of 1000 Ω (ohm), 5000 Ω, and 1,000,000 Ω, then most of the energy will go down the 1000 path, some down the 5000 path, and likely none down the 1,000,000 path.

    • @RFC-3514
      @RFC-3514 3 года назад +4

      This is not how real lightning works, and electricity doesn't follow a single path anyway. If you look at super slow motion video of lightning strikes you'll see it follows a lot of different paths, and the reason why one becomes (a lot) brighter is that resistance starts to drop, making that path preferable.

  • @mnix5701
    @mnix5701 3 года назад +2

    Who’s here from the 301 views vid

  • @nothingnewhere6551
    @nothingnewhere6551 3 года назад +9

    I like the examples this guy presents. Always something cool going on with you guys!

  • @alextemplet
    @alextemplet 3 года назад +2

    I knew this was going to be a great video as soon as I saw the cat butt.

  • @RueBRed
    @RueBRed 3 года назад +3

    301 views

  • @Abdullah_Khan25
    @Abdullah_Khan25 3 года назад +2

    I was here after seeing his 301 views video

  • @Walking_Death
    @Walking_Death 3 года назад +6

    Matt: This is how to model a lightening strike.
    Cat: Here is my butthole.

  • @KilgoreTroutAsf
    @KilgoreTroutAsf 3 года назад +1

    I believe these kind of phenomena are studied in Percolation theory.

  • @craft_gamer5035
    @craft_gamer5035 3 года назад +3

    301

  • @n0mad385
    @n0mad385 3 года назад +1

    I saw that suspicious looking 2x3 cell block in the thumbnail

  • @Stereotype3
    @Stereotype3 3 года назад +6

    I absolutely love these videos with Matt Henderson! He's got such a nice way of speaking, I'm completely zen after watching

  • @unknownrookie4619
    @unknownrookie4619 3 года назад +2

    this proves we live in a simulation

  • @aukeholic1
    @aukeholic1 3 года назад +3

    If this was interactive I would request the lightning to start again but in reverse; from its arrival point up and see wether it takes roughly the same route. And maybe iterate to find the optimal path. Really interesting!

    • @tommy_svk
      @tommy_svk 3 года назад

      You mean find the shortest path from bottom to the top? Shouldn't that find the exact same path though?

    • @GRAYgauss
      @GRAYgauss 3 года назад

      @@tommy_svk yeah it's literally part of the definition of the algo.

    • @andymcl92
      @andymcl92 3 года назад

      @@GRAYgauss Well it's slightly different. The starting point at the top is fixed as the middle square, but it wouldn't necessarily end there going bottom to top. Say, for example, one maze started top middle and ended bottom left. Then suppose the entire leftmost column was free of walls. The shortest path back up would be straight up the left column, ending top left.
      The reason for this difference is because the start point is fixed, but not the end point.
      Now what I'm wondering about is if you repeated this again and again, where each end point becomes the start of the return, would you ever get back to where you started? I suspect the answer is no, and you'd eventually settle on one route that is (locally) the fastest both forwards and backwards.

    • @GRAYgauss
      @GRAYgauss 3 года назад

      @@andymcl92 Are you saying restart the whole algo in reverse? This isn't measuring shortest path, it's measuring shortest temporal path under a system of rules that effectively modify what a timestep means. If you inverted it and used the end point as origin, it'd still be the shortest temporal path assuming the rules are mirrorable. (I'm abusing time as a sort of metaphorish thing here sorry) I could be wrong but that's the immediate intuition without thinking about it. I also forgot the video so I'm just going off what I imagine the program would be like. Maybe it's not deterministic, but in the simplest case I'm imagining, I expect it to be.

    • @andymcl92
      @andymcl92 3 года назад

      @@GRAYgauss Within the confines of the system, the shortest path and the shortest temporal path are the same thing. I'm saying if you work from top to bottom, then you take that endpoint and work from there upwards following the same rules, the route would not necessarily be the same because you could end up in a different spot on the top from the original start point.
      Imagine taking an n×n grid and filling in all the walls. Now imagine clearing a route that goes from the top middle along the top row to the left, then down the left column. The shortest route to the bottom (both my distance and time) is to go n/2 left, then n down. That's the only route. But now you start from there and go up again. The shortest route to the top is just to go n up. Once you're at the top corner, you're done. You don't need to go to the middle again.
      From there, the shortest route down would be straight down, and up would be straight up, and so on. You fall into a reversible path eventually.

  • @marcusli44
    @marcusli44 3 года назад +1

    Who is like me that click in this video becuase the 301 views video...

  • @jacklardner8229
    @jacklardner8229 3 года назад +2

    Matt, the Twitter legend. I remember seeing this one on Twitter

  • @aikumaDK
    @aikumaDK 3 года назад +2

    I love videos like this, because while I enjoy making the odd program here and there, I got bugger all idea what's going on in Matt's code.

  • @leumas75
    @leumas75 3 года назад +5

    10:33 Thank you for the added thunderbolt sound effect on that last solution. I can’t believe @Matthen2 didn’t include this is the code, because it it ABSOLUTELY necessary.

  • @markbulla1851
    @markbulla1851 3 года назад +2

    In watching all of the solved puzzles, I never saw one where the solution included going upwards for a step or more. I'm not sure if that's a glitch in the programming, or if the puzzles just ended up that way. Thanks for the fun vlog!

  • @Roblox_wec
    @Roblox_wec 3 года назад +6

    Back in the day when we needed screen savers, this would've been really nice.

  • @evil6554
    @evil6554 3 года назад +2

    Your vid is still at 301 views

  • @eFeXuy
    @eFeXuy 3 года назад +2

    Mom, can we have Henry Cavil?

  • @christianmckee3614
    @christianmckee3614 3 года назад +1

    Oh dope! I’m early! How goes your day, people of the internet?

  • @YellowBunny
    @YellowBunny 3 года назад +4

    10:11 sus

  • @mceajc
    @mceajc 3 года назад +2

    Brady, I didn't even know how much I was missing hearing you speak to experts in their field until this moment. Thank you!

  • @ThreeEarRabbit
    @ThreeEarRabbit 3 года назад +3

    This perfectly models how charged particles in the air would collide into other neutral particles, thus jumping the gap and breaking the insulation of the air.

  • @justin_5631
    @justin_5631 3 года назад +1

    That is a terrible maze generation technique. There are much better ones.

  • @goatmeal5241
    @goatmeal5241 3 года назад +5

    Would've been cool to have some slo-mo lightning footage included to compare, because it really does look like the branching fronts of a lightning pre-strike.

  • @brouquier7172
    @brouquier7172 3 года назад +2

    This looks amazing as does everything else Matt has shown is in the previous video! Maybe you could convince him to create the same but with a hexagonal grid instead... I'm just super curious about it