# AI Path Finding.

• 01-15-2014, 03:45 AM
zFollette
AI Path Finding.
So I have an idea for path finding, I just don't know where to start to turn it into code. Say you have point A and point B, all of the tiles in the map would have assigned numbers. The numbers represent the distance from point A to point B. Here is a graphical representation of what I want to complete.

Attachment 5854

As you can see, starting from point A, 7 is the smallest number out of the surrounding tiles, I would move to a tile with the number 7. I would then re-evaluate the grid, 6 would become the next smallest number, and so on. As you can see in my picture, the highlighted paths are both the smallest possible paths from point A to point B, assuming I can only move in a linear motion. It does not matter which path I choose because they are equal. So, where would I even start with this implementation? (-1 is a barrier and will not be considered in the path finding)
• 01-15-2014, 04:12 AM
pj6444
Re: AI Path Finding.
I think you might be better off going to the Java Gaming Forums to do this. They might know some methods to use for path finding.
Java-Gaming.org - home of the largest java game developer community
• 01-15-2014, 08:34 AM
liluma
Re: AI Path Finding.
depending on what is your priority you could give following algoritms a look:

breadth first algorithm ==> Breadth-first search - Wikipedia, the free encyclopedia (this will find a solution if there is a solution, but not necessarily the best (shortest, least pathcost) route)
depth first algorithm ==> Depth-first search - Wikipedia, the free encyclopedia (this will find a solution if there is a solution, but not necessarily the best (shortest, least pathcost) route)
or the a* algorithm (which i would suggest since this is prob the most efficient) ==> A* search algorithm - Wikipedia, the free encyclopedia

and bassicly, you are gonna make a tree or graph from you grid, and traverse that tree or graph with the chosen algoritm.

hope this helps a bit. ;)

grtz liluma
• 01-15-2014, 09:38 AM
JosAH
Re: AI Path Finding.
A simple Dijkstra labeling algorithm can do the job (it'll find an optimal solution).

kind regards,

Jos
• 01-16-2014, 12:03 AM
zFollette
Re: AI Path Finding.
I have decided I am going to implement the A* path finding algorithm.
• 01-16-2014, 10:17 AM
gimbal2
Re: AI Path Finding.
Good choice, IMO. Its a nice challenge for the brain too.