Skip to main content
gamedev.net
🔒 Locked

Problem with A* path finding algorithm

Started by skwee 3 replies 700+ views
Original Post
skwee
skwee
Hello. I wrote a class that find path using A* algorithm, but i got some problems i cant make it work, it just do stupid thing and program stuck. Here is the code of the algorithm: http://pastebin.ca/373163 I used a basic Linked List Interface that i learned at school and its 100% work. The two structs that are not mentioned in the code is PosType that define a pointer to next node and ListType that define a list. I cant find the problem.
I would love to change the world, but they won’t give me the source code.
ToohrVyk
ToohrVyk
Please describe the symptoms of the problem, along with as much debugging information as you can provide.
skwee
skwee
Ok i'll try:
My person starts form Center of screen, i mean of my screen is 640*480 when you start rune the program he will appear at x=320 y=240. Mouse coordinates when you click is correct i checked it.
Next step must be when you press the mouse at some map area my class should find a path from start point to point that was clicked. When i pressed mouse button my person moves to left up corner and at some cases the program stuck. I have no idea why it happened and how to fix it. If you need some more information ask a specific question and i try to answer. Thank a lot for helpers.
I would love to change the world, but they won’t give me the source code.
Palidine
Palidine
do you check for the "done" condition of your GetStep function in whatever code places your entity in the correct position.

When GetStep is done it returns:

p.x = -1;
p.y = -1;

I'd put a breakpoint there and step to see what logic gets executed after that code is hit.

-me
skwee
skwee
Actually you found another bug :)
I need to remove the step that done from Path list, but i have a check at main
if(player.GetCreatureAction() == WALKING)
{
p = path.GetStep();
if((p.x != -1) && (p.y != -1))
{
px = p.x;
py = p.y;
}
else
player.SetCreatureAction(STANDING);
}

Ill and necessary line and update this post if the problem is solved.

UPDATE:
new code can find there
http://pastebin.ca/373434
I still have the problem.

[Edited by - Minios on February 26, 2007 1:30:31 PM]
I would love to change the world, but they won’t give me the source code.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.