Thursday, December 22, 2011

Doomed Game AI Research

The problem with doing research on Game AI is that its all secret sauce.  The AI systems are still considered as a competative advantage so "officially" the source is protected.  The other reality is that they are a "work in progress"... so like most software, they are undocumented and constantly evolving...

This makes studying them at best observational research and at worst like trying to dent water.

Id are about the only company releasing their old game source... although without the assets, so it should be possible to reverse their AI system.  This results in a 10yr old system that has been cloned by eveyone... kind of like game development DNA. And they used scripted AI anyway... so nothing to see there.

The next source is articles and books written by developers and designers.  These are often short, conceptual and neat.  The describe intention and mechanism... and we assume they reveal the "secret sauce"... but in reality the implemtations are going to have their own kinks and twists which don't make it into the article.  Probably not significant but sitll there's a gap between reality and the description which may contain something interesting.

The other side of this is that no matter what the designers intended, emergent systems are by their very nature, a bit unpredictable.  So after all that... observation and experimental testing may be the only way to really document them.  Having the source would make it a lot faster....

But to make the whole observation problem slightly managable we just need more eyeballs... lucky someone invented internet forums to bitch about bad AI... whooot.

E.g Artificial Stupidity at tvtropes. This is a great collection of anecdotes about flawed AI.

Reading this suggests that the "game" is to figure out weaknesses in the enemy strategy... which, when you think about it is the point of any game, even those against a human player.  So are these AI really "flawed" or are they imperfect enough to be satisfying? Do players want an unbeatable opponent? I would think not.  So that only leaves "flawed" opponents... in other words "human", limited, imperfect.... this gets to the question of the type of flaw... will it be a "human" flaw? A Character "flaw"?  So sort of tactical flaw based on not understanding the resources/economy/vehicles/environment?

Do we want the AI to display "human" flaws when they are simulating "things" that are not human?   (How much role-playing do we want encoded in the AI?)

All this gets back to presenting a challenge to a player... which leads to the conclusion that no matter what the AI "should" be doing as far as actually manipulating game elements, it needs to be able to adapt to the players capacity in some fashion.  I shall state it thusly...

Rule 1 of Game AI - Play the player not the game. 

(Reminds me of a line from the movie "Searching for Bobby Fisher")  The player defines the challenge, thus the AI needs to know the player. This gets me back to my on-going rant about modelling the player as the basis of a game AI system.

It's obvious that the vast majority of game developers (99%+ would be my conservative estimate) spend no resources on modelling the player, they simply try to react to the current state of the players avatar or their units and leave it at that.  Pour on a couple of reactive heuristics and some tuning constants and cross their fingers. Or simply have a "Novice", "Middle"and "Hard" settings.  This presents a simple target for the game tuners to work with but also allows the player to exercise some choice about the type of game they want to play "Now".  Sometimes, I just want to blat around in a game without being "Challenged". So I think its important to allow the player to choose their difficulty level in some fashion.  

Reading more of the comments leads to the conclusion that the second rule must be...


Rule 2 of Game AI - Play all the game elements. 

By this I mean that the AI should have heuristics governing all the play elements. In the case where there are dozens or hundreds of different "bits" in the game, the developers have just made a stick to beat themselves with.  Permutation is the enemy.. until they figure out a way to build an AI to write the rule sets for them... Duh!  Computers are there to do the repetative work...

Obviously this starts to bite when the AI is computationally limited and the rulesets exceed the resources allocated.  But even in those situations it should be a case of creating an AI that can decide what to spend that limited CPU resource on... one ruleset to rule them all... lol.

It's easy to see how developers dig themselves into these holes by trying to hand tune games with insane numbers of relationships between game elements. 

Finally, we get to....

Rule 3 of Game AI - Match your players expectations.   

The common thread though the forums is that players expectations are being violated.  It's not that the AI is smarter or dumber or creates wildly un-desirable behaviour (although that's often the end result) but that player "Notice" when the AI does something they think is uncharacteristic.  If they are expecting a smart AI and it acts stupid... tada... forums catch fire.   

So, the big issue is to manage the players expectations.  Tell them before, during and after what they should expect.  Currently, the situation is more that players learn by observation (nothing bad about that) except their learning starts long before they get to most games.  If the game is a strategy game, they have probably seen a couple of movies or read a book or two that have shaped their expectations.  These feed into their expectations of the game behaviour... which is quite reasonable as the game is drawing on those genre's for art and marketing... so its reasonable for the player to carry their expectations into the game.

Am I suggesting that developers should not be ambitious and create games using genre material that the AI is not yet capable of simulating?  That seems a bit limiting... but it would be nice to see the time and energy put into the AI and simulation that matched the quality of the art work, for instance.

I think there is a sense of acheivement when a player figures out (or reads on a forum) an exploitable flaw in a games AI.  Spending the time learning about your enemy, testing them and finally beating them is the essence of competition.  Because of the re-playability of games, they turn into a puzzle that can be beaten if you are persisent. In this case having flaws in the AI behaviour is kind of essential. 

When the AI is not simulating an "Enemy" to be beaten but is trying to generate background behaviour, showing flaws is just wrong. The suspension of disbelief  that the player needs to buy into for the narrative to work is essential and fragile.  Break this and the game is fundamentally broken. The great thing is that players are able to selectivly ignore instances and forgive mistakes and regain their flow given enough other material to continue playing. But multiple, repeated or massive violations drag the game down to a point where it becomes a sham and the player feels foolish for "playing along" with it and abandons it.  Because this kind of simulated life buys into some fairly complex expectations that the players will be carrying into the game, its a particularly hard problem to get right.  


Rule 4 of Game AI - Life is infinitly complex, the players perception is not. 

Resource limits are real in most games so procedural generation is the only viable mechanism for behaviour and art assets when you want to produce complexity. But not all games want to end up looking like "Spore".  So there needs to be some more tools in the toolbox.

Scenario Templating, Procedural generation, Scripts, Rulesets, Heuristics, Skeletal animation + Skins, motion libraries, behaviour libraries, better reaction heuristics, player modelling, AI systems to generate AI systems,  cheating, suggestion, borrowing from the players experience.

Good narrative works by allowing the reader to fill in many of the blanks themselves and just sketches the background.  I feel that most games are able to do this convincingly enough but the question is how to identify and fix the weak points.

More thinking to do.

So whats the linear solution to the exponential problem?

Have the AI do what people do, use feedback... predict the result of their activity, do the behaviour and then evaluate that result, modify their ruleset, rinse, repeat... This simple feedback loop should prevent a lot of the repetative stupidity that I see in the forum posts.  It would also help with game tuning.  Building evaluation critieria is much easier than having a blind ruleset that is context insensitive.

There are some more interesting examples here http://tvtropes.org/pmwiki/pmwiki.php/Main/SpitefulAI


3 comments:

  1. Love the second part of your rant; you should look up Stephane Bura, he's very vocal in his advocacy for this kind of AI (player modelling + AI direction, DnD style).


    As for the first part, there's really not that much secret sauce in practice. Most game developers are increasing willing and keen to share their insights on the systems they built (that's a recruiting advantage) and in practice the only parts that don't get talked about are the "boring" ones -- which anyone could figure out given a bit of time and/or experience on the topic.

    At AiGameDev.com we interview different developers almost every week, and there are very few who couldn't do the interview for 'competitive' reasons. The systems people use are now increasingly well documented and mature, and worth studying!

    We'll be releasing a beginner-oriented course next year to correct a lot of these misconceptions, so stay tuned for that!

    Alex
    AiGameDev.com

    ReplyDelete
  2. Dittos on Alex. Additionally, there are a number of companies that have released their source code other than Id. You can pick up the AI code for F.E.A.R. or Civilization IV for example.

    You really want a brain-melting AI fest? Come join us at the AI Summit at the Game Developers Conference in March. ;-)

    ReplyDelete