Coding Challenge 51.2: A* Pathfinding Algorithm - Part 2

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 16. 07. 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* Pathfinder Algorithm - Part 1: ‱ A* Pathfinding Algorit...
    đŸ“ș 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:00:40 Adding Obstacles
    0:03:12 Dealing With Dead Ends
    0:05:48 Adding Diagonals
    0:09:30 Ideas For Optimization
    0:11:40 Fixing Bugs in The Code
    0:15:39 Choo Choo We Did It!
    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: czcams.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

Komentáƙe • 168

  • @noimodimi9020
    @noimodimi9020 Pƙed 7 lety +199

    This guy is like the Bob Ross of coding, only more enthusiastic.

  • @neelparekh3448
    @neelparekh3448 Pƙed 3 lety +34

    *I FREAKING DID IT! I COMBINED THIS WITH YOUR MAZE GENERATION PROJECT!*

  • @TMacFuzz
    @TMacFuzz Pƙed 7 lety +5

    the no diagonal/no walls search looks funky because every path to the end using right and down movements has the same distance, so its going to search every spot. Every path is optimal.

    • @TheCodingTrain
      @TheCodingTrain  Pƙed 7 lety

      yes, thank for you clarifying this.

    • @pproba
      @pproba Pƙed 6 lety +2

      I was predicting this the moment he created the grid and defined the start and end points. I kept screaming at my screen, It was such a rollercoaster to watch...

  • @GogiRegion
    @GogiRegion Pƙed 5 lety +17

    Thank you so much for this. Ironically enough, I figured out how to add diagonals and go past walls all by myself just using the first video and using the octagonal heuristic from a Stanford article.
    I finished writing the pathfinding for the game I’m programming from the first video, and the second helped me make sure I got it right.

    • @danielromeo99
      @danielromeo99 Pƙed 5 lety +3

      Nice bro!

    • @aichabenlahrech635
      @aichabenlahrech635 Pƙed 5 lety +2

      I ask :
      Why in the beginning of the video the spots moves in same time (i mean the x and y moves in the same same time )?
      Because he have the same (g) and same (distance) ? Every path is optimal and there are no best (g) and distance ? So he check evrey spot

  • @dheerajlxst9141
    @dheerajlxst9141 Pƙed 7 lety +2

    You're so inspiring. Keep on these videos. Love them all.

  • @RobinsonGames
    @RobinsonGames Pƙed 7 lety +9

    Explained exceptionally well, as always.
    I'm looking forward to the neural network videos.

  • @FlorianLagg
    @FlorianLagg Pƙed 5 lety

    really cool watching you code. that enthusiasm is great. thank you.

  • @Kalihomo
    @Kalihomo Pƙed 7 lety +16

    I feel so great finding this hidden part 2 :D

    • @TheCodingTrain
      @TheCodingTrain  Pƙed 7 lety +7

      I always to release the full tutorial but "publish" one day at a time (seems to work best for youtube stats.)

    • @GABRIELFILMSTUDIOS
      @GABRIELFILMSTUDIOS Pƙed 7 lety +3

      You could actually make these private till release, so that actually nobody can see them until they are released. I think you can even let them be released automatically at a specific time.

    • @nicholascurry5536
      @nicholascurry5536 Pƙed 7 lety

      It would be cool if you made the path find its way outward from the center to any corner or "escape". Basically, an escape room AI... Just an idea

  • @elishmuel1976
    @elishmuel1976 Pƙed 5 lety +11

    I wish I could re"like" the video everytime I learn from it

  • @KDChenStudio
    @KDChenStudio Pƙed 7 lety +5

    Hey i followed exactly your tutorial and successfully made this algorithm on my iPhone ;)

  • @LewisCowles
    @LewisCowles Pƙed 3 lety +2

    While I don't love the code, this looks to be a better A-star than I used yesterday, and the ability to watch the iterations is quite cool too.

  • @ne5i_
    @ne5i_ Pƙed 7 lety +1

    Darn good video. I wish your videos had been around when I was studying CompSci! Thank you!!

  • @umchoyka
    @umchoyka Pƙed 7 lety +25

    Not sure, but one additional change would be to calculate the diagonal movement differently than orthogonal movement. From the beginning, your "g" cost was always to add 1, but to move diagonally the actual cost should be sqrt(2).

    • @TheCodingTrain
      @TheCodingTrain  Pƙed 7 lety +5

      yes, a good point indeed!

    • @TiaKatt
      @TiaKatt Pƙed 5 lety +1

      It can work to just approximate it to 1.4

    • @paladin1147
      @paladin1147 Pƙed 4 lety

      I am not sure of the p5.js but the processing versions takes diagonals (g) distance as 1.41...... if you look in the console command

  • @RedouaneKhrifi
    @RedouaneKhrifi Pƙed 7 lety +1

    your code is beautiful
    thank you for the great content :)

  • @zhangkin7896
    @zhangkin7896 Pƙed 6 lety

    thx a lot! I can't believe I found this. It's so great!

  • @justinasbeinorius8817
    @justinasbeinorius8817 Pƙed 7 lety

    thanks for big work you do here!

  • @JamesCoyle95
    @JamesCoyle95 Pƙed 7 lety +13

    You still have a bug in there. At 15:40 you can see the path moves around a red square rather than going through it. It also appears there is a shorter path through that end part.
    You could also take this further by considering that the path needs to be traveled by an entity which is not a single point. That means it can only travel diagonally directly if there is no wall adjacent otherwise it has to travel around the wall taking a path which is somewhere between sqrt(2) and 2 in length depending on the size of that entity.
    Also, ideally you would want an algorithm which can find the choke points and draw the lines between those to give a smooth diagonal path rather than one that is locked to 45 degree increments. This would probably require some sort of ray-tracing algorithm looping through the path and checking to see if there are obstacles between two points

    • @kuskus_th13
      @kuskus_th13 Pƙed 7 lety +1

      RING THE BUG BELL, DAN

    • @Grizix
      @Grizix Pƙed 7 lety +6

      James Coyle It's not a bug, each neighbour is considered as a distance of one, even the diagonals, but he knows that and argued that we can consider as a human for exemple that a step is the same thing orthogonally or diagonally, so moving across or around the red cell at 15:40 are two equally optimal solutions.

    • @76Raby
      @76Raby Pƙed 7 lety +2

      I think too that it is really not the optimal way. The algorithm just before the first red spot should have gone down not to the right. Just by look of it I count 14 steps (blocks) against 17 step that the algorithm did.

  • @NathanBreunig
    @NathanBreunig Pƙed 7 lety +2

    Very cool and very inspiring

  • @krakor92
    @krakor92 Pƙed 6 lety

    Thank you so much, i finally understand!

  • @pepebec
    @pepebec Pƙed 6 lety

    Excelent video you are awesome dude!

  • @deltamico
    @deltamico Pƙed rokem

    Gonna leave here the heuristic for diagonal movement:
    y = vertical distance of current and goal
    x = horizontal distance of currenr and goal
    h = max(x, y)

  • @s45510325
    @s45510325 Pƙed 6 lety

    Very helpful~ Thanks a lot

  • @elpsycongree1132
    @elpsycongree1132 Pƙed 2 lety

    Loved it

  • @ezhilarasinanda5750
    @ezhilarasinanda5750 Pƙed 6 lety

    You are a magician.

  • @DavidLindes
    @DavidLindes Pƙed 10 měsĂ­ci

    I'm not really sure off hand what I would use it for, currently... but one thing I know that does use it is in the game Factorio. I think in several places -- for trains, probably, and certainly for "enemies", coming to attack you... they pick a target destination, and then use A* as a way to find what path to take. I believe they have a whole write-up about it...

  • @nicolascoral8470
    @nicolascoral8470 Pƙed 11 měsĂ­ci

    Thank you for this video. I know it's old but it came up when searching for videos about the A* algorithm.
    I do think there's another bug showing at 15'40. There's an isolated red point near the end. The path goes diagonal bottom right and top right around it. With the distance you chose, the shortest path should be straight through it. It's also showing in other examples you ran.
    Anyway, thank you very much. It was really interesting and well explained. May be it got fixed later.

  • @valinkdevr5520
    @valinkdevr5520 Pƙed 7 lety

    Thank you dude

  • @aaditya4998
    @aaditya4998 Pƙed 3 lety

    man you are awesome ❀

  • @nidoking042
    @nidoking042 Pƙed 2 lety

    There's a significant optimization in calculating the heuristic only once for each Spot, rather than every time you evaluate it - the heuristic value never changes, so it's wasted effort. As for finding neighbors, my preferred method is to spend a bit more space and extend the grid by two in each dimension, filling the outermost cells with walls. Now you don't need to check for existence of neighbors in any direction - there will always be a neighbor in all directions for any non-wall Spot.

  • @josephandres4324
    @josephandres4324 Pƙed 4 lety

    Beautiful

  • @RodrigoNishino
    @RodrigoNishino Pƙed 2 lety

    Awesome

  • @maximilientirard1720
    @maximilientirard1720 Pƙed 7 lety +3

    I think It might be more efficient to add new open paths at the beginning of the open path list. It would (I believe) safe time in cases where there are multiple paths but all of them have the same cost, like the situation in the very beginning of the video (beginning top left, end bottom right, no obstacles, diagonals not alowed). That way, it wall explore only one of all the same-costing paths.

    • @TheCodingTrain
      @TheCodingTrain  Pƙed 7 lety +1

      Great tip!

    • @Dayanto
      @Dayanto Pƙed 7 lety +1

      Was about to say this. In real world applications, it doesn't really matter much since two paths rarely are exactly equivalent, but with a grid based layout, it can become incredibly inefficient not to use a LIFO priority queue.

  • @kuskus_th13
    @kuskus_th13 Pƙed 7 lety +3

    and here I am programming a counter capable of displaying enormous numbers while Dan programs a fully functional algorithm :D

    • @GuardianTam
      @GuardianTam Pƙed 7 lety +2

      KusKusPL we all gotta start somewhere. keep at it man.

  • @coderodion
    @coderodion Pƙed 6 lety +1

    Your videos are nice, since you make complicated things look simple. Also, I want to ask, do you have a degree in CS?

  • @tomburris8380
    @tomburris8380 Pƙed 7 lety

    +The Coding Train, If you had put the start in the middle, it would have shown how the algorithm works better, especially for the first part. Keep up the amazing videos!

  • @hjjol9361
    @hjjol9361 Pƙed 6 lety

    i love your dance in generic.

  • @pianochess1882
    @pianochess1882 Pƙed 5 lety

    By using the taxicab-distance your heuristics will sometimes overestimate the distance (especially since you consider the diagonal steps to have length 1, but it would even if they were sqrt(2)).
    Example. Consider a 3x3 box. Moving diagonally takes 2 steps, but your heuristics would estimate it as 4.

    • @pianochess1882
      @pianochess1882 Pƙed 5 lety

      To fix this, go back to the Euclidean-distance and use sqrt(2) for diagonals. If you want to stick with step length 1 for diagonals use
      h= max(abs(i-x), abs(j-y))

    • @TheCodingTrain
      @TheCodingTrain  Pƙed 5 lety

      thanks for the suggestion!

  • @visintel
    @visintel Pƙed 5 lety

    The heuristic isn’t admissible even with the Euclidean distance. If we assume the goal is on the bottom right neighbor square, the current square would have a heuristic of square root of 2, which is larger than the actual distance (that is 1) since we are adding one after each step anyway

    • @aichabenlahrech635
      @aichabenlahrech635 Pƙed 5 lety

      I ask :
      Why in the beginning of the video the spots moves in same time (i mean the x and y moves in the same same time )?
      Because he have the same (g) and same (distance) ? Every path is optimal and there are no best (g) and distance ?

  • @nayanagarwal5312
    @nayanagarwal5312 Pƙed 4 lety

    People who are trying to implement A* for finding path in a maze try to use Euclidean distance in heuristic rather than Manhattan. Manhattan distance gives you a short path as compared to Euclidean distance when you are considering the diagonals. but if we are considering top right bottom left then no doubt Euclidean distance wins.

  • @gerardjensenolmos7862
    @gerardjensenolmos7862 Pƙed 3 lety +2

    So in 16:36, there is a mistake. On the right bottom part of the grid, he makes a 2 diagonal movement instead of going forward. That's because he didn't ad the g in sqrt(2) when it's diagonal. Am I right?

  • @skundurks9307
    @skundurks9307 Pƙed 2 lety

    you could do some perlin noise to make the walls, im not sure how to implement that tho

  • @quassseabass2770
    @quassseabass2770 Pƙed 7 lety

    Another excellent video, Dan, and loving the new name. I've been building this alongside with Python but it's running painfully slowly, even with all the optimisation I can think of. Do you have any suggestions?

    • @ledues3336
      @ledues3336 Pƙed 7 lety

      Python is possibly one of the slowest languages out there, or at least, so I heard

    • @quassseabass2770
      @quassseabass2770 Pƙed 7 lety

      Le due S It wouldn't surprise me, I'll try it in something like Java and see if I get a better result

  • @kxtbit
    @kxtbit Pƙed 2 lety +2

    two things i would like to mention: the diagonal wall check should be changed because there is a problem with the current design: if a cell had walls to its right and bottom, it could still go diagonally down right and bypass the walls. also, you could probably fix the thing where it goes out in every direction when diagonal movement is not enabled by adding a tiebreaker to the heuristic to keep it on just one path.

    • @souf7409
      @souf7409 Pƙed rokem

      Did you fix the first problem? That it goes in between two walls or ju

    • @kxtbit
      @kxtbit Pƙed rokem +1

      @@souf7409 not sure what you mean, my comment was just a suggestion to the person making the video, i’m not the one who wrote the code

    • @souf7409
      @souf7409 Pƙed rokem

      @@kxtbit I meant: Did you fix the first problem? That it goes in between two walls or touches one corner of the wall. It's easy to mention it, but to fix it is hard ;) If someone knows how to fix it, let me know!

    • @kxtbit
      @kxtbit Pƙed rokem

      @@souf7409 alright so i looked at the github repo and turns out some other people already fixed the bug. but to answer the question, what i was going to do was move the wall check from the main A* function to the getNeighbors function (so that the pathfinder will just work with whatever neighbors it gets) and then add a special check for the diagonal neighbors that checks if it also has a wall on one of the non-diagonal directions making it up. so basically, when it was checking for the up-left diagonal neighbor, it would not only check if there is a wall there but also if there was a wall up or left that would block the diagonal traversal, and if it was then it would count the diagonal as blocked and not a valid neighbor. if you wanted to allow corner-cutting then you could change it to up AND left instead of OR. hope that answers your question!

  • @fiopio2422
    @fiopio2422 Pƙed 2 lety +1

    I love your videos, but in that one there is a bug on the value of steps done, if you move diagonal it should add 1.4, not just 1, otherwise you have the same cost to move sideways than diagonal, and you don't want that, in some paths you can see that this is affecting the performance of the path.

  • @Cfire100
    @Cfire100 Pƙed 6 lety

    Yeah... now i know how i have to implement the A* Algorithm.
    I learned so much from you. Because java script is similar to c#.
    thank you

  • @Nellak2011
    @Nellak2011 Pƙed 3 lety

    What about grids that are general rectangles, instead of squares?
    I have been following along with this, and of course when I try to run it on a rectangle it no longer works.
    It appears that it is trying to see a neighbor that is not on the grid itself.
    "Cannot read property 'wall' of undefined"

  • @Inyourwordwetrust
    @Inyourwordwetrust Pƙed 2 lety

    You are my best friend now.

  • @tomburris8380
    @tomburris8380 Pƙed 7 lety

    He fixed the heuristic which is good, the only thing missing now is he adds 1 to the g-cost every step, even if it's moving diagonally. ( Which should be root(2). )

    • @TheCodingTrain
      @TheCodingTrain  Pƙed 7 lety +1

      This is a good point that I should have covered in more detail.

  • @coderodion
    @coderodion Pƙed 7 lety

    2:24 It's called _*path symmetry*_: on 2D (even with some obstacles) grids there is bunch of paths of optimal cost that make A star visit an entire "rectangle". Assuming the taxicab distance, that is.

    • @TheCodingTrain
      @TheCodingTrain  Pƙed 7 lety

      Thank you for this excellent clarification!

    • @coderodion
      @coderodion Pƙed 7 lety

      Also, more or less famous Jump Point search was developed exactly for dealing with path symmetry in grids.

  • @ThunderDK74
    @ThunderDK74 Pƙed 6 měsĂ­ci

    I'm looking at the time 16:45. Does anyone know a better solution to get a better path where there is only a single red dot... If the diagonal is longer it should not go down and then back up when going right two times (four times) ?? 🙂 Thank you for the tutorials.

  • @qihaosaw4683
    @qihaosaw4683 Pƙed 5 lety

    this one is creating the block by own setting, can i implement this function in google map 

  • @expeng5861
    @expeng5861 Pƙed 4 lety

    hey, why your application goes through the wall.....but finally I know how to write an A-star solution. thanks a lot.

  • @kelvinzhao4960
    @kelvinzhao4960 Pƙed 6 lety

    So what's a better way to add the neighbors?

  • @l1m3s34
    @l1m3s34 Pƙed 6 lety

    yeah thx i impelement it using Java (classes interfaces )) and ect ))) thx youu very much (i love you :D :D :D :D !

  • @robertchen9979
    @robertchen9979 Pƙed 7 lety +4

    For the algorithm to check if something is in the array or not, you can just keep track of it with another boolean array.

  • @roniburju
    @roniburju Pƙed 7 lety

    if i gonna take coding by ms mord hown should i do for that?

  • @archtaurus
    @archtaurus Pƙed 7 lety

    it is different from the A*. you shall try the lowest cost one in the openSet first, right?

  • @5up5up
    @5up5up Pƙed 7 lety +10

    the heuristic needs to be admissible for A* to be optimal (i sound like i know my stuff!)

  • @siekensou77
    @siekensou77 Pƙed 3 lety

    tried jumppoint? jps version of a* is really good

  • @3zdayz
    @3zdayz Pƙed 6 lety

    Hmm thought I had commented that you should generate perlin-noise to give a gray-scale obstacle path....
    I did this; it doesn't work very well... the estimation of how far to go doesn't work very well with gradients... sometimes it's too pessimistic sometimes too optimistic. It's bad to have your predicted length too short or too long; there's a balance in the middle where it does work...

  • @ferdimone521
    @ferdimone521 Pƙed 3 lety

    I have many of motif Dawan culture which i want to apply with p5.js.
    So i need this tutorial and toturials to take the pixel data from a image

  • @whozz
    @whozz Pƙed 7 lety +6

    How about programming a cellular automata?

    • @TheCodingTrain
      @TheCodingTrain  Pƙed 7 lety +8

      Yes, if you search cellular automata and shiffman you'll find a bunch of videos, but I think I should do a new coding challenge one!

  • @otesunki
    @otesunki Pƙed 6 lety

    Combine this with a maze generator!

  • @wazed9468
    @wazed9468 Pƙed 4 lety

    I did this in minecraft turned out to be pretty hard but I managed it (even tough minecraft already uses a* for their ai's thei're just not using diagonal movement in 1.8)

  • @ceorecdeclec9774
    @ceorecdeclec9774 Pƙed 6 lety +2

    how are you running it so fast?
    mine does 3 cells per second and takes 10 minutes to do a 50x50 while yours is done in 10 seconds

    • @kxtbit
      @kxtbit Pƙed 2 lety

      what programming language is it written in? how is the algorithm implemented? did you forget to remove wait statements for your code? could be one of those things, idk but 3 cells per second seems crazy inefficient

  • @souf7409
    @souf7409 Pƙed rokem

    How to prevent that the path travels in between two walls or touches one corner of the wall? It shouldn't be possible! Does anyone know how to code that?

  • @gokselkucuksahin
    @gokselkucuksahin Pƙed 5 lety +1

    diagonal neighbors must cost sqrt(2) times more than non diagonal neighbors. isn't it?

  • @RedCocoon
    @RedCocoon Pƙed 7 lety +1

    You should try to code a pixel circle generator

  •  Pƙed 6 lety

    15:36 If I am not wrong. It stops when it finds the 1st solution. But it can be shorter path, maybe next solution.

  • @WalterZarl
    @WalterZarl Pƙed 7 lety

    Looked like Dwarf Fortress from the thumbnail.

  • @blackburnmichelson6189
    @blackburnmichelson6189 Pƙed 3 lety

    can i do this with c++?

  • @Kalrox1
    @Kalrox1 Pƙed 7 lety +1

    what's the pros and cons of c# & c++? I want to start coding but I don't know which to learn

    • @iofish__
      @iofish__ Pƙed 7 lety +1

      Kalahan Eagle You should probably start programming in JavaScript, Python or C#. C# is the best out of these for desktop applications. JavaScript works in browsers and is for web programming. Python does a 90% of everything and it is the prettiest. C++ has manual memory management which means if you have a degree in computer science C or C++ can be faster than other programming languages, but otherwise you will probably see very little benefit in terms of speed compared to writing good code in a high level language

    • @Kalrox1
      @Kalrox1 Pƙed 7 lety +2

      Matthew Biggs thank you , I have chosen to work with unity I am working on the basics of c# an the unity interface. I am getting help from my uncle whom made a game called "lovers in a dangerous spacetime". have a wonderful day, week, month, year, and decade.

  • @wesvanduine7773
    @wesvanduine7773 Pƙed 7 lety

    Is there a book you would recommend for someone that is a beginner with programing?

    • @TheCodingTrain
      @TheCodingTrain  Pƙed 7 lety

      You can certainly try mine if you like! learningprocessing.com/

  • @deva8496
    @deva8496 Pƙed 2 lety +1

    i will never accept diagonal path. Coincidentally I wrote a* path finding solution for my game i developer in 2015

  • @shashank007sharma
    @shashank007sharma Pƙed 4 lety

    Can someone share github link please

  • @XoIoRouge
    @XoIoRouge Pƙed 5 lety +22

    Maybe if you actually implemented the Pseudo Code correctly, you would actually have optimal pathing.
    EDIT: You realized it at the VERY end, haha!

  • @generaldave7455
    @generaldave7455 Pƙed 7 lety +1

    It's not much different. I just coloured a bit differently and "refactored" to clean up sketch.js.
    github.com/generaldave/A_Star_Simulation
    Also, I'm glad you are getting into machine learning, Daniel. I have recently gotten excited about machine learning and needed a good source of information. As always, your videos are educational and entertaining.

  • @mohammadkazemzadeh2299
    @mohammadkazemzadeh2299 Pƙed 4 lety

    where is the source ? can anyone send it to my?!

  • @tudordumitrescu8707
    @tudordumitrescu8707 Pƙed 7 lety

    How did you get the Processing to auto fill in the functions and all that? It would really help me since I am new to this language.

    • @kuskus_th13
      @kuskus_th13 Pƙed 7 lety

      Tudor Dumitrescu That's p5.js, Processing doesn't do that pretty sure

    • @tudordumitrescu8707
      @tudordumitrescu8707 Pƙed 7 lety

      I have p5.js editing app but it still doesn't fill those words in and color them the same way. Maybe it is just a macOS thing

    • @TheCodingTrain
      @TheCodingTrain  Pƙed 7 lety

      I'm using the Atom editor.

    • @tudordumitrescu8707
      @tudordumitrescu8707 Pƙed 7 lety

      Oh, thanks for the info!

  • @sebastianmestre2145
    @sebastianmestre2145 Pƙed 7 lety +1

    you created a false boolean and then set it to true no matter what and then you tested if it was true. was that a mistake?

  • @bitworld2848
    @bitworld2848 Pƙed 6 lety

    i want that whistle button thing
    i need that whistle button thing
    i need it now

  • @aliceorwell7541
    @aliceorwell7541 Pƙed 7 lety

    @5:43 for where there's no solution you say that's the best path it found. I would have thought the best path would finish closest to the endpoint whereas that looks to show the last evaluated path. How would you go about showing the best path in the case of a no solution grid? Track the fittest incomplete path?

    • @TheCodingTrain
      @TheCodingTrain  Pƙed 7 lety +1

      This is a very good point. Yes I think you are right about tracking the "fittest" incomplete path, the one that is the shortest to end up the closest?

    • @aliceorwell7541
      @aliceorwell7541 Pƙed 7 lety

      I was curious just how easy this would be to implement and it turns out to be really easy. If anyone else is curious I put some code on Github: aliceorwell.github.io/AStar/ The gist of what I did was track which discovered spot has the lowest h and in the event of a no solution render that particular spot's path.

  • @aayushsaini9363
    @aayushsaini9363 Pƙed 7 lety

    Does g map also uses A* algo

    • @coderodion
      @coderodion Pƙed 6 lety

      aayush saini Not necessarily since there are faster algorithms than A*.

  • @TheSkepticSkwerl
    @TheSkepticSkwerl Pƙed rokem

    Diagonal should cost 1.4 otherwise super awesome.

  • @MultiMunding
    @MultiMunding Pƙed 7 lety

    Hey i wanted to create a Sketch that is counting the number of clicks since its Start BUT without having the Sketch window selected. how is it possible?

    • @Texplanations
      @Texplanations Pƙed 7 lety

      I dont think that's possible... but you can use other software to get that info if you just wanna use it for something that is not done with the code

    • @MultiMunding
      @MultiMunding Pƙed 7 lety

      TechNerd01 thank you for your answer but i wanted to use it in a Screenshot making program like gyazo

    • @Texplanations
      @Texplanations Pƙed 7 lety

      Could you explain in details? I may be able to help... I dunno

    • @MultiMunding
      @MultiMunding Pƙed 7 lety

      TechNerd01 i already looked it Up and it Looks like there is a Java library for global hotkeys but i have no clue on how to Install it

    • @Texplanations
      @Texplanations Pƙed 7 lety

      Its a java library so you're gonna have to use processing and not p5js

  • @hudson5365
    @hudson5365 Pƙed 3 lety

    Ah, it's wonderful when it works, isn't it?

  • @ledues3336
    @ledues3336 Pƙed 7 lety

    What? When did you change your channel's name?

    • @kuskus_th13
      @kuskus_th13 Pƙed 7 lety

      Le due S He changed it a few days ago due to trademark issues with something called "Reading Rainbow"

  • @alekmoth
    @alekmoth Pƙed 7 lety

    "return, and that is going exit out of this function instantly. and then I have noLoop on the next line." .. meeep.. are you even listening to yourself?

  • @sebastiantamayoguzman552
    @sebastiantamayoguzman552 Pƙed 3 lety

    nosew? guapo

  • @KaletheQuick
    @KaletheQuick Pƙed 7 lety

    Why is it a train now :(

  • @fcbtomtom7132
    @fcbtomtom7132 Pƙed 7 lety

    First

  • @MarsCorporations
    @MarsCorporations Pƙed 5 lety

    you should not be able to pass "between" two obstacles just because you can walk diagonally.

    • @aichabenlahrech635
      @aichabenlahrech635 Pƙed 5 lety

      I ask :
      Why in the beginning of the video the spots moves in same time (i mean the x and y moves in the same same time )?
      Because he have the same (g) and same (distance) ? Every path is optimal and there are no best (g) and distance ?

  • @jovanadidharma9222
    @jovanadidharma9222 Pƙed 7 lety

    Can someone combine the maze generator with deez

    • @l1m3s34
      @l1m3s34 Pƙed 6 lety

      for maze generator use first depth search algoritm

  • @wightknight7056
    @wightknight7056 Pƙed 4 lety

    No, you didn't. Not working without diagonals

  • @dibayuin7859
    @dibayuin7859 Pƙed 7 lety

    PLEASE MASTER CODING TRAIN REPLY ME :((
    I have processing and how to add p5 js ? where's the link video of that turtorial ??
    I need reply somebody help :(
    I have to download p5 js and processing but I don' t know to use it
    pardon my bad english

  • @sator666666
    @sator666666 Pƙed 7 lety +1

    I hate this style of code, I mean using {
    }

  • @bellyboydiao2460
    @bellyboydiao2460 Pƙed 7 lety

    is he a computer science ??

  • @roniburju
    @roniburju Pƙed 7 lety

    if i gonna take coding by ms mord hown should i do for that?

  • @bitworld2848
    @bitworld2848 Pƙed 6 lety

    i want that whistle button thing
    i need that whistle button thing
    i need it now