PDA

View Full Version : Pathfinding in a dungeon/maze


Atur
02-21-2009, 10:41 PM
Lets say I a number of n' points in 3d space with XYZ values.

All points are linked somehow,
Some directly, some through other points.
For instance:
A---B
|
E---------F
|
C---D

I can go from A to B directly, I can only go from D to A through C and E.

My question, lets say I have hundreds of points, and I know to what points each point is linked directly, how do I find the shortest route(shortest in distance / or the amount of points you to go through).
How do I teach the computer AI code to find a route quickly from point X to point Y?

I require this for mob AI.:o

Thank you in advance for any help with this routing issue.

Ciubhran
02-21-2009, 10:48 PM
In AS3 you can probably implement the A*-algorithm easily.

That's what I use when I do pathfinding. It's kinda tricky, but it's the best for finding the fastest route.

Atur
02-21-2009, 11:30 PM
In AS3 you can probably implement the A*-algorithm easily.

That's what I use when I do pathfinding. It's kinda tricky, but it's the best for finding the fastest route.Yup, I'm using AS3 for this.
Thank you for your help.
I googled it up.

I will figure it out.

Right now, I have an array of objects.

Each "point" object in the array is "linked" to one or more "points" by an array of "point" IDs.

So D for instance only knows C and E knows C, A, and F.

... I think your answer is great.

I'll try to figure it out tomorrow and see if I can figure out how to get it working, and maybe continue to post about what I'm doing.

kkbbcute
02-22-2009, 04:00 AM
Actually if you intend on having a very elaborate game, A* may not be the best option as it really lags a whole lot before figuring out the path. So a tip is to make your character walk in the rough direction of where it's supposed to be heading while calculating the path, this way the reactions of your AI don't seem to "lag" so much.

Atur
02-22-2009, 05:31 PM
Actually if you intend on having a very elaborate game, A* may not be the best option.I do have lots of rooms.. perhaps I should store the correct routes in the memory and calculate them beforehand so the game will run smoothly.

Thanks for the help.