A* Pathfinding Algorithm (Coding Challenge 51 - Part 1)

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 พ.ค. 2024
  • In this multi-part coding challenge, I attempt an implementation of the A* Pathfinding Algorithm to find the optimal path between two points in a 2D grid. Code: thecodingtrain.com/challenges...
    💻 Github Repo: github.com/CodingTrain/AStar
    🕹️ p5.js Web Editor Sketch: editor.p5js.org/codingtrain/s...
    Other Parts of this Challenge:
    📺 A* Algorithm - Part 2: • Coding Challenge 51.2:...
    📺 A* Algorithm - Part 3: • Coding Challenge 51.3:...
    🎥 Previous video: • Coding Challenge #50.1...
    🎥 Next video: • Random Walker in p5.js...
    🎥 All videos: • Coding Challenges
    References:
    📘 Artificial Intelligence: A Modern Approach: aima.cs.berkeley.edu/
    🗄 A* Search Algorithm on Wikipedia: en.wikipedia.org/wiki/A*_sear...
    💻 Online demo: codingtrain.github.io/AStar/
    Live Stream Archive:
    🔴 Live Stream #72: • Live Stream #72: A* Pa...
    Related Coding Challenges:
    🚂 #10 Maze Generator: • Coding Challenge #10.1...
    🚂 #162 Self Avoiding Walk: • Coding Challenge 162: ...
    Timestamps:
    0:00:00 Introduction
    0:01:26 A* Pathfinder
    0:09:39 Coding a Grid
    0:13:09 A* Pathfinder Algorithm
    0:22:07 Choosing Best Available Path
    0:27:05 Finding New Nodes
    0:38:30 Adding Heuristic
    0:41:50 Tracing Back
    0:46:49 Using Better Heuristics
    Editing by Mathieu Blanchette
    Animations by Jason Heglund
    Music from Epidemic Sound
    🚂 Website: thecodingtrain.com/
    👾 Share Your Creation! thecodingtrain.com/guides/pas...
    🚩 Suggest Topics: github.com/CodingTrain/Sugges...
    💡 GitHub: github.com/CodingTrain
    💬 Discord: / discord
    💖 Membership: th-cam.com/users/thecodingtrainjoin
    🛒 Store: standard.tv/codingtrain
    🖋️ Twitter: / thecodingtrain
    📸 Instagram: / 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-o...
    This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecod...
    #aalgorithm #pathfinding #heuristic #p5js #javascript

ความคิดเห็น • 615

  • @drlipnose
    @drlipnose 2 ปีที่แล้ว +353

    I ended up here while trying to fix my own version of A* code for a personal project. Although in a completely different language, I figured following the logic from start to finish would help. I am happy to say that after watching this twice, clocking in at a near 2 hours of of the most energetic coding I've ever observed, I realized one of my i's were a j.

    • @TheCodingTrain
      @TheCodingTrain  2 ปีที่แล้ว +44

      This is an amazing story!!

    • @rya7886
      @rya7886 ปีที่แล้ว +5

      I feel your pain before notepad++ we had notepad... it was as fun as you described!

    • @greatcesari
      @greatcesari ปีที่แล้ว +7

      I got intense nausea reading that last part.

    • @arcalypse1101
      @arcalypse1101 10 หลายเดือนก่อน

      ​@rya7886 I you just took me way back lol thanks for that.

    • @nightwintertooth9502
      @nightwintertooth9502 3 หลายเดือนก่อน

      This is the problem with monospace font glyphs and bad vision. 😂

  • @kim15742
    @kim15742 7 ปีที่แล้ว +1035

    I like it how you show the result at the beginning. Otherwise, I always have to go to the end and see if that is something I want to learn.

    • @TheCodingTrain
      @TheCodingTrain  7 ปีที่แล้ว +159

      Yes, I hope to keep doing this with future challenges!

    • @ilyaexo2005
      @ilyaexo2005 7 ปีที่แล้ว +3

      Sometimes it is obvious from description what are you going to do. So, please don't show final result until it really hard to understand!

    • @Twurl
      @Twurl 5 ปีที่แล้ว +10

      I personally hate it when he shows the end result at the beginning. At least give a spoiler warning or a timestamp to skip it. For me, seeing the exact end result removes nearly all motivation to watch through an hour long two-part tutorial. I would rather watch the project organically come together as he builds it, without knowing exactly what to expect.

    • @tx6723
      @tx6723 4 ปีที่แล้ว +3

      I agree to an extent I like the excitement and motivation of not knowing

    • @luckylove72
      @luckylove72 3 ปีที่แล้ว

      You are impatient.

  • @psyrinx
    @psyrinx 4 ปีที่แล้ว +27

    I love all your Coding Challenge videos. I'd love to see you make a multi-part series of you putting a lot of code and detail into a project.

  • @user-wo6qp2mo4o
    @user-wo6qp2mo4o 5 ปีที่แล้ว +31

    Man, thank to you again!! I'm so interesting in algorithms and ML, but didn't know where to start. And your lectures are such a good place to start and go far! It's really great, new level, so different to compare with usual front-end JS, it's real science, it's interesting, it's improve you. Thank you!

  • @CodingWithUnity
    @CodingWithUnity 5 ปีที่แล้ว +21

    I know this is a pretty old video, but for anyone watching. The reason it wasnt giving his expected results with no walls and no diagonals is because you need to add tiebreaking in. You can do this simply by changing
    for (int i = 0; i < openSet.Count; i++)
    {
    if (openSet[i].F < openSet[winner].F)
    winner = i;
    }
    Too
    for (int i = 0; i < openSet.Count; i++)
    {
    if (openSet[i].F < openSet[winner].F)
    winner = i;
    else if (openSet[i].F == openSet[winner].F)//tie breaking
    if (openSet[i].H < openSet[winner].H)
    winner = i;
    }

  • @akshay2012rdts
    @akshay2012rdts 7 หลายเดือนก่อน +4

    People like you do more for students than many universities around the world. Cheers to learning 🎉

  • @viggzta
    @viggzta 7 ปีที่แล้ว +1

    This was super helpful for actually learning A*. I have tried to do it multiple times in C# but never got it working, but ~3 days ago i figured it out thanks to this video. You rock!

  • @archanamotagi1675
    @archanamotagi1675 5 ปีที่แล้ว +12

    Best explanation of A* on the internet! By the way, you could have added neighbours to a spot just before looping through its neighbours. This way if you didn't need to check the neighbours of some spots, you wouldn't need to add neighbours to it. They could just be added to closed set without neighbours. This would save a lot of memory when you're dealing with many spots

  • @petergriffith9468
    @petergriffith9468 5 ปีที่แล้ว +1

    Thanks to your inspiration I finally managed to implement an object oriented version of Astar for Codewars. Keep up the good work!

  • @douggale5962
    @douggale5962 2 ปีที่แล้ว +4

    25:20 Array's splice method removes one or more elements from an array, closes the gap, and reduces the length. It makes an array of the removed elements, if any, and returns them. You can also insert zero or more new elements in that position by passing them as the subsequent parameters after removal range base and length.

  • @sennabullet
    @sennabullet 2 ปีที่แล้ว +3

    I have been binge watching your videos over the holiday vacation...and I just don't know how I can express my gratitude for making these amazing videos. Your enthusiasm, presentation style...makes what would be a tough process (learning to program) a VERY enjoyable learning process. A massive thank you for sharing your incredible knowledge. You just got a new member.

    • @TheCodingTrain
      @TheCodingTrain  2 ปีที่แล้ว +1

      Thank you Rico! Did you fill out the google form and link your account to Discord?

    • @sennabullet
      @sennabullet 2 ปีที่แล้ว +1

      @@TheCodingTrain...notbyet! Will do!! Did buy some Coding Train Merch though!
      What I love the most about the videos you make...is that you don't edit out your mistakes. 'this dot' et all. They are mistakes all of us noobs will make and you show us that even pros make mistakes...and the debugging method is education in itself

    • @codingtraintwitcharchive3277
      @codingtraintwitcharchive3277 2 ปีที่แล้ว

      @@sennabullet Thanks, I really appreciate this feedback!

  • @benzokiller1
    @benzokiller1 5 ปีที่แล้ว +1

    Absolutely amazing video! Your energy for coding is absolutely amazing and got me coding in p5

  • @thishe0
    @thishe0 3 ปีที่แล้ว +5

    I honestly don't know what I would do without you.

  • @amazingstudiotechnology6513
    @amazingstudiotechnology6513 6 ปีที่แล้ว +2

    You are one of the best teacher online and with a great personality .You have help me a lot with processing. We need more people like you in the world ,thank you.

  • @hassaanfarooq9803
    @hassaanfarooq9803 5 ปีที่แล้ว +3

    Best tutorial seen so far on A* algorithm

  • @scottk5083
    @scottk5083 5 ปีที่แล้ว +1

    found out about this channel afew days ago. your videos and walkthroughs are amazing.

  • @canitbeapplied2500
    @canitbeapplied2500 4 ปีที่แล้ว +9

    Translating this into C# for unity is... interesting. Tough to find a good tutorial on pathfinding, luckily this seems to be working for me so far. Love the videos keep up the great work : )

    • @smolboye1878
      @smolboye1878 2 ปีที่แล้ว

      I had to translate my js code for A* to C for my robotics team a couple of years ago. Great way to learn about pointers and dynamic memory.

  • @tanmayagarwal8513
    @tanmayagarwal8513 4 ปีที่แล้ว +2

    Really Really Really!!!! Fantastic Video. I really love his energy while he was teaching!! Wish I could have this man as my professor. Amazing!!

  • @simonec3511
    @simonec3511 2 ปีที่แล้ว +14

    This guy is a genius! It looks so straight forward every single step. Amazing 🤩

  • @markell1172
    @markell1172 15 วันที่ผ่านมา

    This channel always when i don’t know what to do when i want to code something gives me motivation and ideas, pretty cool.

  • @sulochandhungel
    @sulochandhungel 6 ปีที่แล้ว +1

    So after a mess and 2 hours you finished it? You are BRILLIANT my friend!

  • @Stickman-yw3nu
    @Stickman-yw3nu 7 ปีที่แล้ว +186

    It is fantastic how this guy has so muck inspiration and energy to program,and a lot of that anergy actually hi is giving to us , BIG THANKS YO HIM :D

    • @Nickoking12
      @Nickoking12 5 ปีที่แล้ว +8

      Tbh his overly childish display of energy is kind of annoying

    • @FeLiNe418
      @FeLiNe418 4 ปีที่แล้ว +9

      @@Nickoking12 you must be fun at parties

    • @BloodyClash
      @BloodyClash 4 ปีที่แล้ว +2

      Also like his energy and paired with it his intelligence you can hear and see

    • @kavinbharathi
      @kavinbharathi 3 ปีที่แล้ว +1

      @@Nickoking12 there are always people that does not want someone be themselves, aren't there...

    • @skmgeek
      @skmgeek 2 ปีที่แล้ว

      @@kavinbharathi yep

  • @YADA70073
    @YADA70073 3 ปีที่แล้ว

    I'm really love the way you showing the coding... fun and relax.... with the great result.

  • @shubhamagarwal797
    @shubhamagarwal797 5 ปีที่แล้ว +1

    You saved my semester! Brilliant work. You sir, are awesome!

  • @taradis5659
    @taradis5659 6 ปีที่แล้ว +84

    If I had more professors who teach like you I was a better engineer now !

    • @neotodsoltani5902
      @neotodsoltani5902 3 ปีที่แล้ว +14

      Yeah, the problem is, many of the university teachers are bunch of morons.

    • @MrTrollo2
      @MrTrollo2 3 ปีที่แล้ว +7

      if teachers would teach like this you'd need longer days. Of course it's easy to understand when you already know how it's done.

    • @justarandomlol
      @justarandomlol 2 ปีที่แล้ว

      @@MrTrollo2 ikr

  • @gordonmctague1723
    @gordonmctague1723 หลายเดือนก่อน

    So cool to watch you programming, I've been learning C# for the past few months and it's cool to watch you working in Java but still understanding what you're doing. I'm going to have a go at doing this in C#.

  • @historian2
    @historian2 5 ปีที่แล้ว +1

    BInary heap implementation of Dijkstra Algorithm runs in O(E)+|V|log|V| time which isn't particularly slow. Together with Hoare's Quicksort Algorithm, Dijkstra Algorithm must rank in the top 2 algorithm of the last century!
    Excellent job on your videos, you are a great teacher!

  • @JavaVampire
    @JavaVampire 7 ปีที่แล้ว +5

    I cannot stop watching your videos. The way you explain your process of coding is excellent. Awesome videos, I always look forward the the next one!!

  • @bronsonsedeno8064
    @bronsonsedeno8064 7 ปีที่แล้ว +8

    I did this a few years ago in one of my intro classes to programming. Was hell, still have the file though :)

  • @nicholask9251
    @nicholask9251 6 ปีที่แล้ว

    Please keep making these vids, and thank you for teaching us

  • @claudiameneghesso1843
    @claudiameneghesso1843 3 ปีที่แล้ว +1

    Very well explained, thanks! Love your enthusiasm for teaching!

  • @dtymnn
    @dtymnn 9 หลายเดือนก่อน

    I'm in web dev and watching this. Idk why but this is refreshing some good memories lol

  • @jchenji
    @jchenji 7 ปีที่แล้ว +5

    Dan, you are one of the only CS instructors I've enjoyed listening to. Even when I'm not in a mood to program, watching your videos always makes me want to start something of my own. I've always struggled with finding motivation, and you have helped me find it again. Thanks a bunch! I'm glad I found your channel.

    • @TheCodingTrain
      @TheCodingTrain  7 ปีที่แล้ว

      Thank you for the nice feedback!

  • @premnathd
    @premnathd 4 ปีที่แล้ว

    Thanks for showing result at the beginning of the video. Awesome

  • @aliceorwell7541
    @aliceorwell7541 7 ปีที่แล้ว +1

    I absolutely love these coding challenges! Keep being awesome.

  • @_melts
    @_melts ปีที่แล้ว

    Web dev trying to build a game as a hobby project, such a good tutorial - thank you!

  • @taihatranduc8613
    @taihatranduc8613 3 ปีที่แล้ว

    Thank you a lot. Why are you always the best person to explain things

  • @camelcase9225
    @camelcase9225 7 ปีที่แล้ว +1

    I watched this live stream. Must have been the hardest one to edit yet. Probably why part 1 wasn't released until 2 days after haha. Love your channel man, I swear I've put in at least 60 hours watching many of your vids. Btw, I started Frogger today in P5, I think you should consider it for a coding challenge. It's a long and tedious one though!

  • @hjjol9361
    @hjjol9361 6 ปีที่แล้ว

    I loved it, espescially the way that without diagonal or obstacle, each way take same time to travel, your grid is 25 by 25, if it go down, right alternativly it will take 25 down and 25 right move to the other side, just like to go on the edge of the grid is 25 down + 25 right :D !
    You helped me take the code train thank you prof. i would have kill to got prof like you in college.

    • @phizc
      @phizc 4 ปีที่แล้ว

      Problem is that it's not actually A*. It's breadth first due to bugs. A* Would only need to check alternately going right down, right down etc or down right down right etc.
      It found an optimal path but it checked all 625 cells doing it. A* would also find an optimal path, but would need to check fewer cells.

  • @ipwnzyanoobz
    @ipwnzyanoobz 6 ปีที่แล้ว +3

    For any of you wondering, this is the kind of algorithm top down view rpgs and mobas use like league, runescape, fallout etc

  • @matiasvlevi6647
    @matiasvlevi6647 5 ปีที่แล้ว +9

    1:42 "needle in a haystack"
    *Non-premium spotify user's ptsd intensifies*

  • @asphaltproject3392
    @asphaltproject3392 3 ปีที่แล้ว +1

    Thanks !!! You helped me a lot, and that works for Hex grids! (Of course just have to change neighbors conditions)

  • @pactube8833
    @pactube8833 3 ปีที่แล้ว

    I love the energy he has
    Love you bro

  • @Grizix
    @Grizix 7 ปีที่แล้ว +3

    To remove a value from an array in javascript, the two main solutions I know are .filter and .splice(.indexOf)

  • @noutkleef4458
    @noutkleef4458 7 ปีที่แล้ว +3

    yesss A*!! awesome

  • @abdlbasetsaci4488
    @abdlbasetsaci4488 6 ปีที่แล้ว

    thanks you are awsome man !!.we need more complicated videos

  • @BukovTervicz
    @BukovTervicz 2 ปีที่แล้ว

    Holy crap what a good A* explanation at the beginning

  • @adamjc86
    @adamjc86 5 ปีที่แล้ว +1

    at 25:48 you create a function to find the index of the `current` element, but you already know that value, it is the value stored in `winner`, so I think you could just do `openSet.splice(winner, 1)`, or without side effects: `openSet = openSet.slice(0, winner).concat(openSet.slice(winner + 1, openSet.length))`

  • @djxfade90
    @djxfade90 6 ปีที่แล้ว +14

    I know this is an old video, but a more effective way of removing a specific element from an array could be written as:
    var myArr = ["foo", "bar", "bas"]
    var element = myArr[2] //"bas"
    function removeFromArray(arr, el) {
    let i = arr.indexOf(el)
    if (i > -1) {
    arr.splice(i, 1)
    }
    return arr
    }
    myArr = removeFromArray(element)

    • @xerxius5446
      @xerxius5446 3 ปีที่แล้ว

      use filter instead
      // remove 2 from array
      [1,2,3].filter(i => i !== 2)
      I would personally use a linked list if random access is not needed and there is a lot of insertion / deletion happening

    • @mannyc6649
      @mannyc6649 3 ปีที่แล้ว

      In this case your function is definitely better and faster. But it's not equivalent to what he wrote in general. If an array has duplicate elements his function will remove all of them while yours only the first occurrence (assuming that indexOf returns the first occurrence). I just wanted to point that out.

    • @mannyc6649
      @mannyc6649 3 ปีที่แล้ว

      @@xerxius5446 I agree. I was referring to the code in the parent comment, not yours :)

    • @chrismanning5232
      @chrismanning5232 3 ปีที่แล้ว +1

      The most effective way is just to use the winner variable, which already had the index of the item (and he instantly forgot that). Just openSet.splice(winner,1)

  • @freeidaho-videos
    @freeidaho-videos 27 วันที่ผ่านมา

    Looks just like a robot finding an optimal path through a building. ;)

  • @MarkusBurrer
    @MarkusBurrer 7 ปีที่แล้ว +1

    This is a good video about A* pathfinding, but there are a lot of videos for simple 2d grids. What I miss are tutorials how I can implement A* in a 3d voxel world like Minecraft or Minetest, including jumping, fall height and so on. This is far more complex than the basic 2d grid algorithm

  • @adityakulshrestha7033
    @adityakulshrestha7033 2 ปีที่แล้ว

    I love your videos because it builds logic 😊

  • @ChiniMini-ChujuMuju
    @ChiniMini-ChujuMuju 3 ปีที่แล้ว

    Thanks, man !! You saved my day. I was struggling with this algorithm and your video helped me a lot. One thing I want to ask you. What could be other good heuristics methods we can use here (except euclidean and manhattan)?

  • @benamiomer7819
    @benamiomer7819 6 ปีที่แล้ว

    I don't even code but your videos are really fun to watch it makes me want to learn it

  • @timeslongpast
    @timeslongpast 7 ปีที่แล้ว

    I found your channel about a month before your channel name changed from coding rainbow to Daniel Shiffman to coding train and I got really confused as to why the super awesome intro you had was all blurred out. Now I understand though. Anyway you are doing a great job and I love seeing your processing videos.

    • @TheCodingTrain
      @TheCodingTrain  7 ปีที่แล้ว

      I'm wondering if I should have left the channel name to "Daniel Shiffman" even if the name name is "Coding Train" . .

    • @kenan2386
      @kenan2386 3 ปีที่แล้ว

      Keep it as Coding Train

  • @tillroberg1730
    @tillroberg1730 6 ปีที่แล้ว

    Thaaaaaanks a lot! You are a genius! Well explained and easy to follow. Thanks to you I finally understood what A* is actually doing and I got this big piece of homework done. Thanksthankthanks and did I thank you already?

  • @ChrisFotosMusic
    @ChrisFotosMusic 3 ปีที่แล้ว +15

    31:39 "some other life that you have"
    buddy i barely have one life as it is

  • @Tordek
    @Tordek 7 ปีที่แล้ว +9

    I built an A* PF viz in Processing the other day, and I was *this* close to tearing my hair out until I realized how I could simplify away almost half of the code I had written to fix edge cases by just... making a smarter Neighbors() function.

  • @jacobmpp
    @jacobmpp 7 ปีที่แล้ว +48

    you should make 2048

  • @TeamUnpro
    @TeamUnpro ปีที่แล้ว

    dude, I f*ing LOVE your website!

  • @yt.mhasan
    @yt.mhasan 5 ปีที่แล้ว +4

    When I will go to USA, I will meet you no matter what. I love you, man ❤️

  • @maxtaniepetitdol9986
    @maxtaniepetitdol9986 7 ปีที่แล้ว +3

    Dude you're just amazing. Programming is so great!!!

  • @tylerhanson133
    @tylerhanson133 4 ปีที่แล้ว

    Thanks this helped me solve a real world problem!

  • @lystic9392
    @lystic9392 4 ปีที่แล้ว

    I want to do this on a curved surface that changes over time where there is no translation to a flat surface.
    I'm thinking I may be able to use an estimated curvature and use collision boxes around it to the end point to find probable relevant points on the ground. And then weigh them with their height relative to the estimated curvature.
    Maybe I can reuse those boxes until it gets there/changes path in case it all changes while traveling.
    That all sounds complex though.

  • @jordanbao2835
    @jordanbao2835 7 ปีที่แล้ว +1

    Thanks to this channel I moved all my draw engine of my project to p5 :D

  • @cedriccarteron2578
    @cedriccarteron2578 3 ปีที่แล้ว +3

    Hello, thank you for your video. I have implemented the A Star on Android Studio.
    Can I share it with you ?
    Have you ever though of making a Robot Localization with particles filter on simulation ? I have implemented it this weekend.

  • @AshishNallana
    @AshishNallana 3 ปีที่แล้ว

    This algorithm project is very interesting & amazing

  • @youssefsoliman3341
    @youssefsoliman3341 3 ปีที่แล้ว +1

    iam happy to see this work !

  • @Humance
    @Humance 7 ปีที่แล้ว +3

    i don't understand any of that but i find it fascinating!

  • @GRAHAMAUS
    @GRAHAMAUS 3 ปีที่แล้ว +7

    Interesting how the animation at the beginning looks a bit like the "stepped leader" of a lightning strike. I wonder if this has any bearing on that phenomenon, which I believe isn't that well understood - could be an opportunity for some cross-disciplinary research.... :)

    • @sylv171
      @sylv171 3 ปีที่แล้ว

      Actually, a lightning IS looking for the shorter way ! So i thinks that it's pretty much the same thing :)
      Sorry for my english i'm french ^^

    • @AshishBihani
      @AshishBihani 2 ปีที่แล้ว

      Exactly the comment i was looking for!

  • @birnenkopf89
    @birnenkopf89 4 ปีที่แล้ว

    you are wonderfull, very entertaining see your coding process.

  • @bitworld2848
    @bitworld2848 6 ปีที่แล้ว +2

    I like how you explain what's going on, and what you're going to do next, and why.

  • @baltazar0007
    @baltazar0007 7 ปีที่แล้ว

    FANCY stuff. i really like your videos. how about trying to make a tut on creating 2d map from a camera or two could be fun

  • @YoutubeAdministrator
    @YoutubeAdministrator 7 ปีที่แล้ว

    Well done on the editing. Watched the livestream and felt sorry for the editor. But nice result.

  • @christianjt7018
    @christianjt7018 4 ปีที่แล้ว

    Great video as always :)

  • @igniculus_
    @igniculus_ 7 ปีที่แล้ว +41

    Name of this channel was different ... I like the new name though !!!

    • @kuskus_th13
      @kuskus_th13 7 ปีที่แล้ว +1

      He had trademark issues with Reading Rainbow, so he changed it.

    • @manuelbonet
      @manuelbonet 7 ปีที่แล้ว +3

      KusKusPL Wasn't it coding rainbow?

    • @AsifMehedi
      @AsifMehedi 7 ปีที่แล้ว

      Yes, but it was too similar.

    • @igniculus_
      @igniculus_ 7 ปีที่แล้ว

      Actually ... Even before that ... The channel name was his own name ... "Daniel Shiffman".

    • @manuelbonet
      @manuelbonet 7 ปีที่แล้ว +2

      Ani H.​ The channel had always been named Daniel Shiffman, but when he referred to his channel, he called it Coding Rainbow

  • @nofacee94
    @nofacee94 7 ปีที่แล้ว

    I recommend using arrRows.forEach(function(row, i){ row.forEach(function(col, j){ console.log(row, i, col, j) } }); e.g. for the grid.

  • @elpsycongree1132
    @elpsycongree1132 2 ปีที่แล้ว

    Awesome video!

  • @eljhones18
    @eljhones18 9 หลายเดือนก่อน +6

    I loved the part when pathfinder says "get ready, its Zipline time" and start pathfinding all over the place

  • @jesseefcf3268
    @jesseefcf3268 5 ปีที่แล้ว +4

    4:36 "The algorithm is typically written with a formula. The formula's actually quite simple, although any time you write a formula, it starts to be like, 'Oh my god, is this really what we're doing today?' "
    haha ily dan

  • @jony1495
    @jony1495 7 ปีที่แล้ว

    Really enjoy all of your videos! cheers for the great content. I have a question,for a school project I want to build a map for a navigation where your location is fixed in the centre and the map moves along of your path as you move. What would be a good way to go about this (I was thinking canvas or p5js?) I get my location as well as the location of destination in coordinates from an api. Thanks!

    • @TheCodingTrain
      @TheCodingTrain  7 ปีที่แล้ว

      you could look into mapbox.js for mapping stuff. but if you do it in canvas translate() will allow you to always "center" the view.

  • @teeraucher
    @teeraucher 7 ปีที่แล้ว

    I already wrote A* in vb.net to learn how it works. (Tip: Don't write it recursive. The Stack will overflow.) But I started watching this video so see how some one would explain it. But now I am more interested in the p5* framework xD. (btw. very entertaining video #Like)

  • @lbastos1
    @lbastos1 3 ปีที่แล้ว +6

    26:35 if splice removes an element in the given index of the array, couldn't you use it as instead of creating the function removeFromArray? Loving the content ❤

    • @pascha4527
      @pascha4527 2 ปีที่แล้ว

      yes.. Let's just say his brain's think quicker than a machine already so he doesn't need that extra optimisation :')

  • @madsgundersen4507
    @madsgundersen4507 7 ปีที่แล้ว +50

    Your beard is majestic

  • @tryandgain
    @tryandgain 6 ปีที่แล้ว

    So kool! Btw, there's bug in the video of the first loop openSet.length, right after check openSet.length > 0.
    You should close bracket for the loop after the winner is found. The code in source control is fixed but the video is not :)

  • @mattt2684
    @mattt2684 6 ปีที่แล้ว +62

    You should do coding challenges on different languages, such as python or CPP

    • @scholli99
      @scholli99 4 ปีที่แล้ว +4

      Oh right. Python is much harder than JS XD

    • @bigombrello
      @bigombrello 4 ปีที่แล้ว +19

      @@scholli99 that was not the point even if python is easier writing the code is as challenging as js

    • @Doge317
      @Doge317 4 ปีที่แล้ว +1

      Well p5 is a js library, and p3 is a java library, so it wouldn't make much sense to switch up those languages.

    • @formulaintuition8756
      @formulaintuition8756 4 ปีที่แล้ว +5

      @@scholli99 That's not the point...

    • @regi7121
      @regi7121 4 ปีที่แล้ว +8

      What he meant was, to do different languages for educational purposes it's not just about the difficulty, after all this channel is for sharing information about programming.

  • @TJ-hs1qm
    @TJ-hs1qm ปีที่แล้ว +1

    Does anyone know how to adjust A* in order to find all shortest paths ranked by length in an a-priori manner? Say the current shortest path becomes unpassable due to a storm I need to quickly find the next best alternative path, etc. without having to repeat the entire A* calculation.

  • @MR_KALI_YT_007
    @MR_KALI_YT_007 3 ปีที่แล้ว

    OMG 😱😱😍 amazing challenge

  • @katiesilva7651
    @katiesilva7651 7 ปีที่แล้ว +3

    first tried to do this without a tutorial. I started at (1, 1)(on a grid) and tried to get to (1, 2). let's just say it went to (-1, 0) then had an infinite loop

  • @charbelsarkis3567
    @charbelsarkis3567 7 ปีที่แล้ว

    can u explain the this. function thing, because i dont understand how you were capable of keeping track of the path specifically after making the neighbors variable and checking the tempG ...

  • @expeng5861
    @expeng5861 4 ปีที่แล้ว

    wonderful challenge coding game.

  • @endoscopisis
    @endoscopisis 7 ปีที่แล้ว +2

    I love this channel

    • @kuskus_th13
      @kuskus_th13 7 ปีที่แล้ว

      falloist who doesn't

    • @badmin236
      @badmin236 7 ปีที่แล้ว

      me too!

  • @qin2500
    @qin2500 3 ปีที่แล้ว

    Would it be better use a priority queue for the openSet since we are always looking at the node with the smallest f?

  • @shiprasharma1671
    @shiprasharma1671 3 ปีที่แล้ว

    Amazing explaination....have you made any video on best- first search???

  • @nouhazouaghi7862
    @nouhazouaghi7862 4 ปีที่แล้ว

    love your energy

  • @antoineprudhomme9338
    @antoineprudhomme9338 7 ปีที่แล้ว

    An other possibility for the function to remove an item from an array, using filter :D
    function removeFromArray(arr, toRemove) {
    return arr.filter(e => e != toRemove);
    }

  • @tonylim1225
    @tonylim1225 4 ปีที่แล้ว +1

    What a lecture.
    Easy to understand even though i live in non-english country.
    Would love to see whole lectures
    😁😁

  • @cicik57
    @cicik57 2 ปีที่แล้ว

    dud i watched it to see your implementation of binary heap, what is used to store values and pull minimum value, but you made it pretty trivial. Anyways, thanks :D

  • @MrAruiz5
    @MrAruiz5 7 ปีที่แล้ว +1

    Hello Daniel! Let me start saying that I discovered this channel like a month ago and I totally love it! You have made me start coding again after leaving it for a long time :)
    I have kind of a silly question for you, I like following your examples and challenges as I'm watching the video, and I try to have the code as organized as you do, but I end up being much slower typing everything and specially spacing everything so it becomes much more readable. How do you make Atom automatically space things out (I'm not refering to indentation inside functions since that came with Atom right out of the box, but rather making a line such as (var i=0, i

  • @itsMike05
    @itsMike05 5 ปีที่แล้ว

    Is there any way that can be done in Processing? If so, could you make a tutorial?