Introduction to ai in computer games
Download
1 / 97

Introduction to AI in Computer Games - PowerPoint PPT Presentation


  • 123 Views
  • Uploaded on

Introduction to AI in Computer Games. Hojjat Jafary Fanafzar Game Studio November 2012. What is AI. How do you think about AI?. What is AI. The field of AI research was founded at a conference on the campus of Dartmouth College in the summer of 1956

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Introduction to AI in Computer Games' - oded


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Introduction to ai in computer games

Introduction to AI in Computer Games

HojjatJafary

Fanafzar Game Studio

November 2012

Fanafzar Game Studio


What is ai
What is AI

  • How do you think about AI?

Fanafzar Game Studio


What is ai1
What is AI

  • The field of AI research was founded at a conference on the campus of Dartmouth College in the summer of 1956

  • “The science and engineering of making intelligent machines” -- John McCarthy 1956

  • The study and design of intelligent agents -- Russell & Norvig

Fanafzar Game Studio


Turing test
Turing Test

  • The Imitation Game (1950)

  • A man (A), a woman (B), and an interrogator (C) who may be of either sex.

Fanafzar Game Studio


Turing test1
Turing Test

  • The Imitation Game

  • We now ask the question, What will happen when a machine takes the part of A in this game?

Fanafzar Game Studio


Turing test2
Turing Test

  • Turing conjectured that, by the year 2000, a computer with a storage of 10^9 units could be programmed well enough to pass the test.

  • The Turing test does not directly test whether the computer behaves intelligently

    • Some human behavior is unintelligent

    • Some intelligent behavior is inhuman

  • Real intelligence vs. simulated intelligence

Fanafzar Game Studio


Chinese room
Chinese room

  • The Chinese room is a thought experiment by John Searle which first appeared in his paper "Minds, Brains, and Programs", published in Behavioral and Brain Sciences in 1980.

Fanafzar Game Studio


Chinese room1
Chinese room

Fanafzar Game Studio


Chinese room2
Chinese room

  • Searle argued that software could pass the Turing Test simply by manipulating symbols of which they had no understanding.

  • Searle concludes—the Turing Test cannot prove that a machine can think.

Fanafzar Game Studio


Strong ai
Strong AI

  • According to Strong AI, the correct simulation really is a mind.

  • In 1931, Kurt Gödel proved that it is always possible to create statements that a formal system (such as an AI program) could not prove.

Fanafzar Game Studio


Weak ai
Weak AI

  • According to Weak AI, the correct simulation is a model of the mind.

  • Can machines think?

    • boats and submarines do move through the water but we do not call that swimming.

  • Stuart Russell and Peter Norvig write: "AI researchers have devoted little attention to passing the Turing test."

Fanafzar Game Studio


Alien intelligence
Alien intelligence

  • The way computers "think" is vastly different from the way a human thinks. --James Martin

  • AI is faster and has a larger capacity for storage and memory than any human.

  • The largest nerves in the brain can transmit impulses at around 90 meters per second, whereas a fiber optics connection can transmit impulses at 300 million meters per second, more than 3 million times faster.

Fanafzar Game Studio


Machine learning
Machine Learning

  • “A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E.” --Tom M. Mitchell

  • REcognition, classification

  • Online and Offline learning

  • Supervised, Unsupervised, Reinforcement

Fanafzar Game Studio


Machine learning supervised
Machine Learning - Supervised

  • Classification

Fanafzar Game Studio


Machine learning unsupervised
Machine Learning - Unsupervised

  • Clustering

    • We don’t know number of classes

Fanafzar Game Studio


Machine learning unsupervised1
Machine Learning - Unsupervised

  • Clustering

Fanafzar Game Studio


Machine learning reinforcement
Machine Learning - Reinforcement

  • The goal of a reinforcement learning agent is to collect as much reward as possible.

  • Highly related to dynamic programming techniques

  • Most famous technique is Q-learning

  • Reinforcement Learning in First Person Shooter Games

    • IEEE TRANSACTIONS ON COMPUTATIONAL INTELLIGENCE AND AI IN GAMES, VOL. 3, NO. 1, MARCH 2011

  • High-level Reinforcement Learning in Strategy Games

    • International Conference on Autonomous Agents and Multiagent Systems

Fanafzar Game Studio


Evolutionary computing
Evolutionary Computing

  • A simple idea: use the theory of evolution as an algorithm.

  • A Population of Individuals

  • Swarm intelligence

    • Ant colony optimization

    • Particle swarm optimization

    • Bees algorithm

    • Cuckoo search

Fanafzar Game Studio


Genetic algorithm
Genetic Algorithm

  • Individual = Chromosomes

  • Mutation, Selection, and Crossover.

  • Operating on dynamic data sets is difficult

  • Tendency to converge towards local optima

  • Randomness

Fanafzar Game Studio


Neural networks
Neural Networks

  • Simplified models of neural processing in the brain

Fanafzar Game Studio


Neural networks1
Neural Networks

  • Multilayer Perceptrons

Fanafzar Game Studio


Neural networks2
Neural Networks

  • How to train

  • Black box

  • Over fitting

  • Computationally expensive

  • Evolving Neural Controllers using GA for Warcraft 3-Real Time Strategy Game

    • 2011 Sixth International Conference on Bio-Inspired Computing

Fanafzar Game Studio


Neural networks3
Neural Networks

  • A good book about

    GA and NN in games

Fanafzar Game Studio


What we expect from game ai
What we expect from game AI?

Do we really need AI in computer games?

Fanafzar Game Studio


What we expect from game ai1
What we expect from game AI?

  • Efficiency

  • Ease of Debugging (randomness)

  • We don’t need general problem solver

  • Believability

    • We don’t need human level intelligence

    • It doesn't really matter how NPC intelligence is achieved, as long as the creatures in the game appear believable.(weak AI)

Fanafzar Game Studio


What we expect from game ai2
What we expect from game AI?

  • Video games provide a rich test bed for artificial intelligence methods

  • Designers need to control the behavior of NPCs

    • Explicit control

    • Implicit control

  • It is very genre specific

  • Avoid artificial stupidity

Fanafzar Game Studio


Agents as npcs
Agents as NPCs

  • Agent cycle

SENSE

THINK

ACT

Fanafzar Game Studio


Agents as npcs1
Agents as NPCs

  • Agent cycle

THINK

ACT

MAP

GEOMETRY

ENTITIES

. . .

Fanafzar Game Studio


Agents as npcs2
Agents as NPCs

  • Agent cycle

SENSE

ACT

REASON

BEHAVE

REMEMBER

Fanafzar Game Studio


Agents as npcs3
Agents as NPCs

  • Agent cycle

SENSE

THINK

ANIMATE

NAVIGATE

. . .

Fanafzar Game Studio


Rule based
Rule Based

  • Rule : if (condition) then action

  • Production Rule System comprised of a database of rules, each rule consists of an arbitrarily complex conditional statements.

  • They are fairly uncommon approach.

Fanafzar Game Studio


Goal oriented
Goal Oriented

  • Search Methods, discovering a sequence of actions or states within a search space that satisfy some goal

  • Goal-oriented behavior is still fairly rare in games.

Fanafzar Game Studio


Introduction to path planning
Introduction to Path planning

  • Everything in game world is triangle

  • In door / Out door

  • Path finding still is a problem

    • Some pathfinding bugs(Video)

Fanafzar Game Studio


A dijkstra
A*/Dijkstra

  • Graph Theory – shortest path

  • Single Source shortest path

  • All pairs shortest path – Floyd

    • Store the result

  • Heuristic F(n) = D(n) + H(n)

Fanafzar Game Studio


Hierarchical pathfinding
Hierarchical Pathfinding

  • Near-Optimal Hierarchical Pathfinding,

    • A. Botea, M. Muller, and J. Schaeffer, Journal of Game Development, Volume 1

Fanafzar Game Studio


Reviewing some pathfinding methods
Reviewing some pathfinding methods

  • Grid/Tile Base

    • Fast

    • Easy to develop

    • Memory Inefficient

    • 2D and strategy games

Fanafzar Game Studio


Reviewing some pathfinding methods1
Reviewing some pathfinding methods

  • Waypoint graphs

    • Manual

Fanafzar Game Studio


Reviewing some pathfinding methods2
Reviewing some pathfinding methods

  • Waypoint graphs

    • Automated : Point of visibility

Fanafzar Game Studio


Reviewing some pathfinding methods3
Reviewing some pathfinding methods

  • Worlds require a ridiculous number of waypoints

  • Difficult dynamic obstacle avoidance, if not impossible

  • Is not shortest path – not optimal

  • Impossible to do path-smoothing

  • ZigZag path

Fanafzar Game Studio


Reviewing some pathfinding methods4
Reviewing some pathfinding methods

Inefficient

Fanafzar Game Studio


Reviewing some pathfinding methods5
Reviewing some pathfinding methods

  • Convex Polygons

    • Manual/Automated

Fanafzar Game Studio


Reviewing some pathfinding methods6
Reviewing some pathfinding methods

  • Shortest path - Optimal

  • Smaller Search Space

Fanafzar Game Studio


Reviewing some pathfinding methods7
Reviewing some pathfinding methods

OK, But how to implement?

Fanafzar Game Studio


Reviewing some pathfinding methods8
Reviewing some pathfinding methods

  • Mesh simplification

  • Rendering techniques

  • Flood filling with AABBs (UDK)

  • Voxelization

  • Check MikkoMonone’s work, RecastNavigation

    • http://digestingduck.blogspot.com

Fanafzar Game Studio


Navigation mesh generation process
Navigation mesh generation process

  • The general process is as follows:

  • Voxelization

  • Generate Regions

  • Generate Contours

  • Generate Polygon Mesh

  • Generate Detailed Mesh

Fanafzar Game Studio


Navigation mesh generation process1
Navigation mesh generation process

1. Voxelization

Fanafzar Game Studio


Navigation mesh generation process2
Navigation mesh generation process

1. Voxelization

Fanafzar Game Studio


Navigation mesh generation process3
Navigation mesh generation process

1. Voxelization

Fanafzar Game Studio


Navigation mesh generation process4
Navigation mesh generation process

1. Voxelization

Fanafzar Game Studio


Navigation mesh generation process5
Navigation mesh generation process

1. Voxelization

Fanafzar Game Studio


Navigation mesh generation process6
Navigation mesh generation process

1. Voxelization

Fanafzar Game Studio


Navigation mesh generation process7
Navigation mesh generation process

2. Generate Regions

Fanafzar Game Studio


Navigation mesh generation process8
Navigation mesh generation process

2. Generate Regions

Fanafzar Game Studio


Navigation mesh generation process9
Navigation mesh generation process

2. Generate Regions

Fanafzar Game Studio


Navigation mesh generation process10
Navigation mesh generation process

3. Generate Contours

Fanafzar Game Studio


Navigation mesh generation process11
Navigation mesh generation process

3. Generate Contours

Fanafzar Game Studio


Navigation mesh generation process12
Navigation mesh generation process

3. Generate Contours

Douglas-Peucker simplification

Fanafzar Game Studio


Navigation mesh generation process13
Navigation mesh generation process

3. Generate Contours

Douglas-Peucker simplification

Fanafzar Game Studio


Navigation mesh generation process14
Navigation mesh generation process

3. Generate Contours

Douglas-Peucker simplification

Fanafzar Game Studio


Navigation mesh generation process15
Navigation mesh generation process

4. Generate Polygon Mesh

  • Triangulation

  • Merge to Convex Polygon

  • Benefits of Convex Polygon

Fanafzar Game Studio


Navigation mesh generation process16
Navigation mesh generation process

5. Generate Detailed Mesh

Fanafzar Game Studio


Navigation mesh generation process17
Navigation mesh generation process

5. Generate Detailed Mesh

Fanafzar Game Studio


Navigation mesh generation process18
Navigation mesh generation process

  • Path find with A*

    • Graph nodes are convex polygons

    • Corridor map

    • A* is not complex to implement

    • There are many optimization techniques

Fanafzar Game Studio


Navigation mesh generation process19
Navigation mesh generation process

  • Pathfinding is Not A Star, AUTODESK® KYNAPSE ® MIDDLEWARE WHITE PAPER

    • Path smoothing

    • Path following

    • Deal with other NPCs

    • Deal with dynamic evolutions of game world

Fanafzar Game Studio


Navigation mesh generation process20
Navigation mesh generation process

  • Velocity obstacle

  • There are some variations

    • RVO, NLVO, FVO, HRVO, NHRVO, PVO

  • Mikko uses RVO(Reciprocal Velocity Obstacles)

Fanafzar Game Studio


Navigation mesh generation process21
Navigation mesh generation process

  • Voxelization also used in Cover selection, Jumps, Camera movement

    • Automatic annotations in Killzone 3 --MikkoMononen, Paris Game AI Conference 2011

Fanafzar Game Studio


Navigation mesh zorvan integration
Navigation mesh, Zorvan Integration

Fanafzar Game Studio


Navigation mesh zorvan integration1
Navigation mesh, Zorvan Integration

  • Generation Types

    • Solo

    • Tiled Navmesh

      • Dynamic loading

      • Deal with dynamic obstacles

  • Off-Mesh Connections

  • Convex polygons

Fanafzar Game Studio


Steering behaviors
Steering Behaviors

  • How to simulate movement of intelligent objects like bird, animals, cars, etc. --Craig Reynols

  • Stanley and Stella in: Breaking the Ice (1987)

Fanafzar Game Studio


Steering behaviors1
Steering Behaviors

  • Simple Vehicle Model

    • Mass scalar

    • Position vector

    • Velocity vector

    • max_force scalar

    • max_speed scalar

Fanafzar Game Studio


Steering behaviors2
Steering Behaviors

  • Seek

  • Flee

  • Flocking

  • Pursuit

  • Arrival

  • Obstacle avoidance

  • Path follow

  • Leader follow

  • Hide

Fanafzar Game Studio


Steering behaviors3
Steering Behaviors

  • Seek Vs Flee

Fanafzar Game Studio


Steering behaviors4
Steering Behaviors

  • Seek

    Vector2D SteeringBehaviors::Seek(Vector2D TargetPos)

    {

    Vector2D diff = TargetPos - m_pVehicle->Pos();

    Vector2D DesiredVelocity =

    Vec2DNormalize(diff) * m_pVehicle->MaxSpeed();

    return (DesiredVelocity - m_pVehicle->Velocity());

    }

Fanafzar Game Studio


Steering behaviors5
Steering Behaviors

  • Obstacle avoidance

    • Only circles

Fanafzar Game Studio


Steering behaviors6
Steering Behaviors

  • Combining Steering Behaviors

    • Weighted Truncated Sum

    • Weighted Truncated Running Sum with Prioritization

    • Prioritized Dithering

  • Open Steer

Fanafzar Game Studio


Steering behaviors7
Steering Behaviors

Advantages

  • Simplicity

  • Reliability

  • Predictability

  • Efficiency

    Disadvantages

  • Local traps

    • Oscillation

  • Realism

    • Jagged paths

  • Scalability

Fanafzar Game Studio


Decision making
Decision Making

  • Pure scripting!

  • Structured

    • FSM

    • HFSM

    • Behavior Tree

Fanafzar Game Studio


FSM

  • Theory (Simplified)

    • A set states, S

    • An input vocabulary, e

    • Transition function, T(s, e)

      • Map a state and an input to another state

Player Seen

Patrol (idle)

Pursue

Reach post

Far from post

Near Player

Return to post

Combat

Fanafzar Game Studio


FSM

  • Finite State Machine (FSM) is the Most Commonly used Game AI Technology Today

    • Simple

    • Efficient

    • Easily extensible

    • Powerful enough to handle a wide variety of situations

  • Decisions only depend on current state

Fanafzar Game Studio


FSM

  • Hard Coded

    • Switch Statement

    • Function pointers

    • Polymorphism (State Pattern)

  • Interpreted

    • Data Driven

    • Scripted

  • Compiled

    • machine code

    • Generating source code

Fanafzar Game Studio


FSM

  • Function Pointer-Based, Embedded Finite-State Machines

    • Chapter 3.1, Game programming gems 1

  • A Finite-State Machine Class

    • Chapter 3.3 Game Programming Gems 3

Fanafzar Game Studio


HFSM

  • Each state can be a complete state machine in its own right

  • Original Paper

    • Statecharts: A Visual Formalism for Complex Systems D. Harel Science of Computer Programming 8, 1987

  • Clustering states (XOR)

  • Concurrency (AND)

Fanafzar Game Studio


HFSM

  • Example

Player Seen

Patrol (idle)

Pursue

Reach post

Far from post

Near Player

Return to post

Combat

Attack 1

Attack 2

Success

Fanafzar Game Studio


HFSM

  • Cluster states

  • The semantic of D is exclusive-or (XOR) of A and C

D

α

A

β

γ(cond)

B

C

δ

Fanafzar Game Studio


HFSM

  • Parallel (AND combination)

Y

A

D

E

γ

μ

A

α

G

α

β

F

δ

C

Fanafzar Game Studio


Iranvij ai editor
Iranvij AI Editor

Fanafzar Game Studio


Iranvij ai editor1
Iranvij AI Editor

Fanafzar Game Studio


Behavior tree
Behavior tree

  • Halo 2 [Bungie Software, 2004] was one of the first high-profile games for which the use of behavior trees.

  • Instead of a state, the main building block of a behavior tree is a Task

  • Conditions, Actions, and Composites

Fanafzar Game Studio


Behavior tree1
Behavior tree

  • Selector

?

terminate

keep trying

Fanafzar Game Studio


Behavior tree2
Behavior tree

  • Sequence

bail out

keep going

Fanafzar Game Studio


Behavior tree3
Behavior tree

  • Example

?

Door

Open?

Move

(into room)

Move

(to door)

Open

door

Move

(into room)

Condition

Action

Fanafzar Game Studio


Behavior tree4
Behavior tree

  • Refactored tree

?

Door

Open?

Move

(to door)

Open

door

Move

(into room)

Fanafzar Game Studio


Fanafzar Game Studio


Next generation ai for game
Next Generation AI for game

  • Procedural Animation

  • Procedural level generation

  • Dynamic game difficulty balancing

Fanafzar Game Studio


References
References

  • Artificial Intelligence For Games, Second Edition, Ian Millington, John Funge

  • Programming Game AI by Example, Mat Buckland

  • Game programming gems series

  • AI Game Programming Wisdom series

  • AI Game Development: Synthetic Creatures with Learning and Reactive Behaviors, Alex J. Champandard

  • http://aigamedev.com/

  • http://www.ai-blog.net/archives/000183.html

  • http://www.critterai.org/nmgen_study

Fanafzar Game Studio


References1
References

  • http://digestingduck.blogspot.com/

Fanafzar Game Studio


Thank You

[email protected]

Fanafzar Game Studio


ad