Game Development Community

Plan for Mark Storer

by Mark Storer · 09/08/2005 (4:00 pm) · 3 comments

As detailed here, I've been fighting with AIPlayer.pushTask() for a while.

Having finally slain the beast, I now plan to rip it out completely. Glad I expended the extra effort, eh?

See, pushTask just takes a string. When the task is executed, it's called as a member function of the AIPlayer in an "eval" call. That means compiling the string then executing it. Not terribly effcient, but about as versitile as one could hope.

But our game is going to have A Lot of AI going on, so efficiency is high on the list of priorities. We're thinking of 100 or more at a time typically. We've already invested in the RTS kit, so our network load shouldn't be too bad.

So I'm thinking of two separate lists of commands. "moves" and "targets". The move list will be a list of coordinates, and the targets will be a list of objects (object handles really). We can then pass these into the AI functions setMoveDestination or setTarget (is that right?) as appropriate.

We'll probably add some brains to the target list so it'll stick targets it can't see (a raycast or three that don't make it) at the end of the list. I'll also be dropping anything that's already dead/invalid. No point in shooting at a corpse, or puking script errors all over the .log file.

My AI script will (if & when complete) seperate "pushing" and "executing" tasks. The "pushTask()" that ships with the 1.3 FPS starter kit always executes tasks as they're pushed, then saves them in an array. That's not a "push" in my book. That's an "execute". I've already accomplished this part. Not at all tested, save by my silly "chase the crossbow explosion" thing.

That's not an Orc... It's a lemming! First person to rewrite "Lemmings" using Kork instead of those weirdos with the green hair wins a lollipop, shipping and handling not included!

I'm also eagerly awaiting my wife's first paycheck at her new job so I can order the Advanced "3d game programming all in one" book... I hear there's a section on AI. Cash is a bit tight just now. I'd like to see a review of that section of anyone seen one.

There's still the possibility that a script-based approach won't be fast enough either, but I'm going to reserve judgement on that. Once we've got a tech demo up and running, I'll see if we're having issues. If that happens, I'll just move the target and destination lists inside the engine and hope that makes up the difference. We Shall See.

#1
09/08/2005 (7:13 pm)
I like the idea of moving the AI into C++.

I need something like this to handle NPC's in my RPG game. My idea was to create a new scripting language much like NWN's scripting language and make it event driven instead of procedural. That way you could have something like "moveTo(x,y,z); waitUntilDestinationReached(); doSomethingElse();" etc. Good idea for an RPG needing NPC's but I think your strategy might be a little different for an RTS. Sounds like you're on the right track.
#2
09/08/2005 (9:15 pm)
@Tony: The AIPlayer already has a number of callbacks available from the engine. They're enumerated in the stock AIPlayer.cs (right at the top):
//-----------------------------------------------------------------------------
// AIPlayer callbacks
// The AIPlayer class implements the following callbacks:
//
//    PlayerData::onStuck(%this,%obj)
//    PlayerData::onUnStuck(%this,%obj)
//    PlayerData::onStop(%this,%obj)
//    PlayerData::onMove(%this,%obj)
//    PlayerData::onReachDestination(%this,%obj)
//    PlayerData::onTargetEnterLOS(%this,%obj)
//    PlayerData::onTargetExitLOS(%this,%obj)
//    PlayerData::onAdd(%this,%obj)
//
// Since the AIPlayer doesn't implement it's own datablock, these callbacks
// all take place in the PlayerData namespace.
#3
09/09/2005 (10:14 am)
Most of Torque is pretty event driven as is :)