Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Need Some Help With AI

Author
Message
ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 30th May 2009 02:28 Edited at: 30th May 2009 02:30
Hello, I am looking to create an AI for my RPG game and have run into some problems. I haven't actually started coding the AI yet (I only want to implement being able to have the AI be able to choose a path path to get from A to B to start with). The problem I am having is essentially getting my AI idea to work in a 3D environment, such as having the AI be capable of climbing stairs or dealing with buildings that have multiple floors.

Right now I have 3 ideas for implementing pathing, but all of them have a pretty big weakness.

Idea 1:


Idea 2


Idea 3


I was wondering what techniques others have used for AI pathing. The ideal solution would essentially allow me to input a pair of coordinates I want my AI entity to move to, the AI would than determine a path that gets it to those coordinates from its current location.

I am not asking for code examples (although they would be appreciated). I am asking for ideas that I could put into code myself.

------------------------------------
Currently 1500+ lines of code into an "over-the-shoulder" action RPG with combat based on rag-doll physics.
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 2nd Jun 2009 12:32
Perhaps a google search on the topic of "AI Pathfinding" or "AI game programming" would yield some useful results.

I have personally downloaded a number of free ebooks on the subject of computer game AI and AI techniques, alot of them dedicate a fair amount pages to the subject of pathfinding.

On the subject of pathfinding, i would suggest looking into the "A* Pathfinding" algorithm. It tends to be a fairly standard pathfinding workhorse and easy enough to work with.

Hope this helps some

If it ain't broke.... DONT FIX IT !!!
ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 3rd Jun 2009 03:09
I have tried Google and found something about "A*" pathfinding, but every example of it I've seen was in 2D, although I think I should be able to get it working in complex environments.

------------------------------------
Currently 1500+ lines of code into an "over-the-shoulder" action RPG with combat based on rag-doll physics.
Jumpster
16
Years of Service
User Offline
Joined: 7th Feb 2008
Location:
Posted: 4th Jun 2009 05:26
Let me just say that A* is a great place to start!

It's not much different than your ideas 2 or 3, however, you don't have to limit yourself to 1-step per turn, but n-steps per x-ms of *think time*...


Regards,
Jumpster
Merak Spielman
16
Years of Service
User Offline
Joined: 14th Jul 2008
Location:
Posted: 5th Jun 2009 09:50
You also have to realize how very, very few games have excellent pathfinding. How many games have you played where 3d characters get stuck on walls? Or strategy games where your units, when told to attack a position on the other side of the map, string themselves out in a useless, straggly line instead of moving as one, cohesive army?

You're heading into the terrible, deadly waters of efficient algorithm design. How do you get the computer to narrow down the literally infinite possible paths to the few efficient paths, down to the single most efficient path? That problem itself isn't TOO hard, and the A* isn't too hard to expand to a third dimension if you're clever. But doing it for multiple units simultaneously, each of which has different AI and possibly shifting goals, and without taking up too much CPU time?

Good luck. Let me know if you figure it out.
ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 5th Jun 2009 10:19
As I understand it, A* finds the "least expensive" route from A to B, I'm guessing I could speed up the algorithm (and make my AI movement look more realistic) by stopping the calculations when I find a "good enough" route.

I may also integrate a waypoint system that if used right could better my pathfinding. Thanks for the help!

------------------------------------
Currently 1500+ lines of code into an "over-the-shoulder" action RPG with combat based on rag-doll physics.
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 5th Jun 2009 13:15
I know its complex but you could keep a list of the poly's of your terrain in an array of some type, along with their position's and whatever data about them you need.. along with a flag as to whether or not it is "walkable" or "unpassable" or whatever it happens to be, basically you would setup the poly's to be like nodes that the algorithm can navigate through.

or you can build a set of nodes into the map itself as you build it in whichever app you are using, that can be used by your ai to navigate with, like your "ai map" idea.

Once you have an environment that can be navigated through, you can setup groups of nodes to minimize the amount of initial checks, for instance you wouldnt even consider the ones that are unpassable, a set of nodes flagged as flat ground or road would make travel faster so would be the desired route if possible, hills or rough terrain would be lowest priority as it would slow travel. assuming that your ai would know where it wanted to go, it would have a destination for the algorithm to work bak from to find the quickest way to the destination.

you could also for instance, setup node properties that tell your ai where it can find the best cover cover when its being shot at as its moving around, or which is the best route to drive that tank along to run over the player.

In relation to agents getting stuck, you would need to have some kind of contingency for that, if they are meant to be doing one action, like walking to a destination, and you know roughly how long it should take, if it hasnt occured in a reasonable time, you could maybe rotate the agent and walk it a little in a different direction, or teleport it a short way from where it is etc.

with nodes, you could also pre-define paths for your ai to get from certain areas of your map to other areas, roads from one town to another, or along a trench from bunker to bunker for example, and have it prioritize using them to reduce pathfinding calculations during runtime, of course then you have to worry about it becoming predictable..

If it ain't broke.... DONT FIX IT !!!

Login to post a reply

Server time is: 2024-10-01 03:19:16
Your offset time is: 2024-10-01 03:19:16