Need help finding a way!

I am making a puzzle game that needs some way to direct the selected units to their destination. This is my first case involving any way to find the path, so I chose the aStar method, which was the easiest for me. (thanks to this wonderful page http://www.policyalmanac.org/games/aStarTutorial.htm ). I came quite far, farther than I expected, but there are still some minor issues.

I could write a long explanation that no one would understand, but instead I uploaded my Flash project so you can see: http://www.martinowullems.com/pigsplode/pigsplode%20flash.html

Select the pig, and then select the second tile to make it walk (not the bottom tiles, they are bugged: P). Dark tiles are unusable. Red tiles are those that belong to the generated path. I seem to be on the right track, I feel like I'm making a little mistake. I felt something was wrong with choosing the best node function (findNextNode).

I looked at the code for too long and made no progress. I tried to look at the implementation of other people, but it is always difficult for me to understand how other people work.

Any help would be greatly appreciated, I want to go to the project!

I made wonderfl version so you can check and play with the code: http://wonderfl.net/c/hRtO

+4
source share
1 answer

In the placeNode() function, if the current node is already in the open list, you do not change the parent node when the G value is improved using the new node parent.

 //if it is already on the open list - check if it is a better option if (node.G > parentnode.G + 10) { //recalculate node.parentNode = parentnode; //add this line node.G = parentnode.G + 10; node.F = node.G + node.H; } 

This may not be the only problem, but it looks like a source of potential errors. Hope this helps.

0
source

All Articles