Solving 8 puzzle with A* search

Поділитися
Вставка
  • Опубліковано 28 вер 2024
  • Made in March 2018
    Link of code: github.com/Jan...

КОМЕНТАРІ • 52

  • @Lilowillow42
    @Lilowillow42 3 роки тому +5

    Great explanation, thank you! I also could relate a lot when I saw the the clock, lol. There ain't no rest for coders.

  • @oamarkanji3153
    @oamarkanji3153 6 років тому +39

    @2:46 I think the manhattan distance should be 3 as the empty space needs to move one to the left then two down, therefore f should be 4.

    • @kimbokjay
      @kimbokjay 5 років тому

      I'm still confused about this step. Shouldn't be the the H value be 1? Cause the #2 just moved once, going to the right.

    • @HarshPanchal321
      @HarshPanchal321 5 років тому +2

      Same, I was going to comment the same Oamar

    • @danteeep
      @danteeep 5 років тому +2

      @@kimbokjay H is the distance between its current state to the goal state. so it needs to travel to bottom right. that's 3 moves. right down down. or you can go down down right. same thing. So H should be 3 here not 2 as shown on the video

    • @kimbokjay
      @kimbokjay 5 років тому +2

      @@danteeep Yeah, that's where I was confused because it should be 3 and the video shows 2.

    • @stanleymuzhuthettu9309
      @stanleymuzhuthettu9309 4 роки тому +5

      the left child of the root should have a score of 4. G = 1 H = 3. the right child of the root is correct. Remember you don't count the empty space towards your heuristic because you always want your heuristic score to always be an underestimate.
      This guy does a pretty good video explaining why.
      ua-cam.com/video/6TsL96NAZCo/v-deo.html

  • @khoironi5954
    @khoironi5954 3 роки тому

    Big thanks. It's a best reference that i ever seen for my A* algorithm task

  • @bindushreesiri9876
    @bindushreesiri9876 2 місяці тому

    Can I get the code for implementing the tree structure

  • @rahulratra6672
    @rahulratra6672 5 років тому +23

    One of the best explanation i have found in internet so far

  • @qingdong3264
    @qingdong3264 5 років тому

    Nice video. Please upload more!!!

  • @dipkumardas3941
    @dipkumardas3941 Рік тому

    Great explanation ❤

  • @horizon-achilles5819
    @horizon-achilles5819 3 роки тому

    Thank you. Great job

  • @kempisabel9945
    @kempisabel9945 4 роки тому

    thank you so much! this was so helpful

  • @hongboxin2099
    @hongboxin2099 6 років тому

    it helps a lot, thank you very much!!

  • @michaeltruong405
    @michaeltruong405 3 роки тому

    What if 2 paths have the same distance?

  • @pulbring
    @pulbring 4 роки тому

    thanks

  • @akashsahu933
    @akashsahu933 5 років тому

    good for just explaining the basics and nothing else

  • @echoanatolia5721
    @echoanatolia5721 5 років тому

    What G represent , i did not actually get it

    • @tonyli5851
      @tonyli5851 5 років тому +1

      G is the cost of the node

    • @josteveadekanbi9636
      @josteveadekanbi9636 3 роки тому +2

      @@tonyli5851 I don't get it too, It seems irrelevant since it's the same for every node to be compared in each traverse.
      help

  • @sujith_TwiceOnce
    @sujith_TwiceOnce 13 годин тому

    good explanation. Much appreciated

  • @Boomerangry
    @Boomerangry 5 років тому +2

    I tested with these input values ​​and the algorithm failed to solve:
    board = [[8, 5, 2],[7, 6, 4],[0, 1, 3]]
    Waited about 10 minutes and was not able to find a solution.
    But other entries less shuffled he solved quickly.
    Thanks for sharing, it helped to improve my college work.

    • @richardmedzihradsky7952
      @richardmedzihradsky7952 2 роки тому +4

      late reply, but for anyone with similar question: these puzzles basically have 2 possible shuffle states: solvable and unsolvable. Basically, if you just switch 2 neighboring tiles (for example [[1, 3, 2], [4, 5, 6], [7, 8, 0]]), the puzzle becomes impossible to solve. The same applies to the example you've given. When I switched 1 and 3 (since they're neighboring), the solution was identified.
      Yes, it would be nice to add a feature that would prevent the program from endlessly trying to solve an impossible puzzle. But since we're practically given the whole code, I consider it a suitable challenge for everyone who wants to really understand how this program works to do that on their own.

    • @glory9605
      @glory9605 2 роки тому

      @@richardmedzihradsky7952 nice work🤝

  • @Anshul_Aggarwal
    @Anshul_Aggarwal 5 років тому +2

    Excellent Tutorial! You saved the day :D

  • @薇季芬
    @薇季芬 9 місяців тому

    1:23
    Two very important value
    Cost(number of steps taken to current state)
    1:32
    Estimate distance from current state to goal state
    1:39
    Manhatan distance
    垂直距離 加上 水平距離
    2:23
    H value is the total Manhattan distance of all vertex except for empty vertex
    2:37
    A star search uses the sum of G and H as a score to determine which go next

  • @oxymoron6701
    @oxymoron6701 2 роки тому

    Your code is slow and inefficient. You can solve 8-puzzles with A*, or IDA, but this approach starts to fail terribly once you want to solve bigger puzzles. Also, Manhattan distance alone is not sufficient as a heuristic when using A*

  • @joydip6670
    @joydip6670 5 років тому +1

    Thanks Jinyue !! Thanks a lot

  • @t.mproductions6665
    @t.mproductions6665 3 роки тому

    AttributeError: module 'time' has no attribute 'clock' Shows This Error

  • @leenabhandari5949
    @leenabhandari5949 6 років тому

    What is the difference between branch and bound method and A* for solving this problem?

  • @Momo-qr3rd
    @Momo-qr3rd 2 роки тому

    Thank you very much. You explained it very well

  • @rayslaiweishi531
    @rayslaiweishi531 2 роки тому

    thanks for the code very cool

  • @jeanreinhold4564
    @jeanreinhold4564 3 роки тому

    Best explanation on UA-cam

  • @sreeloykrdas8921
    @sreeloykrdas8921 5 років тому

    Thanks alot , nice explanation, best Regards :)

  • @linalala292
    @linalala292 3 роки тому

    how to set the goals?

  • @mostu1009
    @mostu1009 2 роки тому

    Thanks

  • @justinvalentine9181
    @justinvalentine9181 2 роки тому

    Goated

  • @qipingran5354
    @qipingran5354 3 роки тому

    Great vedio

  • @vishalambavade8539
    @vishalambavade8539 5 років тому

    Thanks for sharing the code. It really helped me!!

  • @saitejaballa6759
    @saitejaballa6759 4 роки тому

    What happens if the manhatten distance is same for two cases?

    • @angelzacarias8886
      @angelzacarias8886 3 роки тому

      It will start exploring the first one, if it fails (I mean it ends up into a blind alley) then it will start rollback into past options.

  • @EdsonZandamelaa
    @EdsonZandamelaa 5 років тому

    Excellent tutorial!

  • @oleersoy6547
    @oleersoy6547 4 роки тому

    This is AWESOME!

  • @rudranilghosh2187
    @rudranilghosh2187 3 роки тому

    I love Chinese Taiwanese