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

Поделиться
HTML-код
  • Опубликовано: 1 окт 2024

Комментарии • 614

  • @drlipnose
    @drlipnose 2 года назад +401

    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 года назад +52

      This is an amazing story!!

    • @rya7886
      @rya7886 2 года назад +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.

    • @nightwintertooth9502
      @nightwintertooth9502 7 месяцев назад

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

    • @8BitZ0mbie
      @8BitZ0mbie 5 месяцев назад

      Classic

  • @kim15742
    @kim15742 7 лет назад +1045

    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 лет назад +162

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

    • @ilyaexo2005
      @ilyaexo2005 7 лет назад +4

      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 6 лет назад +11

      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 года назад +2

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

    • @luckylove72
      @luckylove72 4 года назад

      You are impatient.

  • @jacobmpp
    @jacobmpp 7 лет назад +47

    you should make 2048

  • @Stickman-yw3nu
    @Stickman-yw3nu 7 лет назад +187

    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

  • @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

  • @psyrinx
    @psyrinx 5 лет назад +26

    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.

  • @CodingWithUnity
    @CodingWithUnity 5 лет назад +22

    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;
    }

  • @taradis5659
    @taradis5659 6 лет назад +82

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

    • @neotodsoltani5902
      @neotodsoltani5902 4 года назад +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 3 года назад

      @@MrTrollo2 ikr

  • @ChrisFotosMusic
    @ChrisFotosMusic 4 года назад +15

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

  • @anshum1675
    @anshum1675 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

  • @madsgundersen4507
    @madsgundersen4507 7 лет назад +50

    Your beard is majestic

  • @АлексейГусар-ф9й
    @АлексейГусар-ф9й 5 лет назад +32

    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!

  • @akshay2012rdts
    @akshay2012rdts Год назад +8

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

  • @anteconfig5391
    @anteconfig5391 6 лет назад +41

    Wow I'm a whole year late to this video.

  • @matiasvlevi6647
    @matiasvlevi6647 5 лет назад +9

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

  • @canitbeapplied2500
    @canitbeapplied2500 5 лет назад +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.

  • @GRAHAMAUS
    @GRAHAMAUS 4 года назад +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 4 года назад

      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!

  • @camiloandressandovaldelgad281
    @camiloandressandovaldelgad281 4 года назад +1

    Algorithm for resolve a sudoku

  • @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 :)

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

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

  • @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 :')

  • @mattt2684
    @mattt2684 7 лет назад +62

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

    • @scholli99
      @scholli99 5 лет назад +4

      Oh right. Python is much harder than JS XD

    • @bigombrello
      @bigombrello 5 лет назад +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.

  • @KaletheQuick
    @KaletheQuick 7 лет назад +5

    Thumbs up if you can taste the rainbow.

  • @cedriccarteron2578
    @cedriccarteron2578 4 года назад +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.

  • @yt.mhasan
    @yt.mhasan 5 лет назад +4

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

  • @0ptimal
    @0ptimal 9 месяцев назад +1

    Mimics nature. Question is, is this the absolute pinnacle of pathfinding. What other 'better' ways could there be. To actually know all of the nodes, but it wouldnt be pathfinding more like pathknowing.

  • @dumbcalamitychild
    @dumbcalamitychild 4 года назад +5

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

  • @djxfade90
    @djxfade90 7 лет назад +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 4 года назад

      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 4 года назад

      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 4 года назад

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

    • @chrismanning5232
      @chrismanning5232 4 года назад +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 5 месяцев назад +1

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

  • @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

  • @SimonNitzsche
    @SimonNitzsche 7 лет назад +26

    i like Coding Trainbow more xD

    • @TheCodingTrain
      @TheCodingTrain  7 лет назад +9

      Agreed!

    • @jamesaylward2303
      @jamesaylward2303 7 лет назад

      The Coding Train I'd laugh if you actually changed your name to that temporarily

    • @adammcgrogan8490
      @adammcgrogan8490 4 года назад

      @@TheCodingTrain The new name is way better.

  • @GabeSyme
    @GabeSyme 7 лет назад +1

    25:18: Since we know that the index of current is winner, could we not just use openSet.splice(winner,1) ?

    • @phizc
      @phizc 4 года назад

      yes

  • @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.

  • @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

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

    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

  • @darlya.laporte1123
    @darlya.laporte1123 5 лет назад +5

    Awesome dear genius.
    Jesus loves you. Believe in him and repent.

  • @marcuspeixoto4871
    @marcuspeixoto4871 7 лет назад +13

    18:18 "Are you still watching?"
    0 views

  • @Grizix
    @Grizix 7 лет назад +3

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

  • @douggale5962
    @douggale5962 3 года назад +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.

  • @ruben6284
    @ruben6284 7 лет назад +4

    * spoiler alert * there will be 3 parts!

  • @historian2
    @historian2 5 лет назад +2

    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!

  • @nasrimarc7050
    @nasrimarc7050 Год назад +1

    Interesting coding chanel but the videos are old, it's cool if a new videos will be posted

  • @nautiluso713
    @nautiluso713 7 лет назад +4

    Could you try to make a neural network that learns and can play games like Mario or some other game that would work well

  • @amazingstudiotechnology6513
    @amazingstudiotechnology6513 7 лет назад +3

    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.

  • @Humance
    @Humance 7 лет назад +3

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

  • @halcyonramirez6469
    @halcyonramirez6469 2 года назад +1

    in the for loop with at 12:25 lines 14-16.
    shouldn't the rows be first and then the columns?
    I mean when you iterate through the 2D array you choose the row first and then the columns.
    arr = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
    arr[0][0] is 1st row 1st column not 1st column 1st row.
    am I missing something here?

    • @Nicogs
      @Nicogs 6 месяцев назад

      yes, he used cols for rows and visa versa

  • @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!!

  • @sennabullet
    @sennabullet 2 года назад +4

    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 года назад +2

      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!

  • @Gregzenegair
    @Gregzenegair 7 лет назад +6

    Go to the coding Choppa !

    • @vojvoda-draza
      @vojvoda-draza 7 лет назад +1

      Gregzenegair Skynet
      "put the cookie down" - Arnold Schwarzenegger

  • @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.

  • @SodomEndGomorra
    @SodomEndGomorra Год назад

    well, ok... but can we create way-finder, but more intelligent? i mean not bruteforcing labirynt, but to look, think, and so right answer without millions of tries?

  • @dubvascl5840
    @dubvascl5840 4 года назад +1

    3:24 - You were wrong about Djkstra algorithm. It doesnt search all the possible paths. Instead it searches only the best path to vertex and uses it to search optimal path to it's neighbors. As it only makes updates from each vertex once and each update only uses one edge(as edge connects 2 vertexes it will only take part in 2 update attempts) it will have complexity O(|E| * upd) . As priority queue is used for updates, upd will have comlexity of O(log(|V|). So total complexity is O(|E| * log(|V|)) which is quiet fast and on average PC it will be able to handle graphs with amounts of edges and vertexes not greater than 100000 in 1 second

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

    Omg he move so much that I got tired after a few minutes of watching

  • @Freque
    @Freque 7 лет назад +1

    I don't want to take anything away from you, it's a great tutorial for understanding A* in a simpler situation. But using a grid with obstacles... does that not sound like a more straightforward Lee algorithm? From what I know, in Dijkstra and A* it's the vertices that have a certain cost, and in a grid that is always 1. Again, it's an awesome idea to simplify the concept, but this time it might be a bit confusing, as you ignore a crucial element from the generalized algorithm, and, even though it's harder to understand for some, I think it just has to use graphs. Amazing channel though. I love your simplicity and enthusiasm.

  • @hassaanfarooq9803
    @hassaanfarooq9803 6 лет назад +3

    Best tutorial seen so far on A* algorithm

  • @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

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

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

  • @eljhones18
    @eljhones18 Год назад +6

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

  • @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))`

  • @asphaltproject3392
    @asphaltproject3392 4 года назад +1

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

  • @anandg4018
    @anandg4018 4 года назад +1

    Finally sunder pitchai's official youtube channel😂🤘

  • @sayanghosh6996
    @sayanghosh6996 6 лет назад +2

    25:40 why dont you just use "openSet.splice(winner,1);" ?

  • @noutkleef4458
    @noutkleef4458 7 лет назад +3

    yesss A*!! awesome

  • @TeamUnpro
    @TeamUnpro Год назад

    dude, I f*ing LOVE your website!

  • @voodoo5two927
    @voodoo5two927 7 лет назад +1

    26:37
    removeFromArr = (a, e) => {
    var i = a.lastIndexOf(e);
    a.splice(i, 1);
    }

  • @markell1172
    @markell1172 5 месяцев назад +1

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

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

    trying to translate this into vb however im struggling with drawing the maze and the solution because i cant find a drawing function in vb that would let me do something like this

  • @Danicker
    @Danicker 7 лет назад +2

    Sorry, I'm not familiar with this programming language, can someone please explain to me what the issue with 2d arrays is? Why are they not a built in function?

    • @Grizix
      @Grizix 7 лет назад +3

      Danicker A 2D array is just an array of arrays. What is built in a language is just a design choice.

    • @nofacee94
      @nofacee94 7 лет назад

      it is a built in method for arrays, if you use:
      array.forEach(function(arrayItem, numIndex){ //do something with arrayItem });

  • @TeamUnpro
    @TeamUnpro Год назад

    I've been trying to do this on an isometric grid rotated by 22.5 degrees, (2D plane not just a perspective rotation)
    Talk about heeeeeadache lol, tho I may have just been overcomplicating the sh* out of it

  • @benzokiller1
    @benzokiller1 5 лет назад +2

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

  • @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

  • @pantepember
    @pantepember 4 года назад

    26:40 There is no need to traverse the array backward to remove an element from it. Why would it be? (I'll try it in this tutorial's code though.)
    var arr = [6, 7, 8, 9, 0];
    for (var i = arr.length - 1; i >= 0; i--) {
    if (arr[i] === 7) {
    arr.splice(i, 1);
    }
    }
    console.log(arr);
    // [6, 8, 9, 0]
    for (var j = 0; j < arr.length; j++) {
    if (arr[j] === 7) {
    arr.splice(j, 1);
    }
    }
    console.log(arr);
    // [6, 8, 9, 0]

  • @laugernberg4817
    @laugernberg4817 7 лет назад +4

    create a soduko solving algorithm!

    • @cameronnichols9905
      @cameronnichols9905 7 лет назад

      That's actually not too hard.
      What you can do is use back tracking.
      Iterate through each square, and place a 1 in it, check the entire row, make sure nothing else has a 1, check the entire column and make sure no 1, and check the box of 3x3 squares and make sure no 1. If there is a 1, repeat the process with a 2, then a 3 and so forth...
      If a 9 is tried, and it doesn't work, go to the previous square and increment it by 1, and try that square again.
      If the code reaches the end, and all the rules are followed, it solved it. If the code back tracked all the way to the beginning and no number works in the first square, the puzzle is unsolvable.

    • @laugernberg4817
      @laugernberg4817 7 лет назад

      i could do that, but it is so non efficient it is crazy. solving a soduko would take a lot of time.

    • @cameronnichols9905
      @cameronnichols9905 7 лет назад

      en.wikipedia.org/wiki/Sudoku_solving_algorithms

    • @mrgees100peas
      @mrgees100peas 6 лет назад

      I made one a long time ago but it was not as complicated as the one people propose and it was very efficient time wise. The first step was to have the computer create 81 arrays (Assuming a 9x9 grid). These arrays represents each square. Each of these arrays contain the numbers 1 thru 9. like so
      square_x1_y1 = [1,2,3,4,5,6,7,8,9], square_x1_y2 = [1,2,3,4,5,6,7,8,9].... square_x9_y9 = [1,2,3,4,5,6,7,8,9]
      Then you make a 2D array to represent the game board. in each x,y position you put one of the square arrays.
      2dArr = [[square_x1_y1, square_x1_y2 ...]
      .....
      ....[square_x9_y8, square_x9_y9]]
      In short you end up with a 2d array where each element is another array containing the numbers 1 thru 9.
      The final array is another 2d 9x9 array that contains the numbers the board gives you.
      From here on you divide the program into 2 parts. the first part is to play the game as a human would do by comparing rows, columns and squares. As long as there is 1 change this part of the program will repeat. What you do is eliminate every number that is already given to you by the game board from each of the arrays that applies to. Let me give you an example.
      Suppose the first row of the board looks like this. NOTE: E equal an empty square
      row 1 --> E E 5 E 7 E E E E
      So start at the first position or (0,0) That position is empty so go to the next (0,1) which is also empty. Now go to the next (0,2) AHA!!!! there is a 5 there. So what you do is eliminate a 5 from every array where a 5 cannot exist. So all of the arrays in row 5 cannot ahve a 5 except for the one in (0,2). All arrays which are in column (0,2) cannot have a 5 either so on and so forth. Do this in sequence and once you reach the end or position (9,9) you stat over because there was a change. Eventually each square array will have fewer and fewer numbers so you will solve 80% of the puzzle. Once the computer can narrow it down any more you use recursion and thats it.

  • @cahucadi
    @cahucadi 6 лет назад +1

    In 25:46 can you say openSet.splice(winner,1); at line 72?

    • @phizc
      @phizc 4 года назад

      yes

  • @gibbodoodah
    @gibbodoodah 4 года назад

    Coding Helicopter...?
    CODING PLANE ALL ABOARD THE CODING PLANE

  • @recklessroges
    @recklessroges 5 лет назад

    I thought that, (from set theory) that a closed set was a list of all members of the set, (e.g. fruit_I_like = ["apples"]) and an open set is incomplete, all_the_people_that_I_will_ever_meet = { [parents] {siblings} {friends} {acquaintances} ... } (missing "{people that I will meet tomorrow}" and {siblings} set could grow in the future.)

  • @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!

  • @maxmartin8397
    @maxmartin8397 7 лет назад +2

    coding copter has a ring to it

  • @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!

  • @mble
    @mble 4 года назад +1

    20:46 that's racist

  • @FurryEskimo
    @FurryEskimo Год назад

    I’m surprised more code isn’t written for finding a “good enough” path. My guess is that’s what most life does, and when that fails then you look for a better solution, but the amount of effort required to find A path, would be much simpler, yes/no?

  • @sulochandhungel
    @sulochandhungel 7 лет назад +1

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

  • @muabyt7333
    @muabyt7333 7 лет назад +8

    Chapter 10 of the "Nature of Code" Book would be nice :D

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

    Fantastic video! One minor critique, and I don’t mean offense if you too suffer from ADHD but it seems like you are over-stimulated, which brings out lots of quirks in your speaking. I would assume you drank energy drinks/several cups of coffee before recording. This makes it harder to follow along. Thanks for the video!

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

    Jesus Christ is the Way, the Truth, the Life. No one comes to the Father except through Him. There is no other intermediary. May Jesus Bless you, trust Him, give your life - and He will take care of it :pray: Convert yourself and believe in the Gospel

  • @sandipdas7206
    @sandipdas7206 9 месяцев назад

    3:35 Dijkstra's Algorithm, although does find you the optimal path, but it absolutely doesn't try all the paths, it's a Greedy Algorithm

  • @RockWolfHD
    @RockWolfHD 7 лет назад +1

    First :D

  • @scottk5083
    @scottk5083 5 лет назад +1

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

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

    Stopped watching at 11 minutes...i dont mean to offend but your way of explaining does not comply with my way of understanding. I like how Tech With Tim explains his solutions.

  • @geoffwagner4935
    @geoffwagner4935 10 месяцев назад

    star date 2023, a function called filter() to find and remove objects has been invented , and you cover it . i know, because i just finally learned to removed a few items myself, in my useless sort. however , i did succeed at removing array objects

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

    fantastic tutorial! but::: please speak slower, please! since my english is very poor, i have trouble understanding you. so, please continue those wonderful tutorials

  • @zelioz848
    @zelioz848 11 месяцев назад

    Lmao i started the video and thought, huh he's talking pretty fast in this video. Weird. Took me 2 minutes to realize it was on x1.5 speed lol

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

    Wow ,you just programmed a Printed Circuit Board Auto Router!!!😲😲

  • @zedeleyici.1337
    @zedeleyici.1337 4 года назад

    136 dislike => javascrpit bilmeyenler(not know javascript people)

  • @aleaallee
    @aleaallee 7 лет назад

    damn, i already know some of java, i want to learn javascript but i REALLY hate maths

  • @igniculus_
    @igniculus_ 7 лет назад +1

    Please make video on a 9/15 puzzle solving algorithm ... I read somewhere that it uses a* algorithm ...

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

    I don't get why at 21:46 you still have a visible grid, although you used noStroke()?

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

    Hello genius, I need a favor, could you explain the LPA* algorithm

  • @xdrakolax22
    @xdrakolax22 7 лет назад +1

    ES 6 please!!!!

  • @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