Advertisement Jump to content
Sign in to follow this  
AndyArmstrong

A Star Search Algorithm in a Java game as an example!

This topic is 1786 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi!

 

I am looking for an example Java project which uses AStarSearch preferrably on a tile / grid based 2d game so I can use it as a basis for understanding the implementation of A Star Search.

 

I know there are sources online explaining how to implement A* in java but these are standalone examples and I am finding incorporating A* into my work rather difficult.

 

Hopefully somebody can share a project I can use as an example.

Share this post


Link to post
Share on other sites
Advertisement

Hi!

 

I am looking for an example Java project which uses AStarSearch preferrably on a tile / grid based 2d game so I can use it as a basis for understanding the implementation of A Star Search.

 

I know there are sources online explaining how to implement A* in java but these are standalone examples and I am finding incorporating A* into my work rather difficult.

 

Hopefully somebody can share a project I can use as an example.

 

A* isn't overly complex, what is making it difficult to incorporate?

Share this post


Link to post
Share on other sites

When I coded mine, I used this one as a guide:

 

http://www.policyalmanac.org/games/aStarTutorial.htm

 

Shameless propaganda:

 

In my blog there is an example in C (uses a linked list as OpenList, which is not fast, better use a heap instead, but can be useful):

http://16bitsflag.blogspot.com.br/2012/09/a-implementation-for-grids-in-c.html

 

To integrate with your world, you probably will need to create a isWalkable method, that, given a grid coord it tells you if that cell is walkable or not. This should be enough if you don't need a weight based pathfinding (in other words, walking on any cell is as hard as walking in any other).

Edited by KnolanCross

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!