Found a bug ! And corrected it

Bug,
- you have a waypoint0, with mutiple connections,
one to waypoint1 : "connection_0_1"
one to waypoint2 : "connection_0_2"
- let's ask the path by nodes from waypoint0 to waypoint1
it will tell us that the connection is "connection_0_2"
why ?
for ( connection in currentNode.connections )
{
var tentScore:Float;
neighborNode = connection.to;
if ( neighborNode == null )
continue;
if ( closedSet.indexOf( neighborNode ) > -1 )
continue;
tentScore = currentNode.g + connection.cost;
if ( openSet.indexOf( neighborNode ) < 0 )
openSet.push( neighborNode );
else if ( tentScore >= neighborNode.g )
continue;
neighborNode.parent = currentNode;
neighborNode.parent.activeConnection = connection;
neighborNode.g = tentScore;
neighborNode.f = tentScore + costEstimate( neighborNode.r, neighborNode.c, goalRow, goalCol, graph.norm );
}
it is because of this
neighborNode.parent = currentNode;
neighborNode.parent.activeConnection = connection;
So I changed it to
neighborNode.parent = currentNode.clone();
neighborNode.parent.activeConnection = connection;
and added the function clone to GraphNode
public function clone(){
var gn = new GraphNode(r,c,name);
gn.activeConnection = activeConnection;
gn.parent = parent;
gn.connections = connections;
return gn;
}