Game Development Community

dev|Pro Game Development Curriculum

Planner AI video demo

by Mathieu Marquis-Bolduc · 09/22/2006 (5:36 pm) · 13 comments

Hi everybody!

After a few months of hard work, here is the second AI system that I wish to include in my
AI toolkit: A planner system!

Planners are one of the most powerful AI tools available to game developpers. A very similar
planner is at the core of award-winning F.E.A.R.'s AI*. In fact, I developped this tool after
discussions with Monolith's Brian L, and thanks to Jeff Orkins papers (also from Monolith).

So how does a planner work? Simple. It finds the best sequence of action (a plan) that should take an
AI agent from his current state to a certain goal state. What makes a planner so different
is that a lot more of the thinking is done by the AI, so thats a lot less by the AI designer.

I made a shooter demo featuring the planner engine.
You can view a video of it here on YouTube.
Please tolerate my programmer's map editing skills!

If used correctly, an AI using a planner will be very good at adapting itself to unexpected
situations. As I said, they are also dead easy to use. Taking apart actual debugging of the planner,
setting up the AI for the shooter demo barely took an hour.

Like my previously presented GOAD system, the planner is configured using an XML file.
There are just two sections to this file. The first one list all available actions. For each action, you simply need to mention
what part of the goal state can it helps with and what does that action requires. An improvement to the FEAR
planner architecture is that I also allow you to specify under which conditions it is best to use that action.

An action example from the demo, syntax subject to change:




















This tells the planner that the action ""AttackTarget(x)" will try to solve the goal "IsAttacked = x".
It also tells that this actions require the agent to be near the target x, and have a weapon and ammunition.
Finally, it tells us that Attacking the target is actually *Always* an ideal option to solve the "IsAttacked" goal.

That is the descriptive part of the behavior. I feel that it is key, when designing AI, to separate the behavior
description from the action's implementation. As with the previous GOAD system, I wrote all necessary C++ code
to link the planner with torquescript. Lets see how the "AttackTarget(x)" action behavior is implemented in Torque Script.

function AIPlayer::AttackTargetApply(%this, %target)
{
%this.lSetStateVar("IsAttacked", %target);
}

function AIPlayer::AttackTargetExecute(%this, %target)
{
%this.setAimObject(%target, "0 0 1");
%this.fire(1);
}

Yes, its as dumb as that. Each action has two function attached to it. The "Apply" function is used at planning time,
and set the changes in the current state. The "Execute" function is used when executing the plan.

The last bit of AI configuration is to define each class of AI. The only thing you need to go is to list the actions
that are available to each kind of agents/NPCs/Bots in your game. Here is the whole thing from the demo:















Planner systems are not suitable to all games. For example, it would be harder to use for a sport game, where you dont typically plan a lot of things in advance, but rather react as things unfold. However,they seems to be ideal for tactical shooters. They could also be great for strategy games, both turn based and RTS, as well as role-playing games with complex NPCS (like the Elder Scrolls or Gothic series). It can also be a very good idea to use both the GOAD system and the planner system together! For example, you could use the GOAD to keep track of currents goals and decide which one is most important, then use the planner to find a way to solve the critical goal.

Well, thats all I have to say now about the planner. From now, I am wrapping things up to a state where I will be able to begin beta testing. Things like writing the manual, and safe-profing everything against memory leaks and exceptions. I already have several people interested in beta-testing the GOAD system (Thanks guys!). If you are interested in beta-testing the planner, please contact me directly. If you have ideas about what kind of AI tools you would like to see in future versions of the toolkit, you can post them here.

Some ending word: My main goal with this project is to provide amateur and professionnal game developpers with the most advanced AND efficient AI systems. While I strive to make them the easiest to use, you will still need moderate game programming skills to use them, and some talent with AI to exploit
them to their fullest.

Thanks again for your interest in this project, it makes all the hard work worth it. I can only hope my AI tools will live up to your expectations.

Mathieu Marquis Bolduc


Foot-notes:

*A few words on the FEAR thing. There is a LOT more about FEAR's AI than just a planner.
Targeting system, pathfinding, squad coordination, etc. But the planner is what determines
the NPC's actions. Big thanks to Jeff Orkins and Brian from Monolith Productions for sharing their ideas and
experiments.

**By the way, both video demos are running in debug mode while recording with Fraps. If used correctly, performance is
excellent. However, to have good performance, its is primordial that all information needed by the planner be readily
available. In middle of planning is not a good time to do ray casting or terrain analysis! You can use the other 99% of
cycles when the AI is not planning to do that other stuff.

#1
09/22/2006 (6:03 pm)
This looks very good! Rather excitting stuff :-)
#2
09/22/2006 (6:30 pm)
Uh huh, that's a good idea

*smiles and nods like he has a clue what Mathieu is saying*
#3
09/22/2006 (6:43 pm)
That is ridiculously cool! AI is one of the coolest fields - and it's still very new. Awesome vid!
#4
09/22/2006 (6:53 pm)
This is great, Mathieu.
Are you publishing this through GG?
#5
09/23/2006 (1:51 am)
Thats amazing, it looks completed already, what's left to do?

btw its hard to contact you if you dont show an e-mail address on your profile
#6
09/23/2006 (4:51 am)
I think this is incredible! Are you planning on implementing pathfinding? I would definitely like to test this on Nuclear Nightmare. What's your email address?
#7
09/23/2006 (7:28 am)
Thanks for the encouragements, guys!

@David, I havent worked on publishing yet. My priority was to have both systems up and running with demos. Since the demos are with TGE, it would probably be convenient, for me and the users.

@James, its mainly cleaning up that's left to do, plus the manual. Then I want a short beta test. Not only for begugging purpose, but also to give testers opportunities to suggest feature changes that would make it easier to use by someone who didnt design it!

@Nick, Pathfinding, not for version 1.0. I was thinking that there are already so many pathfinding librairies out there, and few cognition systems. But pathfinding tools are on my wish list of features! You can vote for that here.

I added my email to my profile, sorry about that.
#8
09/24/2006 (12:26 am)
Looks great Mathieu. I'll be purchasing a copy off you for sure.
#9
09/24/2006 (10:52 am)
Very cool work Mathieu!

Seeing this system in action definitely makes me want to get back to writing AI, as I am in management-land now. I've been toying around at home with an goal network/HTN planner concept for a while, but haven't spent enough time on it. Thanks for the inspiration. :)

How did you decide to represent the 'world state' in the end?
#10
09/24/2006 (5:51 pm)
@Brian,

While the popular approach is a list of false/true premises, Ive chosen to represent it as a list of valued variables. I hope it will help to keep world states short, while not sacrificing too much expressability. It also seems to help keeping the "Apply" and "Execute" function simples.

In the end, if you want real-time planning, you need a lot of abstraction.
#11
09/25/2006 (11:22 am)
Mathieu, I have sent you an email. Hopefully you've received it.

Nick
#12
10/22/2006 (1:43 am)
Dear Mathieu,

I would like to use your planning demo for my "Knowledge-based systems" class at Technische Universiteit Einhoven, The Netherlands. May I do this? How can I download the movie?

Best regards,
Alexander
#13
10/22/2006 (6:30 am)
Hi Alexander,

I give you permission to use the video for academic purposes. Hope its corkiness makes your student laugh a bit :). Its not very big (a couple of megs), so I should send it to you by email shortly.