Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

How would i implement an A star algorithm for a game that i'm making on the android in java? i'm looking for a pre-made A star API in java with classes and methods to call. i don't want to have to code from scratch.

share|improve this question
    
Not sure why this got a down-vote, it's a pretty straightfoward question to answer. Anyway, while I'm sure there are plenty of existing A* implementations done in Java, I implemented it pretty easily just by following along with this explanation policyalmanac.org/games/aStarTutorial.htm –  jhocking Feb 5 '12 at 20:13
    
Incidentally, I did it in ActionScript 3, which may be easy to port to Java newarteest.com/flash/astar.html –  jhocking Feb 5 '12 at 20:15
    
thanks i'll read over the articles, crack my knuckles, and get it done ! –  kdavis8 Feb 6 '12 at 4:29

2 Answers 2

up vote 1 down vote accepted

Like others have commented, it might be easier (not to mention fun) to write your own implementation of A* (use the link jhocking provided, I learned it from there, and highly recommend it - http://www.policyalmanac.org/games/aStarTutorial.htm).

However if you definitely want a pre-existing library, here are some alternatives: - http://www.stackframe.com/software/PathFinder (scroll to the bottom for the download) - http://www.ludumdare.com/compo/2011/12/16/java-pathfinding-library/ (probably not an ideal solution, but it would help you in writing your own)

But the one I like best is Critter AI, which is a port of Recast for .NET and Java. The one for Java is more intended for study, but is still awesome. http://www.critterai.org/

Good luck! :)

share|improve this answer
    
thanks, the reason i want a pre existing api is because, as my game gets heavy,and i am implementing my own algorithm,im sure it will become error prone ; where as code that has already been implemented various times by others is well, go to go. –  kdavis8 Feb 6 '12 at 4:33
    
yeah i agree with you on that! - When i was learning about pathfinding I wrote my own simple class. But now that im working on a pretty big project, its nice to use a well-known and tested library like recast. Documentation + help from others is so good –  Aralox Feb 6 '12 at 11:15

Ignore, if you are done.

I have implemented "8-puzzle" using pure A* implementation. You can follow the same searching pattern for your game.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.