Jump to content

  • Log In with Google      Sign In   
  • Create Account


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

  • You cannot reply to this topic
4 replies to this topic

#1 TheSituation   Members   -  Reputation: 94

Like
0Likes
Like

Posted 26 February 2014 - 05:56 PM

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.



Sponsor:

#2 ferrous   Members   -  Reputation: 931

Like
0Likes
Like

Posted 26 February 2014 - 08:30 PM

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?



#3 TheSituation   Members   -  Reputation: 94

Like
0Likes
Like

Posted 27 February 2014 - 02:25 AM

My confusion is where do I create my original list of Nodes....I am using this tutorial : https://code.google.com/p/a-star-java/source/browse/AStar/src/aStar/AStar.java?r=7 But I am unsure where I create my AStarNode list for the WorldMap object seeing this integrated into practice would absolutely help.


Edited by TheSituation, 27 February 2014 - 02:29 AM.


#4 KnolanCross   Members   -  Reputation: 1064

Like
2Likes
Like

Posted 27 February 2014 - 08:20 AM

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, 27 February 2014 - 08:23 AM.

My blog on programming and games.
http://16bitsflag.blogspot.com.br/

#5 TheSituation   Members   -  Reputation: 94

Like
0Likes
Like

Posted 27 February 2014 - 06:18 PM

Wow what a well written considerate article - many thanks really enjoyed reading it. Now to puzzle over moving it into Java!







PARTNERS