Solving 8 puzzle with A* search

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 มี.ค. 2018
  • Made in March 2018
    Link of code: github.com/JaneHJY/8_puzzle

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

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

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

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

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

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

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

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

    @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.
      th-cam.com/video/6TsL96NAZCo/w-d-xo.html

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

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

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

    Excellent Tutorial! You saved the day :D

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

    Nice video. Please upload more!!!

  • @user-nl4ry3wb1x
    @user-nl4ry3wb1x 5 หลายเดือนก่อน

    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

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

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

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

    Excellent tutorial!

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

    thank you so much! this was so helpful

  • @Momo-qr3rd
    @Momo-qr3rd 2 ปีที่แล้ว

    Thank you very much. You explained it very well

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

    it helps a lot, thank you very much!!

  • @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 ปีที่แล้ว +3

      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🤝

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

    Best explanation on TH-cam

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

    Thanks Jinyue !! Thanks a lot

  • @horizon-achilles5819
    @horizon-achilles5819 3 ปีที่แล้ว

    Thank you. Great job

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

    This is AWESOME!

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

    Great explanation ❤

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

    thanks for the code very cool

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

    Great vedio

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

    Thanks alot , nice explanation, best Regards :)

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

    how to set the goals?

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

    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.

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

    thanks

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

    Thanks

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

    What if 2 paths have the same distance?

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

      I think you pick the one on the left

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

    Goated

  • @t.mproductions6665
    @t.mproductions6665 3 ปีที่แล้ว

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

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

    good for just explaining the basics and nothing else

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

    What G represent , i did not actually get it

    • @tonyli5851
      @tonyli5851 4 ปีที่แล้ว +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

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

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

    I love Chinese Taiwanese