artificial intelligence (and stupidity) in computer games

118
Artificial Intelligence ( and Stupidity ) in the Computer Game Industry Lars Lidén [email protected] 2001

Upload: lars-liden

Post on 10-Apr-2015

115 views

Category:

Documents


5 download

DESCRIPTION

An overview of some of the techniques used to control computer characters in 3D 1st person games.

TRANSCRIPT

Page 1: Artificial Intelligence (and Stupidity) in Computer Games

Artificial Intelligence ( and Stupidity )

in the Computer Game Industry

Lars Lidé[email protected]

2001

Artificial Intelligence ( and Stupidity )

in the Computer Game Industry

Lars Lidé[email protected]

2001

Page 2: Artificial Intelligence (and Stupidity) in Computer Games

ValveValveSeattle, WA (2000)

Presto StudiosPresto Studios San Diego, CA (1998)

Page 3: Artificial Intelligence (and Stupidity) in Computer Games

IntroductionIntroduction

• The term A.I. is used broadly in computer game industry

• Games come in many genres and the techniques employed by the different genres vary widely

• Will be discussing A.I. for non-player characters (NPCs) in a first-person or third-person shooter

• Fully rendered 3D environment• Player controls a single character

Page 4: Artificial Intelligence (and Stupidity) in Computer Games

IntroductionIntroduction

Won’t be discussing use of AI for:

• Board games (Chess, Go)• Strategy games (Civilization / Age of Empires)• Camera control in 3D games• Simulation games (The Sims, Sim City)• Racing games

Page 5: Artificial Intelligence (and Stupidity) in Computer Games

Example:

Half-Life 2

Example:

Half-Life 2

Page 6: Artificial Intelligence (and Stupidity) in Computer Games
Page 7: Artificial Intelligence (and Stupidity) in Computer Games

Components of an AI SystemDecision MakingTactical AnalysisArtificial Stupidity

Components of an AI SystemDecision MakingTactical AnalysisArtificial Stupidity

Page 8: Artificial Intelligence (and Stupidity) in Computer Games

Components of an AI Components of an AI SystemSystemDecision MakingTactical AnalysisArtificial Stupidity

Components of an AI Components of an AI SystemSystemDecision MakingTactical AnalysisArtificial Stupidity

Page 9: Artificial Intelligence (and Stupidity) in Computer Games

Components of an AI SystemComponents of an AI System

AnimationAnimation

MovementMovement

BehaviorBehavior

Page 10: Artificial Intelligence (and Stupidity) in Computer Games

Components of an AI SystemComponents of an AI System

AnimationAnimation

Responsible for controlling NPC bodyResponsible for controlling NPC body

• MovementMovement

• BehaviorBehavior

Page 11: Artificial Intelligence (and Stupidity) in Computer Games

AI Components: AnimationAI Components: Animation

• Animation Selection

• Parameterize Animation

• Selected Joint Control

• Inverse Kinematics

Page 12: Artificial Intelligence (and Stupidity) in Computer Games

AI Components: AnimationAI Components: Animation

• NPC models built by artistsUse tools such as “3D Studio Max” or “Maya”

• Models are constructed from bones

• Bones are connected by articulated joints

• The skeletal system is covered by a mesh of textured polygons

Page 13: Artificial Intelligence (and Stupidity) in Computer Games

AI Components: AnimationAI Components: Animation

Example:Example:

Page 14: Artificial Intelligence (and Stupidity) in Computer Games

Texturing and Lighting a Mesh

Texturing and Lighting a Mesh

Page 15: Artificial Intelligence (and Stupidity) in Computer Games

Bones and ArticulatorsBones and Articulators

Page 16: Artificial Intelligence (and Stupidity) in Computer Games

AI Components: AnimationAI Components: Animation

Animation sequences are generated by defining how Animation sequences are generated by defining how joints should articulate through timejoints should articulate through time

Walking sequence:Walking sequence:

Page 17: Artificial Intelligence (and Stupidity) in Computer Games

AI Components: AnimationAI Components: Animation

Animation sequences for a model are either:Animation sequences for a model are either:

• Hand generated by a computer animatorHand generated by a computer animator

• Recorded from real human (or animal) movements Recorded from real human (or animal) movements and applied to a skeletal system (“motion capture”)and applied to a skeletal system (“motion capture”)

Page 18: Artificial Intelligence (and Stupidity) in Computer Games

AI Components: AnimationAI Components: Animation

Motion Capture:Motion Capture:

Page 19: Artificial Intelligence (and Stupidity) in Computer Games

Tom Molet (EGCAS ’96)

Page 20: Artificial Intelligence (and Stupidity) in Computer Games
Page 21: Artificial Intelligence (and Stupidity) in Computer Games

AI Components: AnimationAI Components: Animation

Animation sequences tend to be:Animation sequences tend to be:

Motion primitives:Motion primitives:• Run, Walk, Jump, Side-step, ClimbRun, Walk, Jump, Side-step, Climb

Transitions Transitions • Start_Walk, Run_To_Jump, Jump_LandStart_Walk, Run_To_Jump, Jump_Land

Page 22: Artificial Intelligence (and Stupidity) in Computer Games

AI Components: AnimationAI Components: Animation

Some animation sequences only take control of Some animation sequences only take control of part of the body:part of the body:

• wave_hellowave_hello• hand_signal_stophand_signal_stop• swing_ice_axeswing_ice_axe

Page 23: Artificial Intelligence (and Stupidity) in Computer Games

AI Components: AnimationAI Components: Animation

First step in A.I. Is to select which animation First step in A.I. Is to select which animation sequence or sequences should be applied to a sequence or sequences should be applied to a modelmodel

Many influences:Many influences:• Desired behavior chosen by decision systemDesired behavior chosen by decision system• What animation is currently playingWhat animation is currently playing• The current velocity and direction of the NPCThe current velocity and direction of the NPC• The terrain the NPC is standing onThe terrain the NPC is standing on

Page 24: Artificial Intelligence (and Stupidity) in Computer Games

AI Components: AnimationAI Components: Animation

Second step is to parameterize animationsSecond step is to parameterize animationsSpeed up or slow down animationSpeed up or slow down animation

• Slow walk, fast walkSlow walk, fast walk• Accelerate / decelerate stop and start of runAccelerate / decelerate stop and start of run• Slow run as approach sharp turnSlow run as approach sharp turn

Blend between animationsBlend between animations• walk-to-runwalk-to-run• 70% normal walk + 30% limp70% normal walk + 30% limp

Layer animationsLayer animations• Mix Mix hand_wavehand_wave on top of on top of walk animationwalk animation

Page 25: Artificial Intelligence (and Stupidity) in Computer Games

AI Components: AnimationAI Components: Animation

Next might add selected Joint ControlNext might add selected Joint Control

Take control of particular jointsTake control of particular joints• Either:Either:

• Ignore joint motion in pre-generated animationIgnore joint motion in pre-generated animation• Blend with pre-generated joint motionBlend with pre-generated joint motion

Used for:Used for:• Head TurningHead Turning

• Looking at a particular object or locationLooking at a particular object or location• Arm aimingArm aiming

• Point gun at a locationPoint gun at a location

Page 26: Artificial Intelligence (and Stupidity) in Computer Games

AI Components: AnimationAI Components: Animation

And finally, add inverse kinematicsAnd finally, add inverse kinematics

• Algorithmically determine the joint configuration Algorithmically determine the joint configuration required for an end-effecter (hand or foot) to reach a required for an end-effecter (hand or foot) to reach a particular locationparticular location

• Used for:Used for:• Keep the feet on the ground on uneven terrain or when Keep the feet on the ground on uneven terrain or when

walking up stairswalking up stairs• Reaching hand out to open a door, pick up and objectReaching hand out to open a door, pick up and object

Page 27: Artificial Intelligence (and Stupidity) in Computer Games

AI Components: AnimationAI Components: Animation

• Animation SelectionAnimation Selection

• Parameterization of AnimationsParameterization of Animations

• Selected Joint ControlSelected Joint Control

• Inverse KinematicsInverse Kinematics

Page 28: Artificial Intelligence (and Stupidity) in Computer Games

Components of an AI SystemComponents of an AI System

• AnimationAnimation

Responsible for controlling NPC bodyResponsible for controlling NPC body

MovementMovement

Responsible for controlling NPC movementResponsible for controlling NPC movement

• BehaviorBehavior

Page 29: Artificial Intelligence (and Stupidity) in Computer Games

Movement: PathfindingMovement: Pathfinding• The primary component of a movement system is

pathfinding.

• Find a route for an NPC to travel from one location in the world to another.

• Route depends on:• NPC’s size

• Will NPC’s body fit in a given location?

• NPC’s navigation ability• Walk, Jump, Climb, Swim

Page 30: Artificial Intelligence (and Stupidity) in Computer Games

Movement: Pathfinding ToolsMovement: Pathfinding Tools• Waypoint

• Position in a map that is used for navigation• Usually placed in world manually by a level designer

• Link• Connection between two waypoints• Often annotated with the required navigation type (Jump, Swim, Climb)• For a given NPC, two waypoints are linked when:

• The NPC has room enough to move from one node to another without colliding with the world geometry

• The NPC has the required navigation ability

• Node Graph• Data structure holding all waypoints and links• Either generated manually by a level designer or automatically by the

computer and annotated by a level designer

Page 31: Artificial Intelligence (and Stupidity) in Computer Games

Movement: Node GraphMovement: Node Graph

Page 32: Artificial Intelligence (and Stupidity) in Computer Games

Movement: Route GenerationMovement: Route Generation• A*A* is the preferred pathfinding algorithm for quickly

finding a short path between two waypoints

• Often modified for other route types:• Fastest Route

Shortest route is not often the fastest as it may take an NPC longer to climb a ladder or swim between two waypoints than to run or walk

• Safest RouteFor tactical reasons an NPC may choose to prefer a longer less exposed route than a shorter or faster route with no cover

Page 33: Artificial Intelligence (and Stupidity) in Computer Games

Components of an AI SystemComponents of an AI System

• AnimationAnimation

Responsible for controlling NPC bodyResponsible for controlling NPC body

• MovementMovement

Responsible for controlling NPC movementResponsible for controlling NPC movement

BehaviorBehavior

Responsible for controlling NPC decision makingResponsible for controlling NPC decision making

Page 34: Artificial Intelligence (and Stupidity) in Computer Games

AI Components: BehaviorAI Components: Behavior

Responsible for deciding what behavior an NPC should express

Each NPC has a think cycle:1. Sense Environment2. Select Behavior3. Express behavior

Page 35: Artificial Intelligence (and Stupidity) in Computer Games

AI Components: BehaviorAI Components: Behavior

1. Sense Environment• What to I see?• What can I hear / smell?• Includes internal states:

• How tired am I?• What’s my health?

2. Select Behavior• Finite State Machine• Decision Tree

3. Express Behavior• Select appropriate animation sequences

Page 36: Artificial Intelligence (and Stupidity) in Computer Games

Components of an AI SystemDecision MakingDecision MakingTactical AnalysisArtificial Stupidity

Components of an AI SystemDecision MakingDecision MakingTactical AnalysisArtificial Stupidity

Page 37: Artificial Intelligence (and Stupidity) in Computer Games

Decision Making:Decision Making:Decision Making:Decision Making:

• Module that does behavior selection

• Example of one such system

• OverviewMany of the details and features have been omitted

Page 38: Artificial Intelligence (and Stupidity) in Computer Games

Decision MakingDecision Making:Decision MakingDecision Making:

System consists of three types of objects:System consists of three types of objects:

1.1. TasksTasks

2.2. SchedulesSchedules

3.3. ConditionsConditions

Page 39: Artificial Intelligence (and Stupidity) in Computer Games

Decision MakingDecision Making:Decision MakingDecision Making:

TASKSTASKS

Simple things for a NPC to do, such as:• Turn to face a location or an object

(TASK_FACE_FRIEND)

• Find a path to a location (TASK_FIND_PATH_TO_ENEMY)

• Move along a path(TASK_WALK_PATH)

• Stop moving(TASK_STOP_MOVING)

Page 40: Artificial Intelligence (and Stupidity) in Computer Games

Decision MakingDecision Making:Decision MakingDecision Making:

Tasks can take arguments:

• Wait for a while(TASK_WAIT) < Time to wait >

• Play a particular animation(TASK_PLAY_ANIMATION) < Animation Name >

• Say Something(TASK_SAY_PHRASE) < Phrase >

Page 41: Artificial Intelligence (and Stupidity) in Computer Games

Decision MakingDecision Making:Decision MakingDecision Making:

SCHEDULESSCHEDULES

• Named lists of tasks

• Selected by logic system

• Performed by NPC until:• All tasks have finished• One task has failed• Schedule has been Interrupted

Page 42: Artificial Intelligence (and Stupidity) in Computer Games

Decision MakingDecision Making:Decision MakingDecision Making:

Examples:

• SCHEDULE_GET_WEAPONTASK_FIND_WEAPON

TASK_FIND_PATH

TASK_RUN_PATH

TASK_PICKUP_WEAPON

• SCHEDULE_FLANK_ATTACKTASK_FIND_FLANK_POSITION

TASK_FIND_PATH

TASK_RUN_PATH

TASK_RANGE_ATTACK

Page 43: Artificial Intelligence (and Stupidity) in Computer Games

Decision Making:Decision Making:Decision Making:Decision Making:

CONDITONSCONDITONS

Predicates that are set every time an NPC thinks

Conditions serve two purposes:

1. Schedule Selection

2. Schedule Interruption

Page 44: Artificial Intelligence (and Stupidity) in Computer Games

Decision Making:Decision Making:Decision Making:Decision Making:

Examples:

• See an enemy (CONDITON_SEE_ENEMY)

• Hear danger (CONDITON_HEAR_DANGER)

• Took heavy damage(CONDITION_HEAVY_DAMAGE)

• Enemy blocked by something(CONDITION_ENEMY_OCCLUDED)

Page 45: Artificial Intelligence (and Stupidity) in Computer Games

Decision Making: Decision Making: ConditionsDecision Making: Decision Making: Conditions

Schedule selection is rule based:

• If (CONDITION_HEAR_DANGER) and not (CONDITION_HAVE_WEAPON) select schedule (SCHEDULE_GET_WEAPON)

• If (CONDITION_HAVE_WEAPON) and (CONDITION_OUT_OF_AMMO) select schedule (SCHEDULE_RELOAD_WEAPON)

Page 46: Artificial Intelligence (and Stupidity) in Computer Games

Decision Making: Decision Making: ConditionsDecision Making: Decision Making: Conditions

Interrupt conditions

• Schedules also contain interrupt conditions

• Same set of predicates used for schedule selection

• If interrupt condition is listed in the schedule, and the condition is true, the schedule will be interrupted

Page 47: Artificial Intelligence (and Stupidity) in Computer Games

Decision Making: Decision Making: ConditionsDecision Making: Decision Making: Conditions

Example:

• SCHEDULE_GET_WEAPONTASK_FIND_WEAPONTASK_FIND_PATHTASK_RUN_PATHTASK_PICKUP_WEAPON

CONDITION_HEAVY_DAMAGECONDITION_ENEMY_DEAD

Page 48: Artificial Intelligence (and Stupidity) in Computer Games

Decision Making: Decision Making: ConditionsDecision Making: Decision Making: Conditions

Task Failure

• Sometimes a task can’t be competed

• For example:• (TASK_FIND_WEAPON) when no weapon available• (TASK_FIND_PATH) when no way to get to destination

• In such cases the schedule will exit pre-maturely

Page 49: Artificial Intelligence (and Stupidity) in Computer Games

Decision Making: Decision Making: ConditionsDecision Making: Decision Making: Conditions

Fail Schedules:• Can specify a fail schedule:

SCHEDULE_GET_WEAPONTASK_SET_FAIL_SCHEDULE SCHEDULE_TAKE_COVERTASK_FIND_WEAPONTASK_FIND_PATHTASK_RUN_PATHTASK_PICKUP_WEAPON

• Take cover schedule chosen when any of the tasks fail

Page 50: Artificial Intelligence (and Stupidity) in Computer Games

Decision Making:Decision Making:Decision Making:Decision Making:

NPC Think Cycle:

• Update predicate values (conditions)

• If any conditions interrupt the current schedule, select a new schedule

• Perform next task in schedule list

• If task fails, go to fail schedule (if defined) or select a new schedule

• If all tasks have been completed, select a new schedule

Page 51: Artificial Intelligence (and Stupidity) in Computer Games

Components of an AI SystemDecision MakingTactical AnalysisArtificial Stupidity

Components of an AI SystemDecision MakingTactical AnalysisArtificial Stupidity

Page 52: Artificial Intelligence (and Stupidity) in Computer Games

Tactical AnalysisTactical Analysis

• Level designers place waypoints in the environment for navigation

• Node graph contains node connectivity information for a map

• Waypoints can also be evaluated for their visibility

• Information can be used to make tactical decisions

Page 53: Artificial Intelligence (and Stupidity) in Computer Games

Waypoint Analysis Waypoint Analysis

A World With 6 Nodes and 2 Enemies

Page 54: Artificial Intelligence (and Stupidity) in Computer Games

Waypoint Analysis Waypoint Analysis

• Limited CPU time• Decisions must be made quickly (as few CPU

cycles as possible)• Data must stored efficiently• Store visibility data in a “bit-string” class

= visibility from node “a”aV

Page 55: Artificial Intelligence (and Stupidity) in Computer Games

Waypoint Analysis Waypoint Analysis

Visibility Matrix

Page 56: Artificial Intelligence (and Stupidity) in Computer Games

Waypoint AnalysisWaypoint Analysis

Danger Nodes• Determined by “OR”ing the

visibility of all enemy’s (k) nearest nodes

Safe Nodes• Is its inverse

kj

jjVV

0

V

Page 57: Artificial Intelligence (and Stupidity) in Computer Games

Waypoint Analysis Waypoint Analysis

Safe and Dangerous Nodes

Page 58: Artificial Intelligence (and Stupidity) in Computer Games

Waypoint AnalysisWaypoint Analysis

Safe and Dangerous Nodes

Page 59: Artificial Intelligence (and Stupidity) in Computer Games

Finding a Safe Attack PositionFinding a Safe Attack Position

While attacking a selected enemy, an NPC shouldn’t expose itself to other enemies

A good attack position will:• Provide line-of-site (LOS) to the selected enemy• Provide cover from all other enemies

Page 60: Artificial Intelligence (and Stupidity) in Computer Games

Finding a Safe Attack PositionFinding a Safe Attack Position

To find such locations, first find all nodes which have LOS to the selected enemy

Call selected enemy “a”

aV

Page 61: Artificial Intelligence (and Stupidity) in Computer Games

Finding a Safe Attack Position Finding a Safe Attack Position

Nodes are visible to selectedselected enemy

Page 62: Artificial Intelligence (and Stupidity) in Computer Games

Finding a Safe Attack PositionFinding a Safe Attack Position

Next determine the set of nodes that are visible to all other enemies

ajVVkj

jja

,0

Page 63: Artificial Intelligence (and Stupidity) in Computer Games

Finding a Safe Attack Position Finding a Safe Attack Position

Nodes are visible to otherother enemies

Page 64: Artificial Intelligence (and Stupidity) in Computer Games

Finding a Safe Attack PositionFinding a Safe Attack Position

The set of good attack positions is the set of nodes with LOS to the enemy intersected with the inverse of the set of nodes with LOS to all other enemies

aaa VVV '

Page 65: Artificial Intelligence (and Stupidity) in Computer Games

Finding a Safe Attack Position Finding a Safe Attack Position

Safe nodes to shoot from

Page 66: Artificial Intelligence (and Stupidity) in Computer Games

Static Waypoint EvaluationStatic Waypoint Evaluation

• Unless cheating is employed, NPCs don’t have full knowledge of the world.

• May not know where all their enemies are located

• Find a good location to wait in for attack

• Not all positions are created equal

Page 67: Artificial Intelligence (and Stupidity) in Computer Games

Static Waypoint EvaluationStatic Waypoint Evaluation

To find a good set up position:

• Establish the exposure of all waypoints in a map

• Process can be done off line, before game is even started

Page 68: Artificial Intelligence (and Stupidity) in Computer Games

Static Waypoint Evaluation Static Waypoint Evaluation

Evaluate Each Node For Visibility

Page 69: Artificial Intelligence (and Stupidity) in Computer Games

Static Waypoint EvaluationStatic Waypoint Evaluation

A good location is one which:

1. Has high exposure (visibility)• Easy to locate enemies• Easy to establish LOS to attack and enemy

2. Has areas of low exposure nearby• Can hide easily• Can run for cover easily

Page 70: Artificial Intelligence (and Stupidity) in Computer Games

Static Waypoint Evaluation Static Waypoint Evaluation

Good “Sniping” Positions

Page 71: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

Observation of human players reveals that experienced players anticipate the actions of their opponents (Laird 2000)

For example, if an enemy enters a room with only a single exit an experienced player will wait just outside the exit setting up an ambush

Such “pinch points” can be pre-calculated by analyzing the node graph

Page 72: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

To find pinch points:

For each node, N in the node graph with only two neighbors:Temporarily eliminate node, N, from the graph, call its neighbors as A & B.If both A & B are connected to large regions, N is not a pinch point, try another N.Attempt to find a path between A& B.If path exists, N is not a pinch point, try another N. Call the node connected to the larger region, O (for outside).Call the node connected to the smaller region, I (for inside).

Let’s do that again step-by-step:

Page 73: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

• For each node, N in the node graph with only two neighbors:

Page 74: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

• Temporarily eliminate node, N, from the graph, call its neighbors as A & B.

Page 75: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

• If both A & B are connected to large regions, N is not a pinch point, try another N.

Page 76: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

• Attempt to find a path between A& B, if exists try another N.

Page 77: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

• Call the node connected to the larger region, O (for outside).• Call the node connected to the smaller region, I (for inside).

Page 78: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

Once a pinch point has been located a good ambush location is one which:

• Has a line of site to the waypoint outside the pinch location “O”

• Can’t be seen from the pinch location “N”

Page 79: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

• Nodes that have a line of site to pinch location “O”

• Can’t be seen from the pinch location “N”

• Good ambush locations is their intersection:

OV

NV

NOP VVV

Page 80: Artificial Intelligence (and Stupidity) in Computer Games

Pinch Points Pinch Points

Pinch Point

I = Inside Node

N = Pinch Point

0 = Outside Node

Page 81: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

Another Example:

Page 82: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

Result:

Page 83: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch PointsSlightly altered version to find pinch points at the end of

hallways:

For each node, N in the node graph with only two neighbors:• Temporarily eliminate node, N, from the graph, call its neighbors as A & B.• If both A & B are connected to large regions, N is not a pinch point, try another N.• If O’s neighbor has only one other neighbor in addition to N.

• Move N to O.• Move O to the other neighbor of the old O• Repeat until O has only one neighbor.

• Attempt to find a path between A& B.• If path exists, N is not a pinch point, try another N. • Call the node connected to the larger region, O (for outside).• Call the node connected to the smaller region, I (for inside).

Page 84: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

• If O’s neighbor only has one other neighbor in addition to N

Page 85: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

• Move N to O, Move O to other neighbor of old O• Repeat till O has only one neighbor

Page 86: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

• Move N to O, Move O to other neighbor of old O• Repeat till O has only one neighbor

Page 87: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

• Calculate good ambush locations:

NOP VVV

Page 88: Artificial Intelligence (and Stupidity) in Computer Games

Pinch Points Pinch Points

Hall Pinch

I = Inside Node

N = Pinch Point

0 = Outside Node

Page 89: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

Final Example:

Page 90: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

• For each node, N in the node graph with only two neighbors

Page 91: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

• Attempt to find a path between A& B.• If path exists, N is not a pinch point, try another N

Page 92: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

If NPCs organize into squads regions with multiple pinch points can be employed:

For each node, N1 in the node graph with only two neighbors:• Temporarily eliminate node, N1, from the graph, call its neighbors as A & B.

• If A & B are connected to large regions, N1 is not a pinch point, try another N1

• Attempt to find a path between A& B.• While generating the path if a node with only two neighbors is found,

• Temporarily eliminate it and call it N2.

• Attempt to find a path between A& B.• If path exists, not a pinch point, try another N1

• Call the nodes connected to the smaller regions, I1 and I2 (for inside).

• Call the nodes connected to the larger regions, O1 and O2 (for outside).

Page 93: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

• While generating the path if a node with only two neighbors is found• Temporarily eliminate it and call it N2

Page 94: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

• Attempt to find a path between A & B• If path exists N1 is not a pinch point, try another N1

Page 95: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

• Call the nodes connected to the smaller regions, I1 and I2 (for inside).

• Call the nodes connected to the larger regions, O1 and O2 (for outside).

Page 96: Artificial Intelligence (and Stupidity) in Computer Games

Pinch PointsPinch Points

• Calculate good ambush locations:

2111 NNOP VVVV

2122 NNOP VVVV

Page 97: Artificial Intelligence (and Stupidity) in Computer Games

Pinch Points Pinch Points

Double Pinch

I = Inside Node

N = Pinch Point

0 = Outside Node

Page 98: Artificial Intelligence (and Stupidity) in Computer Games

Tactical Analysis: ReviewTactical Analysis: Review

Using the node graph to evaluate map locations:

• Finding safe and dangerous locations

• Finding places from which to attack

• Finding location to set up sniper positions

• Finding pinch points

Page 99: Artificial Intelligence (and Stupidity) in Computer Games

Components of an AI SystemDecision MakingTactical AnalysisArtificial StupidityArtificial Stupidity

Components of an AI SystemDecision MakingTactical AnalysisArtificial StupidityArtificial Stupidity

Page 100: Artificial Intelligence (and Stupidity) in Computer Games

ARTIFICIAL STUPIDITYARTIFICIAL STUPIDITYARTIFICIAL STUPIDITYARTIFICIAL STUPIDITY

When NPCs Should Make Mistakes

Page 101: Artificial Intelligence (and Stupidity) in Computer Games

Intelligence != FunIntelligence != Fun

• What makes a game entertaining and fun does not necessarily correspond to making characters smarter

• The player is, after all, supposed to win

• 11 Ways to be stupid

Page 102: Artificial Intelligence (and Stupidity) in Computer Games

1. Don’t Cheat1. Don’t Cheat

• Sounds easy, but many games “cheat” by making NPCs omniscient • Know where enemies are even without seeing them• Know where to find weapons or ammo

• Players usually eventually detect cheating or at least get the feeling that the NPC’s behavior seems somehow “unnatural”

Page 103: Artificial Intelligence (and Stupidity) in Computer Games

2. Always miss the player the first time2. Always miss the player the first time

• It’s not fun to suddenly and unexpectedly take damage

• Player may feel cheated, particularly if attacked with a weapon that kills the player or does a lot of damage

• By missing the player the first time, it gives the player a second to react and still keeps the tension high

Page 104: Artificial Intelligence (and Stupidity) in Computer Games

3. Have horrible aim (wide cone)3. Have horrible aim (wide cone)

• Having abundant gun fire in the air keeps the player on the move and the tension high

• However, the player is supposed to win• By giving NPC bad aim, one can have abundant

gun fire without being too hard on the player• “Half-Life” used a wide spread on NPC weapons

(as much at 40 degrees)

Page 105: Artificial Intelligence (and Stupidity) in Computer Games

4. Never shoot when first see the player4. Never shoot when first see the player

• When a player first walks into an area and is spotted by an enemy, the enemy should never attack right away

• A secondary activity, such as running for cover or finding a good shooting location is more desirable

• Gives player time to react

Page 106: Artificial Intelligence (and Stupidity) in Computer Games

5. Warn the Player 5. Warn the Player

• Before attacking the player, warn the player that you are about to do so• Make a sound (beep/click)• Play a quick animation• Say “Gotcha!”, “Take this”

• This is particularly important when attacking from behind

Page 107: Artificial Intelligence (and Stupidity) in Computer Games

6. Attack “kung-fu” style6. Attack “kung-fu” style

• Player is usually playing the role of “Rambo” (i.e. one man taking on an army)

• Although many NPCs may be in a position to attack the player, only a couple should do so at a time

• The remaining NPCs should look busy, reloading, changing positions, etc.

Page 108: Artificial Intelligence (and Stupidity) in Computer Games

7. Tell the player what you are doing7. Tell the player what you are doing

• Interpreting the actions of NPCs can often be subtle

• Complex behaviors are often missed by the player. (Lot’s of work for nothing)

• NPCs should tell the player what they are doing• “flanking!” “cover me!” “retreat!”

• Players with often intuit intelligence behavior that isn’t really there

Page 109: Artificial Intelligence (and Stupidity) in Computer Games

8. Intentionally be vulnerable8. Intentionally be vulnerable

• Players learn to capitalize on opponent’s weaknesses.• Rather than allowing the player to discover unintentional

weaknesses in the AI, vulnerability should be designed into an NPC’s behavior.• Stop moving before attacking• Pause and prepare weapon before attacking• Act surprised and slow to react when attacked from behind

• Planned vulnerability makes the characters seem more realistic

• Unintentional mistakes break the realism (seems like fighting a computer program)

Page 110: Artificial Intelligence (and Stupidity) in Computer Games

9. Don’t be perfect9. Don’t be perfect

• Human players make mistakes• When NPCs behave perfectly they seem

unnatural• If an NPC knows how to avoid trip mines, run

into then occasionally• When reloading, sometimes fumble with the gun

Page 111: Artificial Intelligence (and Stupidity) in Computer Games

10. Pull back last minute 10. Pull back last minute

Trick:• Push the player to the limit• Attack vigorously until the player is near death• Then pull back. Enemy becomes easier to kill• Makes player feel like they really accomplished

something

Page 112: Artificial Intelligence (and Stupidity) in Computer Games

11. React To Mistakes11. React To Mistakes

• Mistakes in AI are inevitable

• Unhandled, they make make the AI look dumb

• By recognizing mistakes and reacting to them intelligently they can be turned into features

Page 113: Artificial Intelligence (and Stupidity) in Computer Games

11. React To Mistakes11. React To Mistakes

• Example 1:• Occasionally when an NPC throws a grenade, it bounces off

of another object and lands back at the NPCs feet• (Note that the player occasionally makes this mistake too!)

• Looks dumb as the NPC blows himself up

• If the NPC reacts, however, the mistake turns into a feature:• NPC body and facial expression can show surprise, fear• NPC can say “Oh Shoot!” or “Doh!”

Page 114: Artificial Intelligence (and Stupidity) in Computer Games

11. React To Mistakes11. React To Mistakes

• Example 2:• Player throws a grenade at a group of NPCs. As they are

crowded together not all of them are able to find a path to get away

• Looks dumb if the NPCs that can’t get away, shuffle around trying to get out

• If we detect that the problem has arisen, can have the trapped NPC’s react• Crouch down and put hands over head

Page 115: Artificial Intelligence (and Stupidity) in Computer Games

Components of an AI SystemDecision MakingTactical AnalysisArtificial StupidityConclusions

Components of an AI SystemDecision MakingTactical AnalysisArtificial StupidityConclusions

Page 116: Artificial Intelligence (and Stupidity) in Computer Games

Some Unsolved Problems:Some Unsolved Problems:

Automatic generation of waypoints

• Currently waypoints placed by hand in levels by level designers

• Placement is time consuming

• Requires editing every time map is changed

• Error prone

• No reliable system for automatically placing waypoints

Page 117: Artificial Intelligence (and Stupidity) in Computer Games

Some Unsolved Problems:Some Unsolved Problems:

Generation of dynamic waypoints

• Pre-generated waypoints only work for static maps

• Can deal with some moving objects, by turning node connections on/off or re-testing connections in real-time

• Maps that are generated dynamically or maps that change significantly during run time are problematic

Page 118: Artificial Intelligence (and Stupidity) in Computer Games

Conclusions:Conclusions:

• In the computer game industry the term A.I. is used to cover a broad range of technologies including animation, movement, navigation and behavior.

• What is required to make a game entertaining does not always coincide with making the game’s characters “smarter”.

• It is world where the illusion of intelligence is far more important then actual intelligence