# Thread: AI Path Finding.

1. ▼ dafuq did I do?
Join Date
Dec 2013
Posts
203
Rep Power
0

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

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)

2. Senior Member
Join Date
Jan 2013
Posts
164
Rep Power
2

## 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

3. ## 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
Last edited by liluma; 01-15-2014 at 07:37 AM.

4. ## Re: AI Path Finding.

A simple Dijkstra labeling algorithm can do the job (it'll find an optimal solution).

kind regards,

Jos

5. ▼ dafuq did I do?
Join Date
Dec 2013
Posts
203
Rep Power
0

## Re: AI Path Finding.

I have decided I am going to implement the A* path finding algorithm.

6. Just a guy
Join Date
Jun 2013
Location
Netherlands
Posts
4,014
Rep Power
6

## Re: AI Path Finding.

Good choice, IMO. Its a nice challenge for the brain too.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•