Game Development Community

dev|Pro Game Development Curriculum

Tactical AI Kit: Crowds of Civilians

by Bryce · 11/03/2009 (7:59 pm) · 15 comments

Allo!

I had previously written a nice, detailed, informative blog, but Firefox decided to encounter an “unexpected error” as I was writing it all out. Horray.

I got an email a few days ago asking me about the Tactical AI Kit code structure. More specifically, how it could be modified to make AI Players do other stuff. Being unsure about this myself, I decided to program civilian AI. It's pretty basic right now, and it probably won't get any more complex, but I'm pretty proud of it. It's a nice touch.

I can typically have around fifteen combatant AI Players in a mission. All of them shooting, reacting, and taking cover, and all that fun stuff, before it starts to drag down on my performance. We should be able to have a lot of civilians in a mission and get a framerate higher than 2. To do this, civilians will perform selective thinking. The way I look at it, there's no reason to process anyone else unless they're dead or alert (in a civilian's case, screaming...). This allows me to drop in around 40-50 civilians, some combatants, and watch it all happen. You can also set combatant AI to fire on civilians (good for terrorists or other rudely-behaving people), though this puts a hit on the framerate.

So what do they do, you ask? Well, they pretty much chill out and react when necessary. When they see someone with a gun walking by, they're going to be naturally curious and/or worried, so they stop and look at the gunman. At this point, they are unsure of whether or not said gunman is a threat. As soon as the gun is pointed at the crowd, they start to back off a bit. When shots are fired, they are out of there. Civilian AI will be able to react to gunfire, bullet impacts, found bodies, and explosions. Grand Theft Torque, anyone?

Now for a video. This shows an AI player having a round of “target practice”, and various interactions with crowds of civilians.
Disclaimer: Nobody even slightly mentally crazed should watch this video. If you're not, well, then you will be. Enjoy the music.

Comments go down there. Do it.

#1
11/03/2009 (8:07 pm)
is that music crazy or what ;)

looks nifty though; but as I said way back, "watch out for feature creeps". Seems to me you simply cant stop adding goodies to the basket :P

-but, keep up the excellent work :)
#2
11/03/2009 (8:41 pm)
Great work! Hysterically civilians running blindly for cover and getting in the way, always adds an extra element to a game - especially if the player can be "punished" in some way for accidentally topping them.

15 active AI sounds fine, you should remember that until very recently, 3A console games had great trouble coping with more than 16, and CoD on the PC could take 32, but used a manager to try and limit spawning to around half that depending on available resources (but you could still "force" them to spawn). And you ain't exactly in possession of a high-tech box ...

Quote:Disclaimer: Nobody even slightly mentally crazed should watch this video.
Luckily, the mentally crazed always obey such rules. Oh hang ...

All good, though as Christian S points out - beware the ides of feature creep ... whatever the hell an ide is ...
#3
11/03/2009 (8:57 pm)
:)
#4
11/03/2009 (9:43 pm)
civilians i did not see any civilians in that vidio they all got guns. :P good work though looks like fun target practice.
#5
11/03/2009 (9:59 pm)
There were actually unarmed, their hands were just up :P (But they'd probably be a bit better off if they utilized the RPG on their back...)
#6
11/03/2009 (10:26 pm)
crazy video, but worth of watching...
p.s.: nice soundtrack
#7
11/03/2009 (10:44 pm)
This is a very nice addition!

What sort of date can we look at for this kit? And the supported engines, TGE/TGEA/T3D?

Are you thinking of a early-adopter program as I think there is a lot of interest for this kit?
#8
11/03/2009 (11:27 pm)
Videos like that get you on the list of people who will shoot people up :-). Ha ha, very funny though.
#9
11/03/2009 (11:37 pm)
@Edward: Not sure about the date, but I've ported the C++ code to T3D. I'd just need to write up documentation.

@Joshua: I always want to shoot the idiots who say things like that ;)
#10
11/04/2009 (1:21 am)
Bryce... Very nice. I was under the impression you were doing this all in script.
#11
11/04/2009 (6:01 am)
LMAO, oh thats awesome!

gj adding NPCs, was that an AI sniping or you... cause if that was an AI he sure was mad at those NPCs. lol.
#12
11/04/2009 (9:10 am)
@Randy: Only the pathfinding code and a few helpful functions (e.g. AIPlayer::isStopped(), which checks to see if the AI's move state is ModeStop) are in C++. I'll try to port the more performance-heavy stuff to C++ when I get that figured out
@CSMP: The guy at the beginning was the only AI player with a gun... That was me sniping, I was getting frustrated that I couldn't hit any of them because my touchpad was being annoying (and I suck at sniping :D )
#13
11/04/2009 (10:54 am)
damn,
I been watching the progress for ages,
bryce,
release already!!!!!
#14
11/04/2009 (1:22 pm)
@Bryce

I got you. And that makes sense to script then code it.. Recompiling while developing can be a pain sometimes:)

#15
11/04/2009 (2:37 pm)
Looks awesome Bryce, still can't wait for a release, but the more time you take the more awesome features go in, so its well worth it!