A* Algorithm Help

Put your problem here if it does not fit any of the other categories.

A* Algorithm Help

Postby noobles » Tue Mar 10, 2009 3:57 pm

Hey guys, I'm trying to write a game for the Android that utilizes a little path finding but unfortunately I can't get my code to run properly. I've been reading up on the algorithm in various books and websites and I believe I understand how it works but I can't seem to get my implementation to work properly.

I've even modeled my version according to the pseudo-code on wikipedia since it appears to be the simplest pseudo-code I could find regarding the A* algorithm.
http://en.wikipedia.org/wiki/A*_search_algorithm

I am aware that google has a few working implementations but I'd love to tackle the problem on my own with a little nudge in the right direction.

If you can help, please let me know what's wrong. I've been up for 72 hours trying to wrap my head around it.
Attachments
Node.java
The node class.
(1.2 KiB) Downloaded 59 times
Main.java
The main entry point.
(2.41 KiB) Downloaded 90 times
noobles
Freshman
Freshman
 
Posts: 5
Joined: Tue Mar 10, 2009 3:47 pm

Top

Postby fakeSchwiz » Tue Mar 10, 2009 5:59 pm

what exactly is going wrong? One thing I notice, is that if you come across a node on the closed list. Before you skip it and continue you should first check if its current cost is less than the current over all distance traveled. If it is less you take it off the list. you also want to do the same if you come across an item on the open list. Otherwise I believe you are doing Bestfirst. other than that, at glance every thing looks good, although I admit I am very new to java and the only a* i have coded was in c#
fakeSchwiz
Freshman
Freshman
 
Posts: 7
Joined: Tue Mar 10, 2009 5:48 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 20 guests