1

Do someone want to explain me (in pseudocode too) how the pathfinding/a* algorithm can be implemented in Python? I searched all over the internet but I am not able to understand how to calculate H-cost or G-cost. I found some source code, but it is too difficult for me (I am still a newbie).

Let's think I have a map like this:

'''
S0000000000000000000000000100000000000
00000000000000000000100000001000000000
10000111110101000001100000001000000000
01111100010001000010100000010000000000
00000100001111100100100001110000110000
00001100000001011000000100000001000000
00000100000000101000000000011110000001
00000010000000000111111111100000000011
00000001000000000000000001100000111100
00000000110000000000000000010011000000
00000000010000000001100000001000000000
00000000010000000000110000000111111000
00000000010000000000010000000000000000
00000000011000111111111111111111111111
000000000100000110000010000000000000E0
00000000001100000100001000000000000000
00000000000100000011000000000000000000
00000000000010000000000000000000000000
'''

Where 1s are obstacles, 'S' is the starting point and 'E' is the end. How can I implement that algorithm? It would be great also if you can link an internet page who explain it in a easy way.

4
  • 1
    A nice page with animations and stuff. Commented Jan 4, 2018 at 16:42
  • Does this help? stackoverflow.com/questions/40871864/… Or this stackoverflow.com/a/22899400/4014959 ? Commented Jan 4, 2018 at 16:44
  • Thank you for the two links, now I read those pages and see! Commented Jan 4, 2018 at 16:55
  • The g-cost is the cost of the path already "walked", while the h-cost is the estimation of the remaining cost of the path to reach the goal. They are dependent on the domain you apply the a* algorithm Commented Jan 5, 2018 at 14:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.