AI for Computer Games (Or the lack of it…) Outline Uses of AI in computer games  Modern computer game “AI”  Special techniques  Ideas.

Download Report

Transcript AI for Computer Games (Or the lack of it…) Outline Uses of AI in computer games  Modern computer game “AI”  Special techniques  Ideas.

AI for Computer
Games
(Or the lack of it…)
Outline
Uses of AI in computer games
 Modern computer game “AI”
 Special techniques
 Ideas for future computer game AI
 Sources for further information

Uses of AI in Computer Games

Currently, AI is primarily used for controlling
non-playable characters (NPCs)
Must be fast! since the game is real-time
 Many AI running in parallel for each NPC in
active play
 Must be extensible


Game AI has little to do with the AI that is
studied in academia
Game AI
Game AI is primarily behavioral, since this is
how player’s perceive the intelligence
 Game AI is not focused on winning – it
enhances play and enjoyment



“Cheating” is perfectly acceptable so long as
the suspension of disbelief is maintained
Too much autonomy and unpredictability
might be undesirable
Game AI: Technical Considerations
Usually the AI for the games is added later
in the development process
 Usually, game development starts from
scratch, so not much code is reused
 Currently, standards are forming for AI
algorithms to allow them to be plug-in
components

Game AI for Navigation
Realistic navigation is very hard due to the
complexity of the environment, the storyline,
etc.
 Game AI has extensively used A* for route
finding
Destination


This is probably the
most-used true AI
technique
Waypoints
Start
Navigation occurs at
multiple scales

Once A* finds the general path through waypoints,
steering methods can find the path between
waypoints

These compute the path from a limited perspective

Steering applies to
individuals or groups

Groups have a “group
vector” that contribute
to individual movements
obstacle
repelling force
from obstacle
vector towards
waypoint
final movement
vector
Current position
Behavior control

Most NPC controllers use finite-state
machines or decision trees to determine the
behavior mode


E.g. when hit, switch
to defensive mode
These are usually
implemented via
scripts and if/then
statements
From (Nareyek 2004)
Behavior control
Once the controller selects the mode, one of
several scripted reactions are then used
 FSMs and Decision Trees can be broken
down into simple if/then statements

This is a rule-based control system
 Fast, efficient, and extensible!


Farther NPCs may be allocated longer
reasoning times for more complex decisions
Age of Empires


Idea: AI would learn the player’s preferred attacks,
locations, defenses, etc. and carry them over
between campaigns [never actually implemented]
User can tweak AI parameter config files
Virtua Fighter 2 & 4

Virtua Fighter 2 opponents
could do basic pattern
recognition (learn favored
moves and sequences) to
determine which countermoves to use

Virtua Fighter 4 allows you
to train a fighter to use
your moves and combos,
then have them fight for
you
Creatures 1, 2 & 3


Creatures uses neural nets to learn behaviors over
time and genetic algorithm concepts to breed
neural nets and creatures
This game is an example of Artificial Life
Half-life

Uses “schedule-driven state machines” to control NPCs’
behavior



The NPC’s state determines the schedule of behavior
available to it
E.g. Multiple NPCs might decide to retreat, but some might
crawl, walk, run, etc.
Uses flocking and formation rules to control squad behavior.
Unreal



Unreal has enemy flocking behaviors, similar to Half-life
Unreal has a extensive script language that allows the
development of AI bots
The Unreal Engine is an excellent simulation framework for
AI research
The Sims

Uses “smart terrain”

Embeds behavior code in the objects themselves
• How to do the behaviors
• Conditions for the behaviors


An object-oriented approach
Allows a VERY extensible environment
Racing Games



Dirt Track Racing : Uses neural networks to control opponent
driving
Formula 1 Grand Prix 2 : Opponent driving styles based on real
Formula 1 drivers
General ideas:
 Most opponents use pre-stored information on how to
approach upcoming track
 Opponents could be trained based on real drivers with specific
styles of driving
AI for Computer Graphics
Use a probabilistic network to computer the
player’s next move to pre-load graphics
 Use AI to control animations

Flocking behavior
 Swarm behavior


Use grammar techniques to generate
graphics (e.g. growing trees)
Specialized AI: Flocking Boids

Boids use a combination of three simple rules to produce
complex flocking behavior
Separation: avoid
colliding with local
flockmates and
obstacles


Alignment: match the
average heading and
velocity of local
flockmates
Cohesion: move
toward the centroid
of local flockmates
Each rule contributes a vector to a sum that gives the final
movement vector
First used commercially in Batman Returns for the bat
swarm and penguin animations
From http://www.red3d.com/cwr/boids/
Specialized AI: Flocking Boids

Boid animations:
http://www.vergenet.net/~conrad/java/Boids/
example2.html
 http://www.vergenet.net/~conrad/java/Boids/
coogee.html
 http://www.red3d.com/cwr/boids/


Boids are an example of emergent
behavior: global behavior that results from
local rules
Aside: emergent behaviors

Ant colony optimization




Ants wander randomly
Upon finding food, they return to the nest laying
pheromones
Ants are more likely to follow pheromone trails
More ants traveling the path with food reinforces the
pheromone trail

Used for path-finding, TSP, other optimization
problems
An example of swarm intelligence

http://website.lineone.net/~john.montgomery/demos/ants.html

Ant colony optimization
Specialized AI: Growing
Trees


Grammars can be used to grow trees in computer
graphics
Not quite AI, but computational linguistics are AI
http://chriscoyne.com/cfdg/graphics/
http://www.monkeyengines.co.uk/demo/
Ideas for future game AI

Major applications of Game AI
Controlling NPCs
 Adapting difficulty automatically
 Adapting environment automatically
 Story generation


Really, only the first has been extensively
used. The second, perhaps, only a bit.
Future directions:
Controlling NPCs
Genuine “hunting” behavior
 Faster algorithms to allow for more
sophisticated AI
 Team organization



E.g. retreating and getting reinforcements
(Half-life)
Emotion control
Subtle responses
 Feedback from player’s treatment

Future Directions

Perception control



Detecting interesting features of environment for
planning (Age of Empires)
Determining which features of environment are
accessible
Adapting the difficulty automatically


Must optimize the player’s experience
Can use existing techniques
Future directions:
Adapting the environment
For example, if a player is searching for
someone, making small directional sounds
to help guide their search at key times
 Automatic placement of objects to enhance
or lessen difficulty
 Dynamic terrain generation

Future Directions:
Story Generation

Automatic generation of elements to move
the player along a story outline

The story becomes a series of plot elements
(events) linked via the AI
Requires natural language understanding
and generation
 Think of the Holodeck from Star Trek

Sources for Further Information

Creatures – including free downloads
http://www.gamewaredevelopment.co.uk/creatures_index.php

ACM Queue article on Game AI
http://www.ai-center.com/publications/nareyek-acmqueue04.pdf

The Game AI site
http://www.gameai.com/

Textbook chapter: The role of AI in computer
game genres
http://ai.eecs.umich.edu/people/laird/papers/book-chapter.htm