AI in Video Games
Grzegorz Mazur
Who we are?
Vile Monarch
Warsaw, Poland
Who I am?
● Co-Boss and Technical Director at
Vile Monarch
● Previously 11bit studios – Lead
Programmer of This War of Mine and
Sleepwalkers Journey
● Lecturer at Warsaw Film School
● Musician - amateur
grzegorz.mazur@vilemonarch.com
@dagenoth
What is AI in games?
● Interactive system that animates game world
● AI Agent
● Agent based on his state and game world state takes
action
What is AI in games?
Stimulus, for example:
- enemy in sight
- hearing call for help
- taking damage
State of agent, for ex:
- HP level
- resource quantity
- current goal
AI System
Action, for example:
- shooting
- playing animation
- beginning of movement
- command to move troop
What makes AI good for player?
● It should support gameplay...
● ... especially create challenge
● Good AI DOESNT have to be SMART
What makes AI good for developer?
● It should support gameplay... ;)
● Configurable
● Predictable
● Reusable
● Scalable
Scripted AI
● Simple scripts "if X then Y" and event-based programming
● Simple customization
● You have to predict everything
● Its hard to make it emergent
● It becomes drastically complicated with size
Finite State Machines
● In every moment Agent is in a single, specific state. For
example: combat, retreat, looking for enemy.
● State → specific behaviour
● Under specific conditions agent can make transistion from
current state to another
Finite State Machines
Idle
Combat
Following after enemy
Retreat
Behaviour Trees
● Node – complex agent behaviour
● Each node knows if he can run
● When node is running it tries to run its first runnable child
● Thats how tree-based decision structure appears
● At each moment only one branch of tree is running
Behaviour Trees
Enemy
Combat
Following after
enemy Idle
Behaviour Trees
Enemy
Combat
Following after
enemy Idle
Choos random
POI
[Range:5m]
Move
[Speed:3]
[Mode: Walk]
Play random
idle animation
[Loop: false]
[Time:5-10s]
Wait
[Time:5-10s]
Behaviour Trees
Enemy
Combat
Follow after
enemy Idle
Is enemy in
range
[Range: 1m]
Play animation
[Animation: hit]
Deal damage
[Damage: 30]
Behaviour Trees
● Sequences, selectors, actions, decorators
● After certain time/after certain stimulus we cen reevaluate
whole tree
● After reevaluation of tree a new branch can start running
● Behaviour trees look similar to hierarchical finiste state
machines
Behaviour Trees
Influence Mapping
● Method of finding areas in which we should move our
troops
● Game world represented by grid or graph
Influence Mapping
● Each unit/building/resource on
a map has its own base
influence – area and value
● Map of our influence
● Map of enemy influence
Influence Mapping
● Influence Map = Our
influence map – enemy
influence map
● Weight of area = influence
/ cost of movement
● Goal for troop = area with
highest weight
Influence Mapping
● Tension map = our influence + enemy influence
● The higher value – the bigger forces at the area
● Vulnerability map = tension map – ABS(influence map)
● The higher value – the bigger even fights at the area
Influence Mapping
● Based on information from different maps and additonal
conditions we can create any strategy
● Optionally we can introduce inertia and propagation of
influence
● Designer can introduce his own additional goal map
● Simple scripts are enough to make use of influence map
Influence Mapping
Other techniques
● Planners
● BDI
● Neural Networks
● Fuzzy Logic
Thank you!
grzegorz.mazur@vilemonarch.com
@dagenoth

Artificial Intelligence in games

  • 1.
    AI in VideoGames Grzegorz Mazur
  • 2.
    Who we are? VileMonarch Warsaw, Poland
  • 3.
    Who I am? ●Co-Boss and Technical Director at Vile Monarch ● Previously 11bit studios – Lead Programmer of This War of Mine and Sleepwalkers Journey ● Lecturer at Warsaw Film School ● Musician - amateur grzegorz.mazur@vilemonarch.com @dagenoth
  • 4.
    What is AIin games? ● Interactive system that animates game world ● AI Agent ● Agent based on his state and game world state takes action
  • 5.
    What is AIin games? Stimulus, for example: - enemy in sight - hearing call for help - taking damage State of agent, for ex: - HP level - resource quantity - current goal AI System Action, for example: - shooting - playing animation - beginning of movement - command to move troop
  • 6.
    What makes AIgood for player? ● It should support gameplay... ● ... especially create challenge ● Good AI DOESNT have to be SMART
  • 7.
    What makes AIgood for developer? ● It should support gameplay... ;) ● Configurable ● Predictable ● Reusable ● Scalable
  • 8.
    Scripted AI ● Simplescripts "if X then Y" and event-based programming ● Simple customization ● You have to predict everything ● Its hard to make it emergent ● It becomes drastically complicated with size
  • 9.
    Finite State Machines ●In every moment Agent is in a single, specific state. For example: combat, retreat, looking for enemy. ● State → specific behaviour ● Under specific conditions agent can make transistion from current state to another
  • 10.
  • 11.
    Behaviour Trees ● Node– complex agent behaviour ● Each node knows if he can run ● When node is running it tries to run its first runnable child ● Thats how tree-based decision structure appears ● At each moment only one branch of tree is running
  • 12.
  • 13.
    Behaviour Trees Enemy Combat Following after enemyIdle Choos random POI [Range:5m] Move [Speed:3] [Mode: Walk] Play random idle animation [Loop: false] [Time:5-10s] Wait [Time:5-10s]
  • 14.
    Behaviour Trees Enemy Combat Follow after enemyIdle Is enemy in range [Range: 1m] Play animation [Animation: hit] Deal damage [Damage: 30]
  • 15.
    Behaviour Trees ● Sequences,selectors, actions, decorators ● After certain time/after certain stimulus we cen reevaluate whole tree ● After reevaluation of tree a new branch can start running ● Behaviour trees look similar to hierarchical finiste state machines
  • 16.
  • 17.
    Influence Mapping ● Methodof finding areas in which we should move our troops ● Game world represented by grid or graph
  • 18.
    Influence Mapping ● Eachunit/building/resource on a map has its own base influence – area and value ● Map of our influence ● Map of enemy influence
  • 19.
    Influence Mapping ● InfluenceMap = Our influence map – enemy influence map ● Weight of area = influence / cost of movement ● Goal for troop = area with highest weight
  • 20.
    Influence Mapping ● Tensionmap = our influence + enemy influence ● The higher value – the bigger forces at the area ● Vulnerability map = tension map – ABS(influence map) ● The higher value – the bigger even fights at the area
  • 21.
    Influence Mapping ● Basedon information from different maps and additonal conditions we can create any strategy ● Optionally we can introduce inertia and propagation of influence ● Designer can introduce his own additional goal map ● Simple scripts are enough to make use of influence map
  • 22.
  • 23.
    Other techniques ● Planners ●BDI ● Neural Networks ● Fuzzy Logic
  • 24.