A* Search Algorithm

hello ...HELP !!!

Having a slight problem implementing the A*Search in Java. We have it calculating the straight line distance from nodes to goal using .cost, however we need to get individual path distances between the nodes, preferably without hardcoding. We were thinking of using the addEdge method to create the edges and within this method then getting the path distance. But we just don't know where to start with it.

[438 byte] By [aoifes272a] at [2007-9-27 23:46:46]
# 1

to get the g(n) function (actual cost from root to node 'n') you will need to add the distance from where you are to the distance to the new node.

So if you start from root your initial g(n) will be 0. Then when you create the node to the proper path then g(n) will be some distance (for example 200). Then from the second node to the third node g(n) will be 200 + the distance from node 2 to node 3. Make sense? I'm not sure how to code this dynamically, you may need to create a file of some sort that will store these node distances.

Since you don't want hard coding then simply having a data file will make sense for the problem.

I hope this made sense

wheaton84a at 2007-7-7 16:32:09 > top of Java-index,Other Topics,Algorithms...