You are on page 1of 66

AI in Computer Games

Dr. Nick Hawes


www.cs.bham.ac.uk/~nah
AI in Computer Games

First, some background...


• AI & CS degree here (avoided as much CS as
was humanly possible)
• PhD sponsored by Sony Computer
Entertainment Europe (including some
pointless work experience).
• Post-doc at Media Lab Europe (they have a
games group, but I wasn't in it).
• Now working here on the CoSy project.
AI in Computer Games

Overview
• Why is AI good for games?
• Why are games good for AI?
• AI techniques for games.
• AI in existing games.
• Halo
• The Sims
AI in Computer Games

Overview
• Why is AI good for games?
• Why are games good for AI?
• AI techniques for games.
• AI in existing games.
• Halo
• The Sims
AI in Computer Games

Why is AI good for games?


• In other words: What makes the games
industry need AI?
AI in Computer Games

The Main Reason


• Suspension of disbelief is crucial for games.
Better AI makes it easier to accept what you
see.
• Typically this means generating behaviour
for opponents.
AI in Computer Games

The Past...
• Originally AI was used to control very, very
simple characters.
AI in Computer Games

The Past...
• Originally AI was used to control very, very
simple characters.
AI in Computer Games

The Past...
• Or provide simple, pattern-based challenges.
AI in Computer Games

The Past...
• Or provide simple, pattern-based challenges.
AI in Computer Games

The Past...
• Does that really count?
• What's the difference between the AI in
Donkey Kong and that in Pac-Man?
• Decisions: In some sense the agents “choose”
what to do next.
• Is this AI if it's a random choice?
AI in Computer Games

The Present...
• AI is still used for opponents, although the
range of possibilities is now much bigger.
AI in Computer Games

The Present...
AI in Computer Games

The Present...
• ... well that's still pattern based. How about...
AI in Computer Games

The Present...
• ... well that's still pattern based. How about...
AI in Computer Games

The Present...
• Or even...
AI in Computer Games

The Present...
• Or even...
AI in Computer Games

The Present...
• AI is also used to provide non-opposition
characters such as team-mates or scene-
setting wildlife.
AI in Computer Games

The Future...
• If current trends in gaming continue, AI
techniques will be for the following things at
least...
AI in Computer Games

World Fillers
• Massively multi-player games need to
populated by non-player-character (NPC)
agents.
• Key problem: The world is persistent.
• NPCs are needed to;

Sell things and make things.
• Play key roles in story telling.
AI in Computer Games

World Fillers
• Who wants to be a reliable baker when they
can be a dashing hero? (well, some people
do, but not enough to build future in-game
economies)
• Who wants to abstain in order to build
dramatic tension when they are paying to
play?
AI in Computer Games

Team mates
• Not just characters you can order around,
but truly interactive entities (whatever that
may mean).
• Convincing AI is necessary in order to help
build relationships with characters (cf Catz,
and Dogz).
AI in Computer Games

Better Opposition
• Opponents that provide a real, dynamic,
challenge.
• Not just foot soldiers, but generals, political
manipulators etc.
AI in Computer Games

Overview
• Why is AI good for games?
• Why are games good for AI?
• AI techniques for games.
• AI in existing games.
• Halo
• The Sims
AI in Computer Games

Why are games relevant to AI?


• In other words: Why should we (and future
generations of AI programmers) care about
games?
AI in Computer Games

Why should we care?


• They provide advanced, existing test-beds.
AI in Computer Games

Why should we care?


• They provide advanced, existing test-beds.
• They are limited, but not too limited.
(compare toy worlds such as the Blocks
World).
AI in Computer Games

Why should we care?


• They provide advanced, existing test-beds.
• They are limited, but not too limited.
(compare toy worlds such as the Blocks
World).
• They are one of the few domains that allow
us to build “proper agents”.
AI in Computer Games

Why should we care?


• Crucially, any AI code in a game is put under
at least 3 serious (-ly necessary) tests;

A real-time environment.

A dynamic environment.

Playing a robust and convincing role.
AI in Computer Games

Overview
• Why is AI good for games?
• Why are games good for AI?
• AI techniques for games.
• AI in existing games.
• Halo
• The Sims
AI in Computer Games

Lots and lots of “If” statements.


AI in Computer Games

Lots and lots of “If” statements.


• Pros:

Not many really, expect they are easy for an
inexperienced AI programmer to write.

Simple solutions to simple problems.
AI in Computer Games

Lots and lots of “If” statements.


• Pros:

Not many really, expect they are easy for an
inexperienced AI programmer to write.

Simple solutions to simple problems.
• Cons:
• Difficult to maintain and extend.

Unpredictable interactions grow with size.
• Cost of matching conditions may get
considerable (cf. Ginsberg's critique of Universal
Plans).
AI in Computer Games

Scripting Languages (not a


technique as such)
• Click to add an outline
AI in Computer Games

Scripting Languages (not a


technique as such)
• Pros:

Allow non-programmers to write AI code.
AI in Computer Games

Scripting Languages (not a


technique as such)
• Pros:

Allow non-programmers to write AI code.
• Cons:

Very strict limits on functionality (unless
complexity is exposed).
• Behaviours may not be decomposable.
AI in Computer Games

Finite State Machines


AI in Computer Games

Finite State Machines


• Pros:

Goes beyond pure conditionals to give states.
• Predictable behaviour.
• Easy to comprehend.
AI in Computer Games

Finite State Machines


• Pros:

Goes beyond pure conditionals to give states.
• Predictable behaviour.
• Easy to comprehend.
• Cons:
• The problem needs to be easily decomposable.
• Visible state (non)transitions and fluctuations
can destroy illusion of intelligence.
AI in Computer Games

The Future of AI in Games


• What techniques and approaches may make
an appearance in the future?
AI in Computer Games

Nature-inspired Computation
• Everybody likes the idea of “evolving
something” for games.
• The problem comes when you try to define
evolutionary units and operators...
• What level should behaviours be represented at?

What is a good fitness metric for game AI?
• ... and also what comes out at the end.
• Do you have something the designers can use?
AI in Computer Games

Level of Detail AI
• Cut AI processing costs by prioritising AI
code (cf. LOD graphics).
• Some interesting questions for AI (thinkers)
• How can we abstract an action and what are the
crucial parts of an action?
• How can this be done automatically?

Can we actually define varying levels of detail at
all?
AI in Computer Games

Natural Language Interaction


• Nothing spoils the suspension of disbelief
like a dialogue menu.
• Interactions with game characters would be
much more natural using spoken language.
• A BIG problem: although we can do speech
recognition now, language understanding is a
very, very hard problem. (AI complete?)
AI in Computer Games

Learning
• NPCs that learn are the holy grail of game AI.
• It has been tried...

Black & White (Decision-Tree learning)

Virtua Fighter 4 (?)
• Loads of problems though...

Huge state spaces.

Unpredictable play experiences.
AI in Computer Games

Cognitive Agents
• Can we develop game agents that are
indistinguishable from a living being.
• A sort of gaming Turing test.
• Although this is another very, very hard
problem, the limited scope of game
interactions may make it achievable.
• That said, it is a very, very hard problem (...
see Birmingham's CoSy project).
AI in Computer Games

Overview
• Why is AI good for games?
• Why are games good for AI?
• AI techniques for games.
• AI in existing games.
• Halo
• The Sims
AI in Computer Games

Overview
• Why is AI good for games?
• Why are games good for AI?
• AI techniques for games.
• AI in existing games.
• Halo
• The Sims
AI in Computer Games

Why look at Halo?


• Great resources. E.g. (Google for...)

The Integration of AI and Level Design in Halo,
by Jaime Griesemer, Chris Butcher. The following slides
are shamelessly “inspired” by this.

In the Mind of the Enemy: The Artificial
Intelligence of Halo 2, by Robert Valdes
• Very clear on the role of AI in games.
• It's pretty much state-of-the-art in terms of
game AI.
AI in Computer Games

The big(ger) picture


• The AI in Halo is designed to create the
illusion of intelligence, not intelligence itself.
• AI is recognised as the place where design
and coding overlap. (and this isn't always a
nice place)
• Responsibilities:
• Design: 3 minute scope, personalities, strategy.
• Code: 30 sec scope, decision making and
reactions.
AI in Computer Games

Design Goals for AI


• Agents should be:

Intelligible
• Interactive
• Unpredictable
AI in Computer Games

Intelligible AI
• Obvious goals
• Personalities
• Roles
• Transparent thought processes.
• Backed up throughout the game with
language, posture, gesture and attention.
• Supported by the agent design.
AI in Computer Games

Interactive AI
• The player shouldn't just shoot at enemies.
• They should be able to:

Impress them.

Fool them.

Thwart them.
• And they should receive some feedback on
these things. (interesting question... how can
this be done without prior specification?)
AI in Computer Games

Unpredictable AI
• No randomness as this goes against
previous goals.
• Instead rely on the combination of:
• Reactive AI.
• Complex, simulated world.

Analog quantities (time, aiming, position)
• An unpredictable player.
• ... to generate emergent behaviour.
AI in Computer Games

Agent Architecture
• Simulated world.
• Restricted
perception (allows
stronger interaction).
• Decision logics
selects from
actions.
AI in Computer Games

Decision Logic
• Specific for each in-
game race.

Grunts flee easily.

Elites seek cover if
hurt.
AI in Computer Games

Overview
• Why is AI good for games?
• Why are games good for AI?
• AI techniques for games.
• AI in existing games.
• Halo
• The Sims
AI in Computer Games

Why look at The Sims?


• An almost pure AI game.
• It does things backwards!
AI in Computer Games

The premise
• A game world populated by intelligent beings
with needs that must be satisfied.
• These needs can be satisfied by interacting
in a particular way with a a particular object.
AI in Computer Games

The problem
• The game should be extensible so we can
make loads of cash.
AI in Computer Games

The solution
• Put all the behaviours (and their related
animations etc.) into the objects!
AI in Computer Games

The Sims Approach To AI


• Make an intelligent world instead of an
intelligent agent.
• Distill the reasoning about an object into the
object itself.
• Get that object to advertise the results of
the reasoning.
• All the agent has to do is choose which
object to interact with.
AI in Computer Games

Why this is good


• Agents don't need to know anything about
objects.
• So new objects can be easily created and
added to the game.
• A massive decision problem is simplified to a
much smaller problem...
• Which desire should I satisfy and how?
AI in Computer Games

Why this is bad


• It rules out any more advanced decision
making.
• Objects can only be interacted with in pre-
determined ways.
• It feels wrong somehow! (but in a game, if it
works then that doesn't matter)
AI in Computer Games

Some resources...
• For information on AI in Computer Games:

AAAI Spring Symposia on AI and
Games/Entertainment/Media

Articles on gamasutra.com
• Proceedings of the Game Developers
Conference (which you can attend as a
volunteer)
AI in Computer Games

So, you want to program games...


• No you don't.
• Learn C++.
• If you want to do AI in games...
• Have cool demos.

Be prepared to do other, less stimulating things
to “learn the ropes” first.

Resign yourself to the fact that there are very
few (interesting) jobs out there.
AI in Computer Games
Dr. Nick Hawes
www.cs.bham.ac.uk/~nah

Thanks!

You might also like