Game AI 101NPCs and Agents andAlgorithms... Oh My!                Luke DickenStrathclyde AI and Games Research Group      ...
Who Am I2
Who Am I    • PhD Student at University of Strathclyde2
Who Am I    • PhD Student at University of Strathclyde      ‣ BSc(Hons), MSc, MRes(Dist) in AI-related fields2
Who Am I    • PhD Student at University of Strathclyde      ‣ BSc(Hons), MSc, MRes(Dist) in AI-related fields    • Founding...
Who Am I    • PhD Student at University of Strathclyde      ‣ BSc(Hons), MSc, MRes(Dist) in AI-related fields    • Founding...
Who Am I    • PhD Student at University of Strathclyde      ‣ BSc(Hons), MSc, MRes(Dist) in AI-related fields    • Founding...
Who Am I    • PhD Student at University of Strathclyde      ‣ BSc(Hons), MSc, MRes(Dist) in AI-related fields    • Founding...
Who Am I    • PhD Student at University of Strathclyde      ‣ BSc(Hons), MSc, MRes(Dist) in AI-related fields    • Founding...
Game AI 1013
Game AI 101    • Today going to look at techniques to populate game     worlds with characters3
Game AI 101    • Today going to look at techniques to populate game     worlds with characters    • This is not state of t...
Game AI 101    • Today going to look at techniques to populate game     worlds with characters    • This is not state of t...
Game AI 101    • Today going to look at techniques to populate game     worlds with characters    • This is not state of t...
Game AI 101    • Today going to look at techniques to populate game     worlds with characters    • This is not state of t...
Game AI 101    • Today going to look at techniques to populate game     worlds with characters    • This is not state of t...
Game AI 101    • Today going to look at techniques to populate game     worlds with characters    • This is not state of t...
Pure AI vs Game AI4
Pure AI vs Game AI    • “Pure” AI is a scientific discipline4
Pure AI vs Game AI    • “Pure” AI is a scientific discipline       ‣ Interested in creating systems as smart as possible4
Pure AI vs Game AI    • “Pure” AI is a scientific discipline       ‣ Interested in creating systems as smart as possible   ...
Pure AI vs Game AI    • “Pure” AI is a scientific discipline       ‣ Interested in creating systems as smart as possible   ...
Pure AI vs Game AI    • “Pure” AI is a scientific discipline       ‣ Interested in creating systems as smart as possible   ...
Pure AI vs Game AI    • “Pure” AI is a scientific discipline       ‣ Interested in creating systems as smart as possible   ...
Pure AI vs Game AI    • “Pure” AI is a scientific discipline       ‣ Interested in creating systems as smart as possible   ...
Pure AI vs Game AI5
Pure AI vs Game AI6
Pure AI vs Game AI    • Pure AI for an NPC would be to make it fight as     effectively as possible.6
Pure AI vs Game AI    • Pure AI for an NPC would be to make it fight as     effectively as possible.    • Is that what we a...
Pure AI vs Game AI    • Pure AI for an NPC would be to make it fight as     effectively as possible.    • Is that what we a...
Pure AI vs Game AI    • Pure AI for an NPC would be to make it fight as     effectively as possible.    • Is that what we a...
Pure AI vs Game AI    • Pure AI for an NPC would be to make it fight as     effectively as possible.    • Is that what we a...
Pure AI vs Game AI    • Pure AI for an NPC would be to make it fight as     effectively as possible.    • Is that what we a...
Automated Opponents7
Automated Opponents    • Centuries of trying to play games with few players7
Automated Opponents    • Centuries of trying to play games with few players      ‣ Mechanical Turk claimed to be a chess p...
Automated Opponents    • Centuries of trying to play games with few players      ‣ Mechanical Turk claimed to be a chess p...
Automated Opponents    • Centuries of trying to play games with few players      ‣ Mechanical Turk claimed to be a chess p...
Automated Opponents    • Centuries of trying to play games with few players      ‣ Mechanical Turk claimed to be a chess p...
Automated Opponents    • Centuries of trying to play games with few players      ‣ Mechanical Turk claimed to be a chess p...
Automated Opponents    • Centuries of trying to play games with few players      ‣ Mechanical Turk claimed to be a chess p...
Automated Opponents    • Centuries of trying to play games with few players      ‣ Mechanical Turk claimed to be a chess p...
Looking and Being Smart8
Looking and Being Smart    • Two components to Game AI8
Looking and Being Smart    • Two components to Game AI      ‣ Looking Smart8
Looking and Being Smart    • Two components to Game AI      ‣ Looking Smart      ‣ Being Smart8
Looking and Being Smart    • Two components to Game AI      ‣ Looking Smart      ‣ Being Smart    • Focus in this session ...
Looking and Being Smart    • Two components to Game AI      ‣ Looking Smart      ‣ Being Smart    • Focus in this session ...
Looking and Being Smart    • Two components to Game AI      ‣ Looking Smart      ‣ Being Smart    • Focus in this session ...
Looking and Being Smart    • Two components to Game AI       ‣ Looking Smart       ‣ Being Smart    • Focus in this sessio...
Looking and Being Smart    • Two components to Game AI       ‣ Looking Smart       ‣ Being Smart    • Focus in this sessio...
Some AI Basics
What is     Artificial Intelligence?10
What is                Artificial Intelligence?     • Any time a computer has to pick between two or      more choices it c...
What is                 Artificial Intelligence?     • Any time a computer has to pick between two or      more choices it ...
What is                 Artificial Intelligence?     • Any time a computer has to pick between two or      more choices it ...
What is                 Artificial Intelligence?     • Any time a computer has to pick between two or      more choices it ...
Decision Making11
Decision Making     • Not going to get too bogged down today in      decision making process.11
Decision Making     • Not going to get too bogged down today in      decision making process.     • Science of decisions c...
Decision Making     • Not going to get too bogged down today in      decision making process.     • Science of decisions c...
Decision Making     • Not going to get too bogged down today in      decision making process.     • Science of decisions c...
Smart or Dumb?12
Smart or Dumb?     • Partly ignoring decision making because for Game      AI, it isn’t so important for intro level.12
Smart or Dumb?     • Partly ignoring decision making because for Game      AI, it isn’t so important for intro level.     ...
Smart or Dumb?     • Partly ignoring decision making because for Game      AI, it isn’t so important for intro level.     ...
Smart or Dumb?     • Partly ignoring decision making because for Game      AI, it isn’t so important for intro level.     ...
Smart or Dumb?     • Partly ignoring decision making because for Game      AI, it isn’t so important for intro level.     ...
Smart or Dumb?     • Partly ignoring decision making because for Game      AI, it isn’t so important for intro level.     ...
Smart or Dumb?     • Partly ignoring decision making because for Game      AI, it isn’t so important for intro level.     ...
Agent-Based Systems13
Agent-Based Systems13
Agent-Based Systems     • Intelligent Agents are things within our problem that      are going to be trying to act intelli...
Agent-Based Systems     • Intelligent Agents are things within our problem that      are going to be trying to act intelli...
Agent-Based Systems     • Intelligent Agents are things within our problem that      are going to be trying to act intelli...
Agent-Based Systems     • Intelligent Agents are things within our problem that      are going to be trying to act intelli...
Agent-Based Systems     • Intelligent Agents are things within our problem that      are going to be trying to act intelli...
Agent-Based Systems     • Intelligent Agents are things within our problem that      are going to be trying to act intelli...
Agent-Based Systems13
NPCs as Agents14
NPCs as Agents     • One of the core places we can apply “agent-based      systems” is when thinking about NPCs14
NPCs as Agents     • One of the core places we can apply “agent-based      systems” is when thinking about NPCs     • Each...
NPCs as Agents     • One of the core places we can apply “agent-based      systems” is when thinking about NPCs     • Each...
NPCs as Agents     • One of the core places we can apply “agent-based      systems” is when thinking about NPCs     • Each...
NPCs as Agents     • One of the core places we can apply “agent-based      systems” is when thinking about NPCs     • Each...
NPCs as Agents     • One of the core places we can apply “agent-based      systems” is when thinking about NPCs     • Each...
NPCs as Agents     • One of the core places we can apply “agent-based      systems” is when thinking about NPCs     • Each...
Representations15
Representations     • Software Engineering buzzwords!15
Representations     • Software Engineering buzzwords!     • Representation internal to one NPC or shared?15
Representations     • Software Engineering buzzwords!     • Representation internal to one NPC or shared?       ‣ Alien Hi...
Representations     • Software Engineering buzzwords!     • Representation internal to one NPC or shared?       ‣ Alien Hi...
Representations     • Software Engineering buzzwords!     • Representation internal to one NPC or shared?       ‣ Alien Hi...
Representations     • Software Engineering buzzwords!     • Representation internal to one NPC or shared?       ‣ Alien Hi...
Representations     • Software Engineering buzzwords!     • Representation internal to one NPC or shared?       ‣ Alien Hi...
Representations     • Software Engineering buzzwords!     • Representation internal to one NPC or shared?       ‣ Alien Hi...
Representations     • Software Engineering buzzwords!     • Representation internal to one NPC or shared?       ‣ Alien Hi...
AI in Game Worlds
Taking Our First Steps17
Taking Our First Steps     • For this session let’s assume we have17
Taking Our First Steps     • For this session let’s assume we have        ‣ A 3D world17
Taking Our First Steps     • For this session let’s assume we have        ‣ A 3D world        ‣ A pre-fab for an NPC17
Taking Our First Steps     • For this session let’s assume we have        ‣ A 3D world        ‣ A pre-fab for an NPC      ...
Taking Our First Steps     • For this session let’s assume we have        ‣ A 3D world        ‣ A pre-fab for an NPC      ...
Taking Our First Steps     • For this session let’s assume we have        ‣ A 3D world        ‣ A pre-fab for an NPC      ...
Moving at Random18
Moving at Random     • OK, let’s do something basic18
Moving at Random     • OK, let’s do something basic       ‣ Take our NPC, pick a location and go there.18
Moving at Random     • OK, let’s do something basic       ‣ Take our NPC, pick a location and go there.       ‣ When he ge...
Moving at Random     • OK, let’s do something basic       ‣ Take our NPC, pick a location and go there.       ‣ When he ge...
Moving at Random     • OK, let’s do something basic       ‣ Take our NPC, pick a location and go there.       ‣ When he ge...
Moving at Random     • OK, let’s do something basic       ‣ Take our NPC, pick a location and go there.       ‣ When he ge...
Moving at Random     • OK, let’s do something basic       ‣ Take our NPC, pick a location and go there.       ‣ When he ge...
Moving at Random19
Moving at Random     • Demo 119
Following the Player20
Following the Player     • Let’s do something a bit more sophisticated20
Following the Player     • Let’s do something a bit more sophisticated       ‣ Follow the player around the map20
Following the Player     • Let’s do something a bit more sophisticated       ‣ Follow the player around the map     • This...
Following the Player     • Let’s do something a bit more sophisticated       ‣ Follow the player around the map     • This...
Following the Player     • Let’s do something a bit more sophisticated       ‣ Follow the player around the map     • This...
Following the Player     • Let’s do something a bit more sophisticated        ‣ Follow the player around the map     • Thi...
Following the Player21
Following the Player     • Demo 221
On Patrol22
On Patrol     • Typically, we want soldiers guarding things, patrolling22
On Patrol     • Typically, we want soldiers guarding things, patrolling        ‣ Go to the next waypoint22
On Patrol     • Typically, we want soldiers guarding things, patrolling        ‣ Go to the next waypoint        ‣ When you...
On Patrol     • Typically, we want soldiers guarding things, patrolling        ‣ Go to the next waypoint        ‣ When you...
On Patrol     • Typically, we want soldiers guarding things, patrolling        ‣ Go to the next waypoint        ‣ When you...
On Patrol     • Typically, we want soldiers guarding things, patrolling        ‣ Go to the next waypoint        ‣ When you...
On Patrol     • Typically, we want soldiers guarding things, patrolling        ‣ Go to the next waypoint        ‣ When you...
On Patrol23
On Patrol     • Demo 323
Looking (Kinda) Smart24
Looking (Kinda) Smart     • An NPC that does just one thing is not smart24
Looking (Kinda) Smart     • An NPC that does just one thing is not smart     • Raging gun battle, it doesn’t make sense to...
Looking (Kinda) Smart     • An NPC that does just one thing is not smart     • Raging gun battle, it doesn’t make sense to...
Different Situations,     Different Behaviours25
Different Situations,                 Different Behaviours     • So we know that different situations are going to      ca...
Different Situations,                  Different Behaviours     • So we know that different situations are going to      c...
Different Situations,                  Different Behaviours     • So we know that different situations are going to      c...
Finite State Machines26
Finite State Machines     • FSMs are fundamental building blocks in Computer      Science26
Finite State Machines     • FSMs are fundamental building blocks in Computer      Science     • A machine that can be in o...
Finite State Machines     • FSMs are fundamental building blocks in Computer      Science     • A machine that can be in o...
Finite State Machine27
NPCs as an FSM28
NPCs as an FSM     • We can represent what behaviour is currently active      as a state in an FSM28
NPCs as an FSM     • We can represent what behaviour is currently active      as a state in an FSM     • When certain thin...
NPCs as an FSM     • We can represent what behaviour is currently active      as a state in an FSM     • When certain thin...
A Simple Guard29
A Simple Guard     • Let’s combine what we’ve seen already29
A Simple Guard     • Let’s combine what we’ve seen already       ‣ A guard stands idle29
A Simple Guard     • Let’s combine what we’ve seen already       ‣ A guard stands idle       ‣ When he sees the player he ...
A Simple Guard     • Let’s combine what we’ve seen already       ‣ A guard stands idle       ‣ When he sees the player he ...
A Simple Guard30
A Simple Guard     • Demo 430
Non-Boolean Transitions31
Non-Boolean Transitions     • We can track non-boolean values and use these as      triggers for state transitions31
Non-Boolean Transitions     • We can track non-boolean values and use these as      triggers for state transitions     • J...
Suspicious Guard32
Suspicious Guard     • This time, the guard will grow suspicious the longer      the player stays in view.32
Suspicious Guard     • This time, the guard will grow suspicious the longer      the player stays in view.        ‣ When s...
Suspicious Guard     • This time, the guard will grow suspicious the longer      the player stays in view.        ‣ When s...
Suspicious Guard     • This time, the guard will grow suspicious the longer      the player stays in view.        ‣ When s...
Suspicious Guard33
Suspicious Guard     • Demo 533
Beyond FSMs34
Beyond FSMs     • Finite State Machines are easy to understand34
Beyond FSMs     • Finite State Machines are easy to understand     • But they get complicated quickly34
Beyond FSMs     • Finite State Machines are easy to understand     • But they get complicated quickly       ‣ Particularly...
Beyond FSMs     • Finite State Machines are easy to understand     • But they get complicated quickly        ‣ Particularl...
Beyond FSMs     • Finite State Machines are easy to understand     • But they get complicated quickly        ‣ Particularl...
Hierarchical Concurrent         State Machines35
Hierarchical Concurrent                  State Machines     • Recent addition to the AI developers arsenal35
Hierarchical Concurrent                  State Machines     • Recent addition to the AI developers arsenal     • Popular a...
Hierarchical Concurrent                  State Machines     • Recent addition to the AI developers arsenal     • Popular a...
Hierarchical Concurrent                   State Machines     • Recent addition to the AI developers arsenal     • Popular ...
Hierarchical Concurrent                   State Machines     • Recent addition to the AI developers arsenal     • Popular ...
Hierarchical Concurrent         State Machines36
Hierarchical Concurrent                 State Machines     • Building block of an HCSM is itself an HCSM36
Hierarchical Concurrent                  State Machines     • Building block of an HCSM is itself an HCSM       ‣ Recursiv...
Hierarchical Concurrent                  State Machines     • Building block of an HCSM is itself an HCSM       ‣ Recursiv...
Hierarchical Concurrent                  State Machines     • Building block of an HCSM is itself an HCSM       ‣ Recursiv...
Hierarchical Concurrent                  State Machines     • Building block of an HCSM is itself an HCSM       ‣ Recursiv...
Hierarchical Concurrent         State Machines37
Behaviour Trees38
Behaviour Trees     • Behaviour Trees are another great way of deciding      which of a bunch of behaviours should be acti...
Behaviour Trees     • Behaviour Trees are another great way of deciding      which of a bunch of behaviours should be acti...
Behaviour Trees     • Behaviour Trees are another great way of deciding      which of a bunch of behaviours should be acti...
Example Behaviour Tree            “Introduction to Behaviour Trees”, Bjoern Knafla                                       Al...
Path Finding40
Path Finding     • Being able to automatically work out how to move      around a world is a common AI problem40
Path Finding     • Being able to automatically work out how to move      around a world is a common AI problem     • Sever...
Path Finding     • Being able to automatically work out how to move      around a world is a common AI problem     • Sever...
Path Finding     • Being able to automatically work out how to move      around a world is a common AI problem     • Sever...
Path Finding     • Being able to automatically work out how to move      around a world is a common AI problem     • Sever...
Path Finding     • Being able to automatically work out how to move      around a world is a common AI problem     • Sever...
Heuristic Example - A*41
Heuristic Example - A*                     B         A42
Heuristic Example - A*                     B         A43
Heuristic Example - A*                     B     1+7    A           1 +744
Heuristic Example - A*                     B     1+7    A           1 +745
Heuristic Example - A*                      B     2+6     1+7    A     2 + 8 1 +746
Heuristic Example - A*                      B     2+6     1+7    A     2 + 8 1 +747
Heuristic Example - A*                      B     3+5     2+6     1+7    A     2 + 8 1 +748
Heuristic Example - A*                      B     3+5     2+6     1+7    A     2 + 8 1 +749
Heuristic Example - A*     4+4              B     3+5 4+4     2+6     1+7    A     2 + 8 1 +750
Heuristic Example - A*     4+4 5+3          B     3+5 4+4 5+3     2+6     1+7    A     2 + 8 1 +751
Heuristic Example - A*     4+4 5+3 6+2        B     3+5 4+4 5+3     2+6          6+4     1+7    A     2 + 8 1 +752
Heuristic Example - A*     4+4 5+3 6+2        B     3+5 4+4 5+3     2+6          6+4     1+7    A     2 + 8 1 +753
Heuristic Example - A*     4+4 5+3 6+2        B     3+5 4+4 5+3     2+6        6+4     1+7    A     2 + 8 1 +7 2 + 654
Heuristic Example - A*     4+4 5+3 6+2        B     3+5 4+4 5+3     2+6        6+4     1+7    A     2 + 8 1 +7 2 + 655
Heuristic Example - A*     4+4 5+3 6+2              B     3+5 4+4 5+3     2+6        6+4     1+7    A     2 + 8 1 +7 2 + 6...
Heuristic Example - A*     4+4 5+3 6+2             B     3+5 4+4 5+3     2+6        6+4     1+7    A         4+4     2 + 8...
Heuristic Example - A*     4+4 5+3 6+2             B     3+5 4+4 5+3     2+6        6+4     1+7    A         4+4     2 + 8...
Heuristic Example - A*     4+4 5+3 6+2             B     3+5 4+4 5+3     2+6        6+4 5+3     1+7    A         4+4 5+3  ...
Heuristic Example - A*     4+4 5+3 6+2             B     3+5 4+4 5+3     2+6        6+4 5+3     1+7    A         4+4 5+3  ...
Heuristic Example - A*     4+4 5+3 6+2             B     3+5 4+4 5+3     2+6        6+4 5+3 6+2     1+7    A         4+4 5...
Heuristic Example - A*     4+4 5+3 6+2             B     3+5 4+4 5+3     2+6        6+4 5+3 6+2     1+7    A         4+4 5...
Heuristic Example - A*     4+4 5+3 6+2             B     3+5 4+4 5+3            7+1     2+6        6+4 5+3 6+2     1+7    ...
Heuristic Example - A*     4+4 5+3 6+2             B     3+5 4+4 5+3            7+1     2+6        6+4 5+3 6+2     1+7    ...
Heuristic Example - A*     4+4 5+3 6+2             B     3+5 4+4 5+3            7+1     2+6        6+4 5+3 6+2     1+7    ...
Heuristic Example - A*     4+4 5+3 6+2             B     3+5 4+4 5+3            7+1     2+6        6+4 5+3 6+2     1+7    ...
Pathfinding in Unity67
Pathfinding in Unity     • Unity 3.5 now includes pathfinding natively67
Pathfinding in Unity     • Unity 3.5 now includes pathfinding natively       ‣ Pro only apparently67
Pathfinding in Unity     • Unity 3.5 now includes pathfinding natively       ‣ Pro only apparently     • Not entirely sure h...
Pathfinding in Unity     • Unity 3.5 now includes pathfinding natively       ‣ Pro only apparently     • Not entirely sure h...
Pathfinding in Unity     • Unity 3.5 now includes pathfinding natively        ‣ Pro only apparently     • Not entirely sure ...
Path68
Path     • Demo 668
Runtime Woes69
Runtime Woes     • We’ve talked about pathfinding and decision making69
Runtime Woes     • We’ve talked about pathfinding and decision making     • These can be computationally hard problems69
Runtime Woes     • We’ve talked about pathfinding and decision making     • These can be computationally hard problems     ...
Runtime Woes     • We’ve talked about pathfinding and decision making     • These can be computationally hard problems     ...
Runtime Woes     • We’ve talked about pathfinding and decision making     • These can be computationally hard problems     ...
Runtime Woes     • We’ve talked about pathfinding and decision making     • These can be computationally hard problems     ...
Runtime Woes     • We’ve talked about pathfinding and decision making     • These can be computationally hard problems     ...
Breaking Problems Up70
Breaking Problems Up     • So we know that we might want to do things take      longer than we have.70
Breaking Problems Up     • So we know that we might want to do things take      longer than we have.     • How can we brea...
Breaking Problems Up     • So we know that we might want to do things take      longer than we have.     • How can we brea...
Breaking Problems Up     • So we know that we might want to do things take      longer than we have.     • How can we brea...
Coroutines71
Coroutines     • Coroutines are blocks of code that can return a      value partway through execution.71
Coroutines     • Coroutines are blocks of code that can return a      value partway through execution.     • Next time tha...
Coroutines     • Coroutines are blocks of code that can return a      value partway through execution.     • Next time tha...
Coroutines     • Coroutines are blocks of code that can return a      value partway through execution.     • Next time tha...
Juggling Timings72
Juggling Timings     • Another great use of Coroutines is to get timing of      things right.72
Juggling Timings     • Another great use of Coroutines is to get timing of      things right.          - Lots of things in...
Juggling Timings     • Another great use of Coroutines is to get timing of      things right.          - Lots of things in...
Juggling Timings     • Another great use of Coroutines is to get timing of      things right.          - Lots of things in...
Juggling Timings     • Another great use of Coroutines is to get timing of      things right.          - Lots of things in...
Juggling Timings     • Another great use of Coroutines is to get timing of      things right.          - Lots of things in...
Juggling Timings     • Another great use of Coroutines is to get timing of      things right.          - Lots of things in...
Coroutines in practice73
Coroutines in practice     • Demo73
Summary74
Summary     • Today we covered basics/fundamentals74
Summary     • Today we covered basics/fundamentals       ‣ What we’re trying to achieve with Game AI74
Summary     • Today we covered basics/fundamentals       ‣ What we’re trying to achieve with Game AI       ‣ Some very sim...
Summary     • Today we covered basics/fundamentals       ‣ What we’re trying to achieve with Game AI       ‣ Some very sim...
Summary     • Today we covered basics/fundamentals       ‣ What we’re trying to achieve with Game AI       ‣ Some very sim...
Summary     • Today we covered basics/fundamentals       ‣ What we’re trying to achieve with Game AI       ‣ Some very sim...
Summary     • Today we covered basics/fundamentals       ‣ What we’re trying to achieve with Game AI       ‣ Some very sim...
Takeaways75
Takeaways     1. AI is awesome75
Takeaways     1. AI is awesome     2. AI is complicated75
Takeaways     1. AI is awesome     2. AI is complicated     3. AI doesn’t need to be scary75
But Wait There’s More!76
But Wait There’s More!     • We haven’t scratched the surface of what we can do      with AI.76
But Wait There’s More!     • We haven’t scratched the surface of what we can do      with AI.       ‣ AI for companions76
But Wait There’s More!     • We haven’t scratched the surface of what we can do      with AI.       ‣ AI for companions   ...
But Wait There’s More!     • We haven’t scratched the surface of what we can do      with AI.       ‣ AI for companions   ...
But Wait There’s More!     • We haven’t scratched the surface of what we can do      with AI.       ‣ AI for companions   ...
Contact     • luke@cis.strath.ac.uk     • @LukeD     • http://saig.cis.strath.ac.uk - Research Group     • http://lukedick...
Upcoming SlideShare
Loading in …5
×

Game AI 101 - NPCs and Agents and Algorithms... Oh My!

4,695
-1

Published on

This is a session originally written for students at Bradley University (Peoria, IL).

It covers a very high level introduction to the concepts behind Game AI, and includes some examples of how we can begin to make characters in a game world perform actions and appear to be making intelligent decisions.

Published in: Technology, Education
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,695
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
191
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Game AI 101 - NPCs and Agents and Algorithms... Oh My!

    1. 1. Game AI 101NPCs and Agents andAlgorithms... Oh My! Luke DickenStrathclyde AI and Games Research Group University of Strathclyde
    2. 2. Who Am I2
    3. 3. Who Am I • PhD Student at University of Strathclyde2
    4. 4. Who Am I • PhD Student at University of Strathclyde ‣ BSc(Hons), MSc, MRes(Dist) in AI-related fields2
    5. 5. Who Am I • PhD Student at University of Strathclyde ‣ BSc(Hons), MSc, MRes(Dist) in AI-related fields • Founding member of SAIG2
    6. 6. Who Am I • PhD Student at University of Strathclyde ‣ BSc(Hons), MSc, MRes(Dist) in AI-related fields • Founding member of SAIG • AltDevBlogADay author2
    7. 7. Who Am I • PhD Student at University of Strathclyde ‣ BSc(Hons), MSc, MRes(Dist) in AI-related fields • Founding member of SAIG • AltDevBlogADay author • AltDevConf organiser2
    8. 8. Who Am I • PhD Student at University of Strathclyde ‣ BSc(Hons), MSc, MRes(Dist) in AI-related fields • Founding member of SAIG • AltDevBlogADay author • AltDevConf organiser • Board of Directors for IGDA Scotland2
    9. 9. Who Am I • PhD Student at University of Strathclyde ‣ BSc(Hons), MSc, MRes(Dist) in AI-related fields • Founding member of SAIG • AltDevBlogADay author • AltDevConf organiser • Board of Directors for IGDA Scotland • Recipient of the 2012 Eric Dybsand Memorial AI Scholarship to attend GDC2
    10. 10. Game AI 1013
    11. 11. Game AI 101 • Today going to look at techniques to populate game worlds with characters3
    12. 12. Game AI 101 • Today going to look at techniques to populate game worlds with characters • This is not state of the art stuff, this is entry level3
    13. 13. Game AI 101 • Today going to look at techniques to populate game worlds with characters • This is not state of the art stuff, this is entry level • We will be dealing with a mix of3
    14. 14. Game AI 101 • Today going to look at techniques to populate game worlds with characters • This is not state of the art stuff, this is entry level • We will be dealing with a mix of ‣ Concepts3
    15. 15. Game AI 101 • Today going to look at techniques to populate game worlds with characters • This is not state of the art stuff, this is entry level • We will be dealing with a mix of ‣ Concepts ‣ Examples3
    16. 16. Game AI 101 • Today going to look at techniques to populate game worlds with characters • This is not state of the art stuff, this is entry level • We will be dealing with a mix of ‣ Concepts ‣ Examples ‣ Code3
    17. 17. Game AI 101 • Today going to look at techniques to populate game worlds with characters • This is not state of the art stuff, this is entry level • We will be dealing with a mix of ‣ Concepts ‣ Examples ‣ Code • Assumes familiarity with Unity3
    18. 18. Pure AI vs Game AI4
    19. 19. Pure AI vs Game AI • “Pure” AI is a scientific discipline4
    20. 20. Pure AI vs Game AI • “Pure” AI is a scientific discipline ‣ Interested in creating systems as smart as possible4
    21. 21. Pure AI vs Game AI • “Pure” AI is a scientific discipline ‣ Interested in creating systems as smart as possible ‣ Optimal solutions to real-world problems4
    22. 22. Pure AI vs Game AI • “Pure” AI is a scientific discipline ‣ Interested in creating systems as smart as possible ‣ Optimal solutions to real-world problems • Game AI is a whole other thing4
    23. 23. Pure AI vs Game AI • “Pure” AI is a scientific discipline ‣ Interested in creating systems as smart as possible ‣ Optimal solutions to real-world problems • Game AI is a whole other thing ‣ Create “realistic simulations” of intelligence4
    24. 24. Pure AI vs Game AI • “Pure” AI is a scientific discipline ‣ Interested in creating systems as smart as possible ‣ Optimal solutions to real-world problems • Game AI is a whole other thing ‣ Create “realistic simulations” of intelligence - E.g. Believable characters4
    25. 25. Pure AI vs Game AI • “Pure” AI is a scientific discipline ‣ Interested in creating systems as smart as possible ‣ Optimal solutions to real-world problems • Game AI is a whole other thing ‣ Create “realistic simulations” of intelligence - E.g. Believable characters ‣ Enhance the players experience4
    26. 26. Pure AI vs Game AI5
    27. 27. Pure AI vs Game AI6
    28. 28. Pure AI vs Game AI • Pure AI for an NPC would be to make it fight as effectively as possible.6
    29. 29. Pure AI vs Game AI • Pure AI for an NPC would be to make it fight as effectively as possible. • Is that what we actually want to achieve?6
    30. 30. Pure AI vs Game AI • Pure AI for an NPC would be to make it fight as effectively as possible. • Is that what we actually want to achieve? • Game AI aims to make an immersive experience6
    31. 31. Pure AI vs Game AI • Pure AI for an NPC would be to make it fight as effectively as possible. • Is that what we actually want to achieve? • Game AI aims to make an immersive experience ‣ Represent a thug character accurately6
    32. 32. Pure AI vs Game AI • Pure AI for an NPC would be to make it fight as effectively as possible. • Is that what we actually want to achieve? • Game AI aims to make an immersive experience ‣ Represent a thug character accurately ‣ Allow the player to “become” Batman6
    33. 33. Pure AI vs Game AI • Pure AI for an NPC would be to make it fight as effectively as possible. • Is that what we actually want to achieve? • Game AI aims to make an immersive experience ‣ Represent a thug character accurately ‣ Allow the player to “become” Batman • Entertainment, not problem solving6
    34. 34. Automated Opponents7
    35. 35. Automated Opponents • Centuries of trying to play games with few players7
    36. 36. Automated Opponents • Centuries of trying to play games with few players ‣ Mechanical Turk claimed to be a chess player circa 17707
    37. 37. Automated Opponents • Centuries of trying to play games with few players ‣ Mechanical Turk claimed to be a chess player circa 1770 ‣ First video game example - Pong 19727
    38. 38. Automated Opponents • Centuries of trying to play games with few players ‣ Mechanical Turk claimed to be a chess player circa 1770 ‣ First video game example - Pong 1972 ‣ Ongoing commercial interest - FPS “Bots” RTS “Skirmish”7
    39. 39. Automated Opponents • Centuries of trying to play games with few players ‣ Mechanical Turk claimed to be a chess player circa 1770 ‣ First video game example - Pong 1972 ‣ Ongoing commercial interest - FPS “Bots” RTS “Skirmish”7
    40. 40. Automated Opponents • Centuries of trying to play games with few players ‣ Mechanical Turk claimed to be a chess player circa 1770 ‣ First video game example - Pong 1972 ‣ Ongoing commercial interest - FPS “Bots” RTS “Skirmish” • Emphasis now on delivering a good player experience.7
    41. 41. Automated Opponents • Centuries of trying to play games with few players ‣ Mechanical Turk claimed to be a chess player circa 1770 ‣ First video game example - Pong 1972 ‣ Ongoing commercial interest - FPS “Bots” RTS “Skirmish” • Emphasis now on delivering a good player experience. ‣ Human-like rather than “good” AI7
    42. 42. Automated Opponents • Centuries of trying to play games with few players ‣ Mechanical Turk claimed to be a chess player circa 1770 ‣ First video game example - Pong 1972 ‣ Ongoing commercial interest - FPS “Bots” RTS “Skirmish” • Emphasis now on delivering a good player experience. ‣ Human-like rather than “good” AI ‣ Sub-human in order to be beatable7
    43. 43. Looking and Being Smart8
    44. 44. Looking and Being Smart • Two components to Game AI8
    45. 45. Looking and Being Smart • Two components to Game AI ‣ Looking Smart8
    46. 46. Looking and Being Smart • Two components to Game AI ‣ Looking Smart ‣ Being Smart8
    47. 47. Looking and Being Smart • Two components to Game AI ‣ Looking Smart ‣ Being Smart • Focus in this session on “Being Smart”8
    48. 48. Looking and Being Smart • Two components to Game AI ‣ Looking Smart ‣ Being Smart • Focus in this session on “Being Smart” • Looking Smart is more of an animation / art issue8
    49. 49. Looking and Being Smart • Two components to Game AI ‣ Looking Smart ‣ Being Smart • Focus in this session on “Being Smart” • Looking Smart is more of an animation / art issue ‣ Does the character “feel” intelligent8
    50. 50. Looking and Being Smart • Two components to Game AI ‣ Looking Smart ‣ Being Smart • Focus in this session on “Being Smart” • Looking Smart is more of an animation / art issue ‣ Does the character “feel” intelligent • Good decision making still required to drive this8
    51. 51. Looking and Being Smart • Two components to Game AI ‣ Looking Smart ‣ Being Smart • Focus in this session on “Being Smart” • Looking Smart is more of an animation / art issue ‣ Does the character “feel” intelligent • Good decision making still required to drive this ‣ Be smart, then trigger equivalent “look smart”8
    52. 52. Some AI Basics
    53. 53. What is Artificial Intelligence?10
    54. 54. What is Artificial Intelligence? • Any time a computer has to pick between two or more choices it can be said it is acting “intelligently”10
    55. 55. What is Artificial Intelligence? • Any time a computer has to pick between two or more choices it can be said it is acting “intelligently” • That isn’t to say that it is inherently making good choices.10
    56. 56. What is Artificial Intelligence? • Any time a computer has to pick between two or more choices it can be said it is acting “intelligently” • That isn’t to say that it is inherently making good choices. ‣ Tho neither do people...10
    57. 57. What is Artificial Intelligence? • Any time a computer has to pick between two or more choices it can be said it is acting “intelligently” • That isn’t to say that it is inherently making good choices. ‣ Tho neither do people... • Typically, looking for better-than-random levels of sophistication10
    58. 58. Decision Making11
    59. 59. Decision Making • Not going to get too bogged down today in decision making process.11
    60. 60. Decision Making • Not going to get too bogged down today in decision making process. • Science of decisions can fill multiple degree-level courses11
    61. 61. Decision Making • Not going to get too bogged down today in decision making process. • Science of decisions can fill multiple degree-level courses • Game Theory is a good starting point to learn more11
    62. 62. Decision Making • Not going to get too bogged down today in decision making process. • Science of decisions can fill multiple degree-level courses • Game Theory is a good starting point to learn more ‣ “Behavioral Mathematics for Game AI” Dave Mark11
    63. 63. Smart or Dumb?12
    64. 64. Smart or Dumb? • Partly ignoring decision making because for Game AI, it isn’t so important for intro level.12
    65. 65. Smart or Dumb? • Partly ignoring decision making because for Game AI, it isn’t so important for intro level. ‣ Making a decision is a good start12
    66. 66. Smart or Dumb? • Partly ignoring decision making because for Game AI, it isn’t so important for intro level. ‣ Making a decision is a good start • Partly because of the entertainment issue12
    67. 67. Smart or Dumb? • Partly ignoring decision making because for Game AI, it isn’t so important for intro level. ‣ Making a decision is a good start • Partly because of the entertainment issue ‣ Making good decisions is irrelevant12
    68. 68. Smart or Dumb? • Partly ignoring decision making because for Game AI, it isn’t so important for intro level. ‣ Making a decision is a good start • Partly because of the entertainment issue ‣ Making good decisions is irrelevant ‣ We don’t want tactical genius soldiers12
    69. 69. Smart or Dumb? • Partly ignoring decision making because for Game AI, it isn’t so important for intro level. ‣ Making a decision is a good start • Partly because of the entertainment issue ‣ Making good decisions is irrelevant ‣ We don’t want tactical genius soldiers • Partly for rapid iteration12
    70. 70. Smart or Dumb? • Partly ignoring decision making because for Game AI, it isn’t so important for intro level. ‣ Making a decision is a good start • Partly because of the entertainment issue ‣ Making good decisions is irrelevant ‣ We don’t want tactical genius soldiers • Partly for rapid iteration ‣ Make any decision, figure out how to make it better later12
    71. 71. Agent-Based Systems13
    72. 72. Agent-Based Systems13
    73. 73. Agent-Based Systems • Intelligent Agents are things within our problem that are going to be trying to act intelligently.13
    74. 74. Agent-Based Systems • Intelligent Agents are things within our problem that are going to be trying to act intelligently. • Could be a Roomba, a warehouse robot, an automated trip booking system or a predator drone13
    75. 75. Agent-Based Systems • Intelligent Agents are things within our problem that are going to be trying to act intelligently. • Could be a Roomba, a warehouse robot, an automated trip booking system or a predator drone • Agents have three important characteristics13
    76. 76. Agent-Based Systems • Intelligent Agents are things within our problem that are going to be trying to act intelligently. • Could be a Roomba, a warehouse robot, an automated trip booking system or a predator drone • Agents have three important characteristics ‣ Sense the environment13
    77. 77. Agent-Based Systems • Intelligent Agents are things within our problem that are going to be trying to act intelligently. • Could be a Roomba, a warehouse robot, an automated trip booking system or a predator drone • Agents have three important characteristics ‣ Sense the environment ‣ “Think” about what to do13
    78. 78. Agent-Based Systems • Intelligent Agents are things within our problem that are going to be trying to act intelligently. • Could be a Roomba, a warehouse robot, an automated trip booking system or a predator drone • Agents have three important characteristics ‣ Sense the environment ‣ “Think” about what to do ‣ Turn “thinking” into actions within the environment13
    79. 79. Agent-Based Systems13
    80. 80. NPCs as Agents14
    81. 81. NPCs as Agents • One of the core places we can apply “agent-based systems” is when thinking about NPCs14
    82. 82. NPCs as Agents • One of the core places we can apply “agent-based systems” is when thinking about NPCs • Each NPC is an agent.14
    83. 83. NPCs as Agents • One of the core places we can apply “agent-based systems” is when thinking about NPCs • Each NPC is an agent. ‣ In some situations we may have a “General” as the agent14
    84. 84. NPCs as Agents • One of the core places we can apply “agent-based systems” is when thinking about NPCs • Each NPC is an agent. ‣ In some situations we may have a “General” as the agent - Directing NPCs around as its way of affecting the world.14
    85. 85. NPCs as Agents • One of the core places we can apply “agent-based systems” is when thinking about NPCs • Each NPC is an agent. ‣ In some situations we may have a “General” as the agent - Directing NPCs around as its way of affecting the world. • In this model14
    86. 86. NPCs as Agents • One of the core places we can apply “agent-based systems” is when thinking about NPCs • Each NPC is an agent. ‣ In some situations we may have a “General” as the agent - Directing NPCs around as its way of affecting the world. • In this model ‣ NPCs sense the world14
    87. 87. NPCs as Agents • One of the core places we can apply “agent-based systems” is when thinking about NPCs • Each NPC is an agent. ‣ In some situations we may have a “General” as the agent - Directing NPCs around as its way of affecting the world. • In this model ‣ NPCs sense the world ‣ Decide what to do, then do it14
    88. 88. Representations15
    89. 89. Representations • Software Engineering buzzwords!15
    90. 90. Representations • Software Engineering buzzwords! • Representation internal to one NPC or shared?15
    91. 91. Representations • Software Engineering buzzwords! • Representation internal to one NPC or shared? ‣ Alien Hivemind - All units know what one unit knows15
    92. 92. Representations • Software Engineering buzzwords! • Representation internal to one NPC or shared? ‣ Alien Hivemind - All units know what one unit knows - Communal blackboard!15
    93. 93. Representations • Software Engineering buzzwords! • Representation internal to one NPC or shared? ‣ Alien Hivemind - All units know what one unit knows - Communal blackboard! ‣ Modern Squad - Communication between certain units15
    94. 94. Representations • Software Engineering buzzwords! • Representation internal to one NPC or shared? ‣ Alien Hivemind - All units know what one unit knows - Communal blackboard! ‣ Modern Squad - Communication between certain units - This was made explicit in “Enslaved Odyssey to the West”15
    95. 95. Representations • Software Engineering buzzwords! • Representation internal to one NPC or shared? ‣ Alien Hivemind - All units know what one unit knows - Communal blackboard! ‣ Modern Squad - Communication between certain units - This was made explicit in “Enslaved Odyssey to the West” - Message passing between units15
    96. 96. Representations • Software Engineering buzzwords! • Representation internal to one NPC or shared? ‣ Alien Hivemind - All units know what one unit knows - Communal blackboard! ‣ Modern Squad - Communication between certain units - This was made explicit in “Enslaved Odyssey to the West” - Message passing between units ‣ Medieval Guards - No widespread communication15
    97. 97. Representations • Software Engineering buzzwords! • Representation internal to one NPC or shared? ‣ Alien Hivemind - All units know what one unit knows - Communal blackboard! ‣ Modern Squad - Communication between certain units - This was made explicit in “Enslaved Odyssey to the West” - Message passing between units ‣ Medieval Guards - No widespread communication - Pure-internal representation15
    98. 98. AI in Game Worlds
    99. 99. Taking Our First Steps17
    100. 100. Taking Our First Steps • For this session let’s assume we have17
    101. 101. Taking Our First Steps • For this session let’s assume we have ‣ A 3D world17
    102. 102. Taking Our First Steps • For this session let’s assume we have ‣ A 3D world ‣ A pre-fab for an NPC17
    103. 103. Taking Our First Steps • For this session let’s assume we have ‣ A 3D world ‣ A pre-fab for an NPC - Surprise! We’ll be using the Unity soldier today17
    104. 104. Taking Our First Steps • For this session let’s assume we have ‣ A 3D world ‣ A pre-fab for an NPC - Surprise! We’ll be using the Unity soldier today • We’re going to work today with FPS, but the techniques generalise fine.17
    105. 105. Taking Our First Steps • For this session let’s assume we have ‣ A 3D world ‣ A pre-fab for an NPC - Surprise! We’ll be using the Unity soldier today • We’re going to work today with FPS, but the techniques generalise fine. • Examples today come primarily from Steve Gargolinski ( http://stevegargolinski.com )17
    106. 106. Moving at Random18
    107. 107. Moving at Random • OK, let’s do something basic18
    108. 108. Moving at Random • OK, let’s do something basic ‣ Take our NPC, pick a location and go there.18
    109. 109. Moving at Random • OK, let’s do something basic ‣ Take our NPC, pick a location and go there. ‣ When he gets there, pick another location etc.18
    110. 110. Moving at Random • OK, let’s do something basic ‣ Take our NPC, pick a location and go there. ‣ When he gets there, pick another location etc. • We need to18
    111. 111. Moving at Random • OK, let’s do something basic ‣ Take our NPC, pick a location and go there. ‣ When he gets there, pick another location etc. • We need to ‣ Pick a location randomly18
    112. 112. Moving at Random • OK, let’s do something basic ‣ Take our NPC, pick a location and go there. ‣ When he gets there, pick another location etc. • We need to ‣ Pick a location randomly ‣ Be able to move the NPC about18
    113. 113. Moving at Random • OK, let’s do something basic ‣ Take our NPC, pick a location and go there. ‣ When he gets there, pick another location etc. • We need to ‣ Pick a location randomly ‣ Be able to move the NPC about ‣ Be able to detect when we get to the location18
    114. 114. Moving at Random19
    115. 115. Moving at Random • Demo 119
    116. 116. Following the Player20
    117. 117. Following the Player • Let’s do something a bit more sophisticated20
    118. 118. Following the Player • Let’s do something a bit more sophisticated ‣ Follow the player around the map20
    119. 119. Following the Player • Let’s do something a bit more sophisticated ‣ Follow the player around the map • This time we need to20
    120. 120. Following the Player • Let’s do something a bit more sophisticated ‣ Follow the player around the map • This time we need to ‣ Determine position of the target20
    121. 121. Following the Player • Let’s do something a bit more sophisticated ‣ Follow the player around the map • This time we need to ‣ Determine position of the target ‣ Move towards the target20
    122. 122. Following the Player • Let’s do something a bit more sophisticated ‣ Follow the player around the map • This time we need to ‣ Determine position of the target ‣ Move towards the target • Very similar to the last example, this time we have a non-random target20
    123. 123. Following the Player21
    124. 124. Following the Player • Demo 221
    125. 125. On Patrol22
    126. 126. On Patrol • Typically, we want soldiers guarding things, patrolling22
    127. 127. On Patrol • Typically, we want soldiers guarding things, patrolling ‣ Go to the next waypoint22
    128. 128. On Patrol • Typically, we want soldiers guarding things, patrolling ‣ Go to the next waypoint ‣ When you get there, go to the next in the series etc22
    129. 129. On Patrol • Typically, we want soldiers guarding things, patrolling ‣ Go to the next waypoint ‣ When you get there, go to the next in the series etc • Still just an iterative improvement on previous22
    130. 130. On Patrol • Typically, we want soldiers guarding things, patrolling ‣ Go to the next waypoint ‣ When you get there, go to the next in the series etc • Still just an iterative improvement on previous ‣ We need to track where the waypoints are22
    131. 131. On Patrol • Typically, we want soldiers guarding things, patrolling ‣ Go to the next waypoint ‣ When you get there, go to the next in the series etc • Still just an iterative improvement on previous ‣ We need to track where the waypoints are ‣ Which one we are near22
    132. 132. On Patrol • Typically, we want soldiers guarding things, patrolling ‣ Go to the next waypoint ‣ When you get there, go to the next in the series etc • Still just an iterative improvement on previous ‣ We need to track where the waypoints are ‣ Which one we are near ‣ Which comes next in a sequence22
    133. 133. On Patrol23
    134. 134. On Patrol • Demo 323
    135. 135. Looking (Kinda) Smart24
    136. 136. Looking (Kinda) Smart • An NPC that does just one thing is not smart24
    137. 137. Looking (Kinda) Smart • An NPC that does just one thing is not smart • Raging gun battle, it doesn’t make sense to carry on patrolling.24
    138. 138. Looking (Kinda) Smart • An NPC that does just one thing is not smart • Raging gun battle, it doesn’t make sense to carry on patrolling. • We’ve got now three different sets of code for specific jobs, no way to swap between them.24
    139. 139. Different Situations, Different Behaviours25
    140. 140. Different Situations, Different Behaviours • So we know that different situations are going to call for different behaviours25
    141. 141. Different Situations, Different Behaviours • So we know that different situations are going to call for different behaviours • We need to be able to swap from one to another realistically25
    142. 142. Different Situations, Different Behaviours • So we know that different situations are going to call for different behaviours • We need to be able to swap from one to another realistically • This is where we’re going to really be using AI techniques25
    143. 143. Finite State Machines26
    144. 144. Finite State Machines • FSMs are fundamental building blocks in Computer Science26
    145. 145. Finite State Machines • FSMs are fundamental building blocks in Computer Science • A machine that can be in one of a number of states26
    146. 146. Finite State Machines • FSMs are fundamental building blocks in Computer Science • A machine that can be in one of a number of states • It transitions from one state to another when certain conditions are met26
    147. 147. Finite State Machine27
    148. 148. NPCs as an FSM28
    149. 149. NPCs as an FSM • We can represent what behaviour is currently active as a state in an FSM28
    150. 150. NPCs as an FSM • We can represent what behaviour is currently active as a state in an FSM • When certain things happen we can transition to a different state28
    151. 151. NPCs as an FSM • We can represent what behaviour is currently active as a state in an FSM • When certain things happen we can transition to a different state • We can move around states as required28
    152. 152. A Simple Guard29
    153. 153. A Simple Guard • Let’s combine what we’ve seen already29
    154. 154. A Simple Guard • Let’s combine what we’ve seen already ‣ A guard stands idle29
    155. 155. A Simple Guard • Let’s combine what we’ve seen already ‣ A guard stands idle ‣ When he sees the player he begins approaching29
    156. 156. A Simple Guard • Let’s combine what we’ve seen already ‣ A guard stands idle ‣ When he sees the player he begins approaching ‣ If the player breaks line of sight, he returns to his start position29
    157. 157. A Simple Guard30
    158. 158. A Simple Guard • Demo 430
    159. 159. Non-Boolean Transitions31
    160. 160. Non-Boolean Transitions • We can track non-boolean values and use these as triggers for state transitions31
    161. 161. Non-Boolean Transitions • We can track non-boolean values and use these as triggers for state transitions • Just need to meet a boolean criteria e.g. X > 10031
    162. 162. Suspicious Guard32
    163. 163. Suspicious Guard • This time, the guard will grow suspicious the longer the player stays in view.32
    164. 164. Suspicious Guard • This time, the guard will grow suspicious the longer the player stays in view. ‣ When suspicion hits a threshold, the guard will investigate32
    165. 165. Suspicious Guard • This time, the guard will grow suspicious the longer the player stays in view. ‣ When suspicion hits a threshold, the guard will investigate ‣ If the player breaks line of sight, guards suspicion begins to lower, continues to investigate32
    166. 166. Suspicious Guard • This time, the guard will grow suspicious the longer the player stays in view. ‣ When suspicion hits a threshold, the guard will investigate ‣ If the player breaks line of sight, guards suspicion begins to lower, continues to investigate ‣ When suspicion drops below a threshold, returns to start32
    167. 167. Suspicious Guard33
    168. 168. Suspicious Guard • Demo 533
    169. 169. Beyond FSMs34
    170. 170. Beyond FSMs • Finite State Machines are easy to understand34
    171. 171. Beyond FSMs • Finite State Machines are easy to understand • But they get complicated quickly34
    172. 172. Beyond FSMs • Finite State Machines are easy to understand • But they get complicated quickly ‣ Particularly for behaviours that need to have multiple components chained to them, and be interruptible34
    173. 173. Beyond FSMs • Finite State Machines are easy to understand • But they get complicated quickly ‣ Particularly for behaviours that need to have multiple components chained to them, and be interruptible • They aren’t state of the art, but good to introduce concepts34
    174. 174. Beyond FSMs • Finite State Machines are easy to understand • But they get complicated quickly ‣ Particularly for behaviours that need to have multiple components chained to them, and be interruptible • They aren’t state of the art, but good to introduce concepts • Not widely used in industry now.34
    175. 175. Hierarchical Concurrent State Machines35
    176. 176. Hierarchical Concurrent State Machines • Recent addition to the AI developers arsenal35
    177. 177. Hierarchical Concurrent State Machines • Recent addition to the AI developers arsenal • Popular after successful use in Left 4 Dead35
    178. 178. Hierarchical Concurrent State Machines • Recent addition to the AI developers arsenal • Popular after successful use in Left 4 Dead ‣ Drove NPCs35
    179. 179. Hierarchical Concurrent State Machines • Recent addition to the AI developers arsenal • Popular after successful use in Left 4 Dead ‣ Drove NPCs ‣ Also drove the AI Director system35
    180. 180. Hierarchical Concurrent State Machines • Recent addition to the AI developers arsenal • Popular after successful use in Left 4 Dead ‣ Drove NPCs ‣ Also drove the AI Director system • A real-time parallel redesign of the Finite State Machine (sort of)35
    181. 181. Hierarchical Concurrent State Machines36
    182. 182. Hierarchical Concurrent State Machines • Building block of an HCSM is itself an HCSM36
    183. 183. Hierarchical Concurrent State Machines • Building block of an HCSM is itself an HCSM ‣ Recursive by nature36
    184. 184. Hierarchical Concurrent State Machines • Building block of an HCSM is itself an HCSM ‣ Recursive by nature • Analogue input wire36
    185. 185. Hierarchical Concurrent State Machines • Building block of an HCSM is itself an HCSM ‣ Recursive by nature • Analogue input wire • Configuration parameters36
    186. 186. Hierarchical Concurrent State Machines • Building block of an HCSM is itself an HCSM ‣ Recursive by nature • Analogue input wire • Configuration parameters • Output wire36
    187. 187. Hierarchical Concurrent State Machines37
    188. 188. Behaviour Trees38
    189. 189. Behaviour Trees • Behaviour Trees are another great way of deciding which of a bunch of behaviours should be activated at a given time.38
    190. 190. Behaviour Trees • Behaviour Trees are another great way of deciding which of a bunch of behaviours should be activated at a given time. • Lets you craft intricate behaviours, and combine them relatively intelligently.38
    191. 191. Behaviour Trees • Behaviour Trees are another great way of deciding which of a bunch of behaviours should be activated at a given time. • Lets you craft intricate behaviours, and combine them relatively intelligently. • Kind of similar conceptually to a Decision Tree with an internal knowledge of what triggered last time38
    192. 192. Example Behaviour Tree “Introduction to Behaviour Trees”, Bjoern Knafla AltDevBlogADay.com39
    193. 193. Path Finding40
    194. 194. Path Finding • Being able to automatically work out how to move around a world is a common AI problem40
    195. 195. Path Finding • Being able to automatically work out how to move around a world is a common AI problem • Several good algorithms for doing this, today going to show A*40
    196. 196. Path Finding • Being able to automatically work out how to move around a world is a common AI problem • Several good algorithms for doing this, today going to show A* • Works by assessing40
    197. 197. Path Finding • Being able to automatically work out how to move around a world is a common AI problem • Several good algorithms for doing this, today going to show A* • Works by assessing ‣ Work done40
    198. 198. Path Finding • Being able to automatically work out how to move around a world is a common AI problem • Several good algorithms for doing this, today going to show A* • Works by assessing ‣ Work done ‣ Estimating work remaining (a heuristic)40
    199. 199. Path Finding • Being able to automatically work out how to move around a world is a common AI problem • Several good algorithms for doing this, today going to show A* • Works by assessing ‣ Work done ‣ Estimating work remaining (a heuristic) • Always selects most promising node40
    200. 200. Heuristic Example - A*41
    201. 201. Heuristic Example - A* B A42
    202. 202. Heuristic Example - A* B A43
    203. 203. Heuristic Example - A* B 1+7 A 1 +744
    204. 204. Heuristic Example - A* B 1+7 A 1 +745
    205. 205. Heuristic Example - A* B 2+6 1+7 A 2 + 8 1 +746
    206. 206. Heuristic Example - A* B 2+6 1+7 A 2 + 8 1 +747
    207. 207. Heuristic Example - A* B 3+5 2+6 1+7 A 2 + 8 1 +748
    208. 208. Heuristic Example - A* B 3+5 2+6 1+7 A 2 + 8 1 +749
    209. 209. Heuristic Example - A* 4+4 B 3+5 4+4 2+6 1+7 A 2 + 8 1 +750
    210. 210. Heuristic Example - A* 4+4 5+3 B 3+5 4+4 5+3 2+6 1+7 A 2 + 8 1 +751
    211. 211. Heuristic Example - A* 4+4 5+3 6+2 B 3+5 4+4 5+3 2+6 6+4 1+7 A 2 + 8 1 +752
    212. 212. Heuristic Example - A* 4+4 5+3 6+2 B 3+5 4+4 5+3 2+6 6+4 1+7 A 2 + 8 1 +753
    213. 213. Heuristic Example - A* 4+4 5+3 6+2 B 3+5 4+4 5+3 2+6 6+4 1+7 A 2 + 8 1 +7 2 + 654
    214. 214. Heuristic Example - A* 4+4 5+3 6+2 B 3+5 4+4 5+3 2+6 6+4 1+7 A 2 + 8 1 +7 2 + 655
    215. 215. Heuristic Example - A* 4+4 5+3 6+2 B 3+5 4+4 5+3 2+6 6+4 1+7 A 2 + 8 1 +7 2 + 6 3 + 556
    216. 216. Heuristic Example - A* 4+4 5+3 6+2 B 3+5 4+4 5+3 2+6 6+4 1+7 A 4+4 2 + 8 1 +7 2 + 6 3 + 5 4 + 457
    217. 217. Heuristic Example - A* 4+4 5+3 6+2 B 3+5 4+4 5+3 2+6 6+4 1+7 A 4+4 2 + 8 1 +7 2 + 6 3 + 5 4 + 458
    218. 218. Heuristic Example - A* 4+4 5+3 6+2 B 3+5 4+4 5+3 2+6 6+4 5+3 1+7 A 4+4 5+3 2 + 8 1 +7 2 + 6 3 + 5 4 + 459
    219. 219. Heuristic Example - A* 4+4 5+3 6+2 B 3+5 4+4 5+3 2+6 6+4 5+3 1+7 A 4+4 5+3 2 + 8 1 +7 2 + 6 3 + 5 4 + 460
    220. 220. Heuristic Example - A* 4+4 5+3 6+2 B 3+5 4+4 5+3 2+6 6+4 5+3 6+2 1+7 A 4+4 5+3 2 + 8 1 +7 2 + 6 3 + 5 4 + 461
    221. 221. Heuristic Example - A* 4+4 5+3 6+2 B 3+5 4+4 5+3 2+6 6+4 5+3 6+2 1+7 A 4+4 5+3 2 + 8 1 +7 2 + 6 3 + 5 4 + 462
    222. 222. Heuristic Example - A* 4+4 5+3 6+2 B 3+5 4+4 5+3 7+1 2+6 6+4 5+3 6+2 1+7 A 4+4 5+3 2 + 8 1 +7 2 + 6 3 + 5 4 + 463
    223. 223. Heuristic Example - A* 4+4 5+3 6+2 B 3+5 4+4 5+3 7+1 2+6 6+4 5+3 6+2 1+7 A 4+4 5+3 2 + 8 1 +7 2 + 6 3 + 5 4 + 464
    224. 224. Heuristic Example - A* 4+4 5+3 6+2 B 3+5 4+4 5+3 7+1 2+6 6+4 5+3 6+2 1+7 A 4+4 5+3 2 + 8 1 +7 2 + 6 3 + 5 4 + 465
    225. 225. Heuristic Example - A* 4+4 5+3 6+2 B 3+5 4+4 5+3 7+1 2+6 6+4 5+3 6+2 1+7 A 4+4 5+3 2 + 8 1 +7 2 + 6 3 + 5 4 + 466
    226. 226. Pathfinding in Unity67
    227. 227. Pathfinding in Unity • Unity 3.5 now includes pathfinding natively67
    228. 228. Pathfinding in Unity • Unity 3.5 now includes pathfinding natively ‣ Pro only apparently67
    229. 229. Pathfinding in Unity • Unity 3.5 now includes pathfinding natively ‣ Pro only apparently • Not entirely sure how this is implemented67
    230. 230. Pathfinding in Unity • Unity 3.5 now includes pathfinding natively ‣ Pro only apparently • Not entirely sure how this is implemented ‣ I still haven’t bought Pro...67
    231. 231. Pathfinding in Unity • Unity 3.5 now includes pathfinding natively ‣ Pro only apparently • Not entirely sure how this is implemented ‣ I still haven’t bought Pro... • Possibly similar to the Path package (creator of that works at Unity)67
    232. 232. Path68
    233. 233. Path • Demo 668
    234. 234. Runtime Woes69
    235. 235. Runtime Woes • We’ve talked about pathfinding and decision making69
    236. 236. Runtime Woes • We’ve talked about pathfinding and decision making • These can be computationally hard problems69
    237. 237. Runtime Woes • We’ve talked about pathfinding and decision making • These can be computationally hard problems ‣ In general we want to shoot for around 60fps69
    238. 238. Runtime Woes • We’ve talked about pathfinding and decision making • These can be computationally hard problems ‣ In general we want to shoot for around 60fps ‣ 16.67ms of computation per frame69
    239. 239. Runtime Woes • We’ve talked about pathfinding and decision making • These can be computationally hard problems ‣ In general we want to shoot for around 60fps ‣ 16.67ms of computation per frame ‣ Most of that will go on non-AI aspects69
    240. 240. Runtime Woes • We’ve talked about pathfinding and decision making • These can be computationally hard problems ‣ In general we want to shoot for around 60fps ‣ 16.67ms of computation per frame ‣ Most of that will go on non-AI aspects • Realistically looking at 1 or 2ms per frame for all AI69
    241. 241. Runtime Woes • We’ve talked about pathfinding and decision making • These can be computationally hard problems ‣ In general we want to shoot for around 60fps ‣ 16.67ms of computation per frame ‣ Most of that will go on non-AI aspects • Realistically looking at 1 or 2ms per frame for all AI • Lots of computation, not a lot of time69
    242. 242. Breaking Problems Up70
    243. 243. Breaking Problems Up • So we know that we might want to do things take longer than we have.70
    244. 244. Breaking Problems Up • So we know that we might want to do things take longer than we have. • How can we break it up into manageable chunks so that we aren’t delaying the game thread?70
    245. 245. Breaking Problems Up • So we know that we might want to do things take longer than we have. • How can we break it up into manageable chunks so that we aren’t delaying the game thread? • In Unity, we have a very powerful system at our disposal called70
    246. 246. Breaking Problems Up • So we know that we might want to do things take longer than we have. • How can we break it up into manageable chunks so that we aren’t delaying the game thread? • In Unity, we have a very powerful system at our disposal called ‣ Coroutines70
    247. 247. Coroutines71
    248. 248. Coroutines • Coroutines are blocks of code that can return a value partway through execution.71
    249. 249. Coroutines • Coroutines are blocks of code that can return a value partway through execution. • Next time that routine is called, it will pick up where it left off71
    250. 250. Coroutines • Coroutines are blocks of code that can return a value partway through execution. • Next time that routine is called, it will pick up where it left off • Allows you to chop a block of code up into roughly frame-computable chunks.71
    251. 251. Coroutines • Coroutines are blocks of code that can return a value partway through execution. • Next time that routine is called, it will pick up where it left off • Allows you to chop a block of code up into roughly frame-computable chunks. ‣ Delays overall result, doesn’t delay code execution71
    252. 252. Juggling Timings72
    253. 253. Juggling Timings • Another great use of Coroutines is to get timing of things right.72
    254. 254. Juggling Timings • Another great use of Coroutines is to get timing of things right. - Lots of things in Unity are “delayed calls”72
    255. 255. Juggling Timings • Another great use of Coroutines is to get timing of things right. - Lots of things in Unity are “delayed calls” • They don’t actually happen til the end of the frame72
    256. 256. Juggling Timings • Another great use of Coroutines is to get timing of things right. - Lots of things in Unity are “delayed calls” • They don’t actually happen til the end of the frame - Destroy(), Debug.Log()72
    257. 257. Juggling Timings • Another great use of Coroutines is to get timing of things right. - Lots of things in Unity are “delayed calls” • They don’t actually happen til the end of the frame - Destroy(), Debug.Log() • We can do things like72
    258. 258. Juggling Timings • Another great use of Coroutines is to get timing of things right. - Lots of things in Unity are “delayed calls” • They don’t actually happen til the end of the frame - Destroy(), Debug.Log() • We can do things like yield return new WaitForEndOfFrame();72
    259. 259. Juggling Timings • Another great use of Coroutines is to get timing of things right. - Lots of things in Unity are “delayed calls” • They don’t actually happen til the end of the frame - Destroy(), Debug.Log() • We can do things like yield return new WaitForEndOfFrame(); • What we are waiting for happens, code resumes72
    260. 260. Coroutines in practice73
    261. 261. Coroutines in practice • Demo73
    262. 262. Summary74
    263. 263. Summary • Today we covered basics/fundamentals74
    264. 264. Summary • Today we covered basics/fundamentals ‣ What we’re trying to achieve with Game AI74
    265. 265. Summary • Today we covered basics/fundamentals ‣ What we’re trying to achieve with Game AI ‣ Some very simple implementations of behaviours74
    266. 266. Summary • Today we covered basics/fundamentals ‣ What we’re trying to achieve with Game AI ‣ Some very simple implementations of behaviours ‣ Simple methods for selecting which is active74
    267. 267. Summary • Today we covered basics/fundamentals ‣ What we’re trying to achieve with Game AI ‣ Some very simple implementations of behaviours ‣ Simple methods for selecting which is active ‣ Discussion of some more advanced methods74
    268. 268. Summary • Today we covered basics/fundamentals ‣ What we’re trying to achieve with Game AI ‣ Some very simple implementations of behaviours ‣ Simple methods for selecting which is active ‣ Discussion of some more advanced methods ‣ Intro to Pathfinding74
    269. 269. Summary • Today we covered basics/fundamentals ‣ What we’re trying to achieve with Game AI ‣ Some very simple implementations of behaviours ‣ Simple methods for selecting which is active ‣ Discussion of some more advanced methods ‣ Intro to Pathfinding ‣ Coroutines for AI74
    270. 270. Takeaways75
    271. 271. Takeaways 1. AI is awesome75
    272. 272. Takeaways 1. AI is awesome 2. AI is complicated75
    273. 273. Takeaways 1. AI is awesome 2. AI is complicated 3. AI doesn’t need to be scary75
    274. 274. But Wait There’s More!76
    275. 275. But Wait There’s More! • We haven’t scratched the surface of what we can do with AI.76
    276. 276. But Wait There’s More! • We haven’t scratched the surface of what we can do with AI. ‣ AI for companions76
    277. 277. But Wait There’s More! • We haven’t scratched the surface of what we can do with AI. ‣ AI for companions ‣ AI for squad behaviours & coordination of multiple NPCs76
    278. 278. But Wait There’s More! • We haven’t scratched the surface of what we can do with AI. ‣ AI for companions ‣ AI for squad behaviours & coordination of multiple NPCs ‣ AI for scenario control (e.g. Left 4 Dead)76
    279. 279. But Wait There’s More! • We haven’t scratched the surface of what we can do with AI. ‣ AI for companions ‣ AI for squad behaviours & coordination of multiple NPCs ‣ AI for scenario control (e.g. Left 4 Dead) ‣ AI for content generation76
    280. 280. Contact • luke@cis.strath.ac.uk • @LukeD • http://saig.cis.strath.ac.uk - Research Group • http://lukedicken.com - Personal Site Questions?77
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×