0
\$\begingroup\$

I Tried to create AStar Algorithm and i'm already finished but i didnte work cause of this line :

// The distance from start to a neighbor.
// The "dist_between" function may vary as per the solution requirements.
tentative_gScore := gScore[current] + dist_between(current, neighbor)
if tentative_gScore >= gScore[neighbor]
   continue     // This is not a better path.

In my Case tentative-GScore is everytime higher than gScore of the neighbor.
Here is my Code:

foreach(ANote neighbor in current.adjacted)
   {
      if (closedSet.Contains(neighbor))
         continue;

      if (!openSet.Contains(neighbor))
         openSet.Add(neighbor);

      double _gScore = current.g + 1;

      if (_gScore >= neighbor.g)
         continue;

      neighbor.parent = current;
      neighbor.g = _gScore;
      neighbor.h = getDistance(neighbor, end);
}

Can someone explain me where i failed ?
I used the Wikipedia Site of AStar : Wiki

\$\endgroup\$

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.