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

Started by
3 comments, last by AndyArmstrong 10 years, 1 month ago

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.

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?

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.

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

Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).

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

This topic is closed to new replies.

Advertisement