1 of 109

Artificial Intelligence (A.I.)

2 of 109

Pure AI

3 of 109

Game AI

4 of 109

Pure AI / Game AI

5 of 109

Pure AI

> “Pure” AI is a scientific discipline

  • Interested in creating a system as smart as possible

6 of 109

Pure AI

> “Pure” AI is a scientific discipline

  • Interested in creating a system as smart as possible
  • Optimal solution to real-world problems

7 of 109

Pure AI

> “Pure” AI is a scientific discipline

  • Interested in creating a system as smart as possible
  • Optimal solution to real-world problems
  • Neural Networks

8 of 109

Pure AI

> “Pure” AI is a scientific discipline

  • Interested in creating a system as smart as possible
  • Optimal solution to real-world problems
  • Neural Networks
  • Machine Learning

9 of 109

Pure AI

> “Pure” AI is a scientific discipline

  • Interested in creating a system as smart as possible
  • Optimal solution to real-world problems
  • Neural Networks
  • Machine Learning
  • Has application in infrastructure of games

10 of 109

Pure AI

> “Pure” AI is a scientific discipline

  • Interested in creating a system as smart as possible
  • Optimal solution to real-world problems
  • Neural Networks
  • Machine Learning
  • Has application in infrastructure of games
  • Adapting to Player Data

11 of 109

Game AI

> Game AI is a whole other thing

  • Create “realistic simulation” of intelligence

12 of 109

Game AI

> Game AI is a whole other thing

  • Create “realistic simulation” of intelligence
  • E.G. Believable characters

13 of 109

Game AI

> Game AI is a whole other thing

  • Create “realistic simulation” of intelligence
  • E.G. Believable characters
  • Enhance the player's experience

14 of 109

Game AI

> Game AI is a whole other thing

  • Create “realistic simulation” of intelligence
  • E.G. Believable characters
  • Enhance the player's experience
  • Finite State Machines ( FSM )

15 of 109

Game AI

> Game AI is a whole other thing

  • Create “realistic simulation” of intelligence
  • E.G. Believable characters
  • Enhance the player's experience
  • Finite State Machines ( FSM )
  • Behavior Trees ( B Trees )

16 of 109

Game AI

> Game AI is a whole other thing

  • Create “realistic simulation” of intelligence
  • E.G. Believable characters
  • Enhance the player's experience
  • Finite State Machines ( FSM )
  • Behavior Trees ( B Trees )
  • Makes the game fun

17 of 109

18 of 109

Pure AI vs Game AI

> Pure AI for an NPC would be to make it fight as effective as possible.

19 of 109

Pure AI vs Game AI

> Pure AI for an NPC would be to make it fight as effective as possible.

> Is that what we want to achieve?

20 of 109

Pure AI vs Game AI

> Pure AI for an NPC would be to make it fight as effective as possible.

> Is that what we want to achieve?

> Game AI aims to make immersive experience

- Represent a enemy character accurately

- Allow Player to “become” Batman

21 of 109

Pure AI vs Game AI

> Pure AI for an NPC would be to make it fight as effective as possible.

> Is that what we want to achieve?

> Game AI aims to make immersive experience

- Represent a enemy character accurately

- Allow Player to “become” Batman

>Entertainment, no problem solving

22 of 109

23 of 109

Automate Opponents

> Centuries of trying to play games with few players

-Mechanical Trunk claimed to be a chess player circ 1770

24 of 109

Automate Opponents

> Centuries of trying to play games with few players

-Mechanical Trunk claimed to be a chess player circ 1770

-First video game example - Pong 1972

25 of 109

Automate Opponents

> Centuries of trying to play games with few players

-Mechanical Trunk claimed to be a chess player circ 1770

-First video game example - Pong 1972

-Ongoing commercial interests - FPS “Bots” RTS “Skirmish”

26 of 109

Automate Opponents

> Emphasis on delivering a good player experience

  • Human-like rather than “good” AI
  • Sub-human in order to be beatable

27 of 109

Looking and Being Smart

> Two components to Game AI

28 of 109

Looking and Being Smart

> Two components to Game AI

  • Looking Smart

29 of 109

Looking and Being Smart

> Two components to Game AI

  • Looking Smart
  • Being Smart

30 of 109

Looking and Being Smart

> Two components to Game AI

  • Looking Smart
  • Being Smart

> Focus in this class is on “Being Smart”

31 of 109

Looking and Being Smart

> Two components to Game AI

  • Looking Smart
  • Being Smart

> Focus in this class is on “Being Smart”

> Looking Smart is more on an animation / art issues

  • Does the character “feel” intelligent

32 of 109

Looking and Being Smart

> Two components to Game AI

  • Looking Smart
  • Being Smart

> Focus in this class is on “Being Smart”

> Looking Smart is more on an animation / art issues

  • Does the character “feel” intelligent

> Good decision making still required to drive this

  • Be smart, then trigger equivalent “look smart”

33 of 109

Some AI Basics

34 of 109

What is AI?

> Any time a computer has to pick between two or more choices it can be said it is acting “intelligently”

35 of 109

What is AI?

> 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...

36 of 109

What is AI?

> 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 sophistication

37 of 109

Decision Making Theory

> Not going to get too bogged down today in the process

38 of 109

Decision Making Theory

> Not going to get too bogged down today in the process

> Science of decision can fill up multiple degree-level courses

39 of 109

Decision Making Theory

> Not going to get too bogged down today in the process

> Science of decision can fill up multiple degree-level courses

> Game Theory is a good starting point to learn more

40 of 109

Smart or Dumb?

> Partly ignoring decision making because of Game AI, it isn’t so important for intro level.

  • Making a decision is a good start

41 of 109

Smart or Dumb?

> Partly ignoring decision making because of 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

42 of 109

Smart or Dumb?

> Partly ignoring decision making because of 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

> Partly for rapid iteration

  • Make any decision, figure out how to make it better later

43 of 109

Agent-Based Systems

44 of 109

Agent-Based Systems

> Intelligent Agents are things within our problem that are going to be trying to act intelligently

45 of 109

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

46 of 109

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 environment

47 of 109

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

48 of 109

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 : E.G. Ray Cast (Tracing), Triggers, Colliders, Nodes

49 of 109

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 : E.G. Ray Cast (Tracing), Triggers, Colliders, Nodes
  • “Think” about what to do

50 of 109

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 : E.G. Ray Cast (Tracing), Triggers, Colliders, Nodes
  • “Think” about what to do
  • Turn “thinking” into actions within the environment

51 of 109

NPCs as Agents

> One of the core places we can apply “agent-based systems” in when thinking about NPCs

52 of 109

NPCs as Agents

> One of the core places we can apply “agent-based systems” in When thinking about NPCs

> Each NPC is an agent

  • In some situation we may have a “General” as the agent
  • Directing NPC’s around as it’s way of affecting the world
  • Hybrid systems

53 of 109

NPCs as Agents

> One of the core places we can apply “agent-based systems” in When thinking about NPCs

> Each NPC is an agent

  • In some situation we may have a “General” as the agent
  • Directing NPC’s around as it’s way of affecting the world
  • Hybrid systems

> In this Model

  • NPCs sense the world
  • Decide what to do, then do it

54 of 109

55 of 109

Representations

> Software Engineering buzzwords!

56 of 109

Representations

> Software Engineering buzzwords!

> Representation internal to one NPC or shared?

57 of 109

Representations

> Software Engineering buzzwords!

> Representation internal to one NPC or shared?

> Alien Hive-mind - All units know what one units knows

  • Communal blackboard!

58 of 109

Representations

> Software Engineering buzzwords!

> Representation internal to one NPC or shared?

> Alien Hive-mind - All units know what one units knows

  • Communal blackboard!

> Director - All knowing and makes decision on player situations

  • Selective info is passed to units

59 of 109

Representations

> Software Engineering buzzwords!

> Representation internal to one NPC or shared?

> Alien Hive-mind - All units know what one units knows

  • Communal blackboard!

> Director - All knowing and makes decision on player situations

  • Selective info is passed to units

60 of 109

Representations

> Software Engineering buzzwords!

> Representation internal to one NPC or shared?

> Alien Hive-mind - All units know what one units knows

  • Communal blackboard!

> Director - All knowing and makes decision on player situations

  • Selective info is passed to units

> Modern Squad - Communication between certain units

  • Message passing between units

61 of 109

Representations

> Software Engineering buzzwords!

> Representation internal to one NPC or shared?

> Alien Hive-mind - All units know what one units knows

  • Communal blackboard!

> Director - All knowing and makes decision on player situations

  • Selective info is passed to units

> Modern Squad - Communication between certain units

  • Message passing between units

> Medieval Guards - No Widespread communication

  • Pure-internal representation

62 of 109

AI Implementations

63 of 109

Automata Theory

> Automata Theory is the study of abstract machines and automata, as well as the computational problems that can be solved using them.

64 of 109

B-Tree

FSM

65 of 109

Finite State Machines (FSMs)

66 of 109

FSM

> Finite State Machine

  • Can have finite number of states

67 of 109

FSM

> Finite State Machine

  • Can have finite number of states
  • Mathematical model that can be in exactly one of any state at a given time

68 of 109

FSM

> Finite State Machine

  • Can have finite number of states
  • Mathematical model that can be in exactly one of any state at a given time
  • Used to model an execution flow

69 of 109

Execution Flow

> Modeling a flow of character movement

  • E.G. Unreal Character State Machine

70 of 109

Agent FSM

71 of 109

Complex FSMs

  • Can become a complex mess as it grows

72 of 109

Complex FSMs

  • Can become a complex mess as it grows
  • States need to have knowledge of what other states are

73 of 109

Complex FSMs

  • Can become a complex mess as it grows
  • States need to have knowledge of what other states are
  • Maintainability: can be rough to add or remove behaviors

74 of 109

Complex FSMs

  • Can become a complex mess as it grows
  • States need to have knowledge of what other states are
  • Maintainability: can be rough to add or remove behaviors
  • Scalability: becomes a nightmare as more states are added

75 of 109

Complex FSMs

  • Can become a complex mess as it grows
  • States need to have knowledge of what other states are
  • Maintainability: can be rough to add or remove behaviors
  • Scalability: becomes a nightmare as more states are added
  • Reusability: becomes tough through multiple projects

76 of 109

Complex FSMs

  • Can become a complex mess as it grows
  • States need to have knowledge of what other states are
  • Maintainability: can be rough to add or remove behaviors
  • Scalability: becomes a nightmare as more states are added
  • Reusability: becomes tough through multiple projects
  • Goal-Oriented: FSM is not goal based, hard to plan with goals in mind

77 of 109

Complex FSMs

  • Can become a complex mess as it grows
  • States need to have knowledge of what other states are
  • Maintainability: can be rough to add or remove behaviors
  • Scalability: becomes a nightmare as more states are added
  • Reusability: becomes tough through multiple projects
  • Goal-Oriented: FSM is not goal based, hard to plan with goals in mind
  • Parallelization: hard to implement in a FMS, cause conflicts and deadlocks

78 of 109

BEHAVIOR TREES (B-Trees)

79 of 109

Directed Acyclic Graphs (DAGs)

> Finite directed graph with no directed cycles.

  • Multiple parents
  • Sub trees
  • Modularization
  • Reusable
  • Complex Behaviors

80 of 109

B-Tree Traversal (tree search)

-Rootfirst

-Depth first order

-Traversal is a tick

-Tick is set via timer

-O(log n) proportional

time

81 of 109

Traversal Results or Return

>Execution of a node or sub behavior tree results in an return state, extends the time of a tick.

82 of 109

Traversal Results or Return

>Execution of a node or sub behavior tree results in an return state, extends the time of a tick

  • The node is ready to run before it is called,

83 of 109

Traversal Results or Return

>Execution of a node or sub behavior tree results in an return state, extends the time of a tick

  • The node is ready to run before it is called,
  • It finished with a success state,

84 of 109

Traversal Results or Return

>Execution of a node or sub behavior tree results in an return state, extends the time of a tick

  • The node is ready to run before it is called,
  • It finished with a success state,
  • The behavior has not finished running yet, and should be called on the next step

85 of 109

Traversal Results or Return

>Execution of a node or sub behavior tree results in an return state, extends the time of a tick

  • The node is ready to run before it is called,
  • It finished with a success state,
  • The behavior has not finished running yet, and should be called on the next step
  • It failed cleanly without side effects

86 of 109

Traversal Results or Return

>Execution of a node or sub behavior tree results in an return state, extends the time of a tick

  • The node is ready to run before it is called,
  • It finished with a success state,
  • The behavior has not finished running yet, and should be called on the next step
  • It failed cleanly without side effects
  • Or an error and has side effects to deal with

87 of 109

Traversal Semantics

  • Disregard states, acquire nodes

88 of 109

Traversal Semantics

-Inner Nodes only control

-Priority Selectors

89 of 109

Priority Selectors: check which child to run in priority order.

-Defined with a priority #

-Nodes needs to return a succeed in order for tree to keep moving

-Can override tree traversal in code

90 of 109

Traversal Semantics

-Inner Nodes only control

-Priority Selectors

-Sequence Selectors

91 of 109

Sequence Selector: Run child one after another.

-If child fails then sequence fails

-Nodes needs to return a succeed in order for tree to keep moving

-Without a reset the or explicit finish will return to last ran child

92 of 109

93 of 109

Traversal Semantics

-Inner Nodes only control

-Priority Selectors

-Sequence Selectors

-Loops

94 of 109

Loop: sequences but they loop around

-Loops when reaching their last child during their traversal instead of returning to its parent.

95 of 109

Traversal Semantics

-Inner Nodes only control

-Priority Selectors

-Sequence Selectors

-Loops

-Random Selectors

96 of 109

Random Selector: randomly select child node to visit

-Its soooo random!

97 of 109

Traversal Semantics

-Inner Nodes only control

-Priority Selectors

-Sequence Selectors

-Loops

-Random Selectors

-Concurrent

98 of 109

Concurrent: nodes visit all the children

-Must set a preset fail amount for concurrent to fail

-Children will be run in parallel

-Parallel options can be denied based on child failures

99 of 109

Traversal Semantics

-Inner Nodes only control

-Priority Selectors

-Sequence Selectors

-Loops

-Random Selectors

-Concurrent

-Decorator

100 of 109

Decorator: Only one child with special child rules

-Used with timers

-Special case statements

101 of 109

Traversal Semantics

-Inner Nodes only control

-Priority Selectors

-Sequence Selectors

-Loops

-Random Selectors

-Concurrent

-Decorator

102 of 109

Leaf Nodes

-Last Nodes to Visit

-Actions

103 of 109

-Basic Actor AI

104 of 109

Actions: Where the Action happens!

-Actor or game word state changes

-EG: switch weapon, run a sound, move to a position, look out for enemies

-Actor or game word state changes

-Run for one tick, one frame, or multiple ticks

-Based on returning of a fale, in progress or success return

105 of 109

Leaf Nodes

-Last Nodes to Visit

-Actions

-Conditions

106 of 109

Conditions: Check if a condition holds true

-A condition check will prevent child nodes form running

-Used to determine if a state has became invalid for actions

107 of 109

-Adding to AI Behavior

108 of 109

Goal Oriented Action Planning

  • Goal oriented action planning (GOAP) is an artificial intelligence system for agents that allows them to plan a sequence of actions to satisfy a particular goal. The particular sequence of actions depends not only on the goal but also on the current state of the world and the agent. This means that if the same goal is supplied for different agents or world states, you can get a completely different sequence of actions., which makes the AI more dynamic and realistic.
  • https://gamedevelopment.tutsplus.com/tutorials/goal-oriented-action-planning-for-a-smarter-ai--cms-20793

109 of 109