1
\$\begingroup\$

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.

\$\endgroup\$
3
  • \$\begingroup\$ 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 \$\endgroup\$
    – jhocking
    Commented Feb 5, 2012 at 20:13
  • \$\begingroup\$ Incidentally, I did it in ActionScript 3, which may be easy to port to Java newarteest.com/flash/astar.html \$\endgroup\$
    – jhocking
    Commented Feb 5, 2012 at 20:15
  • \$\begingroup\$ thanks i'll read over the articles, crack my knuckles, and get it done ! \$\endgroup\$
    – kdavis8
    Commented Feb 6, 2012 at 4:29

2 Answers 2

2
\$\begingroup\$

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 - Link).

However if you definitely want a pre-existing library, here are some alternatives:

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! :)

\$\endgroup\$
3
  • \$\begingroup\$ 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. \$\endgroup\$
    – kdavis8
    Commented Feb 6, 2012 at 4:33
  • \$\begingroup\$ 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 \$\endgroup\$
    – Aralox
    Commented Feb 6, 2012 at 11:15
  • \$\begingroup\$ The biggest problem I find when simply posting links which is the situation with this post in particular is that it becomes useless once those links are no longer available. The provided link from policyalmanac.org is dead. \$\endgroup\$ Commented Oct 24, 2015 at 11:08
0
\$\begingroup\$

Ignore, if you are done.

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

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .