A* (A-star) implementation in AS3

若如初见. 提交于 2019-12-06 09:33:56

Could you explain what's the purpose of these lines:

if (cNode.dirArray[i] >= 4)
{
 neighborNode.g_score -= 4;
}

A* is for problems where costs are always positive i.e. cost of paths is monotonically increasing.

Another thing to check, regarding optimality, is that distFunction() is returning always a value which is lesser or equal than the actual cost to reach the goal (i.e. the heuristic is required to be admissible so A* can guarantee it will find optimal solutions).

I don't know anything about AS3 at all - so I can't comment on the priority queue usage.

There is a fast implementation here: https://github.com/tomnewton/AS3AStar

lucky one

Try out http://script3.blogspot.com/2010/04/star-path-finding-algorthim-in.html you can find there powerful a* pathfinding class with smooth pathfinding option.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!