Attempt at A star algorithm not working

Started by
11 comments, last by DejaimeNeto 10 years, 4 months ago

Your getPoint and getNodeFromCoord functions don't always return a value. (Possibly a C heirloom that they can be compiled.) They don't return values if the coordinates you're searching for is not in the list. I assume that out of bounds coordinates are not listed, so their behavior are undefined in this case. And that might cause your problem. Please try if adding proper boundary checking in aStar and error checking in getPoint and getNodeFromCoord solve your problem or not.

Advertisement

I understand, but that's not the problem. It is the pathfinding that isn't working. It is not going the right way. Whilst I appreciate these tips for improving my code, the real problem is that the algorithm doesn't work. I'm thinking there might be a problem calculating the F G and H scores, or a problem in the code which looks at adjacent nodes

I understand, but that's not the problem. It is the pathfinding that isn't working. It is not going the right way. Whilst I appreciate these tips for improving my code, the real problem is that the algorithm doesn't work. I'm thinking there might be a problem calculating the F G and H scores, or a problem in the code which looks at adjacent nodes

We'll have a hard time trying to help you find the problem on your a-star implementation if we don't know what your code is doing. There could be problems in the list implementation, score calculations, walkable data checking; to name a few...

This topic is closed to new replies.

Advertisement