Home > database >  A* implementation
A* implementation

Time:03-20

I'm trying to implement A* algorithm and I'm following the pseudocode from wiki https://en.wikipedia.org/wiki/A*_search_algorithm#Pseudocode I'm stuck at this part tentative_gScore := gScore[current] d(current, neighbor) what exactly is the d() function supposed to do? d(current,neighbor) is the weight of the edge from current to neighbor but I don't get what they mean by that. In my case current and neighbor would be states(I'm building a snake game which is playing on its own) of the head of the snake. So lets say current is 15 and neighbor is 25, so d(15, 25) what should the function return?

CodePudding user response:

d is the distance to the next vertex in your graph. If you are on a regular square grid, it’s always 1.

  • Related