Game Development Community

My big, fat, NPC AI...

by Ted Southard · 08/03/2009 (7:05 pm) · 9 comments

www.DigitalFlux.com/images/devbloglogo.png


Anyone who has read my blogs has heard me talk about how I like to prototype as much outside of the game engine as possible. Excel affords a great opportunity to simply stare your math in the face and work directly with it in realtime without recompiling (even at the scripting level) or relying on console output to tell you after the fact if your math is correct.

The above is true for non-rendering math, like AI, crafting, or other things. Here, we're talking about the AI that is going to go into Epic Frontiers in order to make our NPCs a little more believable.

And speaking of Excel and AI... That's what Willis was talking about:
www.DigitalFlux.com/images/aetest2.jpg
Each NPC in Epic Frontiers will have six personality traits:
1) Altruism: Selflessness
2) Openness: How reserved or "open" they are
3) Discipline: Mainly regarding self-discipline
4) Dominance: You can also term this as Aggressiveness
5) Sensitivity: How stable they are in regards to changing moods
6) Trust: Self-explanatory... right?

On top of that, the traits can be modified either by certain actions directly, or through emotions:
1) Anger/Joy
2) Fear/Confidence
3) Disgust/Desire

www.DigitalFlux.com/images/hitman-ae-test.png
The Hitman personality type loses confidence as he loses control of his anger...

And through the ever-successful formula (pants collected)*(?)=profit, the AI should be able to pick generalized actions out of the following categories:
1) Physical: Combat and healing (or more precisely, offense and defense)
2) Verbal: Ranges from freely volunteering information to threatening the player
3) Economic: Crafting, training, information on where to get training, or maybe just wanting to pick the player's pocket

Now, why did I say the AI "should" be able to pick out an action from the generalized action lists? Well, the problem is kind of what people run into in real life: Figuring out why people make the choices they do. Granted, whittling down personality traits to a paltry six makes the task easier, and using emotion variables to slide those traits "up and down" in the range has produced very nice results with very fast math. However, I believe I've hit the limit as to what Excel can do for me without getting into the Visual Basic side of things. Not that I don't know VB (I learned it just for this purpose), but at this point, I feel I should move it into Torque Script to do the testing.

Some of the issues above can be seen in the cells below the ranges of generalized actions: I've tried doing simple weighting of values corresponding to a specific ordering of traits for each personality type that I'm testing (the two tables at the bottom), to no avail. While the "assist" Physical generalized action shown in the screenshot is fairly accurate for the Adventurer type (take a look at the traits exhibited in the results cells, colored orange), it does not stay consistent.

Part of this is the nature of the personality model I'm using: For each trait, you can see extreme ends of the trait that are bad on both ends, and there would need to be some small amount of AI logic to account for this. Excel is great for formulas, but is limited in logic statements for cells without using VB. Also, I can probably get this stuff looking much prettier in a dialog in Torque and be able to test it almost as fast.

Now, getting past that issue will probably not be as hard as it looks, and the good news is that once the AI selects the generalized action categories correctly, there is existing and fairly straight-forward code all over the interwebs for selecting the best action for a goal. And goals may play a fairly large part in this logic as well- luckily, I've done work with assigning and accomplishing goals for quests on the part of the player, so I can transfer that over to the NPC and adapt it to this logic.

Does any of that make sense? I hope so. I've spent as many years looking into AI as I have trying to cook up Interrogative, and while it's not as original as Interrogative is (all sorts of emotion/personality AI representations are floating around out there, and this just represents my needs for Epic Frontiers), I think the work will be worth it once done. On the other hand, I have this nightmare scenario stuck in my head of malfunctioning NPCs telling players they're in love with them while trying to kill them... It also makes me laugh.

And that's the update for the NPC AI which will be found in Epic Frontiers, and the next blog, which will also post on the DigitalFlux website, will detail the triumphs and finalized features of the personality-based AI.

And if there were a moral to this story, it would be to use simple tools to quickly prototype your game logic. So, now you know...
2.bp.blogspot.com/_DePH4a9h_94/SUJ1bpHfcII/AAAAAAAAAsg/f-ksqHEu2FM/s400/KnowingIs_Fullpic_1.gif

#1
08/03/2009 (7:47 pm)
Can't wait to see it in action even the malfunctions would be fun to see!
#2
08/03/2009 (7:59 pm)
I can agree with wanting to see the AI go nuts, maybe itll start yelling while shooting at you and pissing its pants at the same time!

Now that would be an awesome video!
#3
08/03/2009 (8:32 pm)
Quote:Excel is great for formulas, but is limited in logic statements for cells without using VB.

This has driven me to madness on several occasions. 7 nested if statements is the limit if I'm not mistaken. That and the fact that you can't do an advanced filter across worksheets, and the 65,000 row limit.

Madness I tell you!!!

www.bedpanmedia.com/images/madness.jpg
haha, nice blog!

`Patrick
#4
08/03/2009 (8:37 pm)
...or NPCs telling the player that they hate them, while giving the player flowers!

Well, my view is you gotta take a few risks of snafus like that, if you want to push AI technology forward. I think that way of parameterizing AI looks cool and seems promising.

I've pondered doing something similar, though simpler, for an RTS game. Like, if an AI player has a high "vindictive" trait and you wipe out one of his bases, he may get obsessed for a while with trying to smack you back.
#5
08/03/2009 (9:12 pm)
Quote:
I have this nightmare scenario stuck in my head of malfunctioning NPCs telling players they're in love with them while trying to kill them
That's not a nightmare... that's real life. You never knew my ex :D

Sounds like you almost have a "System and method for creating exalted video games and virtual realities wherein ideas have consequences" ;)

Don't kick me for that, just kidding. I'm just starting to explore idea of outside tools such as spreadsheets and databases for game prototyping and balancing, it's great to read your side of things.
#6
08/03/2009 (9:29 pm)
@Michael: You just couldn't resist bringing up that crazy guy, lol... I swear he used that "e-word" so many times it's ruined for me. Even my girlfriend used it on me during a game of Bananagrams, like a psychological weapon (it worked, as she knew it would)...

But yeah, prototyping outside the engine is really good. It helps me to stop looking at stuff that's irrelevant at the time like art and bugs in other parts of the game.

Sometimes I find it interesting that I'm going through so much for a system that will be far more subtle than it sounds, but then again, I think that's what AI lacks. If I ever get back to RTS stuff, I'd love to create some AI that is capable of economy of forces and diversionary strategies without having it scripted in...
#7
08/03/2009 (9:48 pm)
I was looking for any excuse to use that word for a while now ;)

Sometimes true depth and power in a system will appear very subtle on the surface, but from what I've read in your blogs I think you've hit the spot between immersion and interaction that would allow changes in gameplay based upon 'x' bot's "mood" -- and that's a great thing no matter how subtle it is. I've always felt that most AI in almost all games were nothing more than moving targets and/or talking roadsigns, and in the end it lessened my enjoyment of those games.
#8
08/04/2009 (2:17 am)
Speaking of Excel and AI ... WhaChu talkin bout??
#9
08/04/2009 (9:20 pm)
Quote:Sometimes I find it interesting that I'm going through so much for a system that will be far more subtle than it sounds, but then again, I think that's what AI lacks.
That's exactly what AI lack in games. To date, most, if not all, seem scripted and unreal. It sounds like you are well on your way to making some "believable" AI. Oh, and let's not start taking notes on Ex's. Haha. I can tell you some horror stories that match your "nightmare senario". :-D