/
Individual NPC Behavior Individual NPC Behavior

Individual NPC Behavior - PowerPoint Presentation

alida-meadow
alida-meadow . @alida-meadow
Follow
407 views
Uploaded On 2015-12-05

Individual NPC Behavior - PPT Presentation

Daniel Phang amp Sui Ying Teoh NPC NonPlayer Character Primary application of AI in games Any character not controlled by player Mobs Monsters Enemies Allies Noncombat or neutral units Environment animals ID: 215446

npc npcs player behavior npcs npc behavior player reputation body actions human priority guards animation specific system event objects

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Individual NPC Behavior" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Individual NPC Behavior

Daniel Phang & Sui Ying TeohSlide2

NPC - Non-Player Character

Primary application of AI in games

Any character not controlled by player

Mobs, Monsters, Enemies

Allies

Noncombat or neutral units

Environment animals

Function to create an immersive gaming experience for the playerSlide3

Overview

NPC Behavior

Coordinated Behavior

Human-like NPCs

Reputation Systems

Animating NPCsSlide4

NPC BehaviorSlide5

What is NPC Behavior?

Actions NPCs perform (in-game behavior)

Movement

Environmental interactions

Combat

Responses to game events

Querying and storing information

Later: animations

Movement: limb and body animation

Emotions: facial expressions, body languageSlide6

NPC Requirements

Believable actions

Realistic behavior

Fulfill function without impeding gameplay or other NPCs

Minimize strain on system

Make the game funSlide7

AI for NPC Behavior

Static NPCs are predictable, repetitive and harder to manage

Complex autonomous NPCs make for interesting emergent behavior and replayable games

NPC AI must be balanced and practical

NPC should not make the game too difficult

NPC AI needs to conserve system resources

Unrealistic behavior and cheating is acceptable if player does not noticeSlide8

Scripted behaviors

Predefined set of actions

Good for linear environments, with predictable events

Bad for open or dynamic environments, with unexpected events

Half-Life 2 uses a lot of scriptingSlide9

Scripts in Half-Life 2 (2:00)Slide10

Autonomous Behavior

Goal-based

NPCs are more complex

Emergent behavior based on desires, sensory input, and proximity to objects of interest

Good response to unexpected events

Human-like behavior: reading books, drinking water, opening doors, etc.

Very flexible

Developers can create an open world

No need to script many individual characters

NOLF2, Far Cry 2, Assassin's Creed: BrotherhoodSlide11

Assassin's Creed: BrotherhoodSlide12

Autonomous Behavior

Simple implementation: Finite State MachinesSlide13

Autonomous Behavior

Complex NPCs are more chaotic

NOLF2: Guard leaves post to work in office

Solution: Apply human concepts

Ownership

Dependency

Responsibility

Relevance

Priority

Consciousness

Expected state

Presence of othersSlide14

Ownership

"Is this object mine to use?"

A guard cannot use a microscope

A scientist cannot use a gun

Assign ownership by grouping objects into sets belonging to specific NPCs

What to do about public objects?

Group them into multiple overlapping sets

Use a world set

Don't group them at allSlide15

Dependency

"Is there anything I need to do before using this object?"

NPCs use the sink after going to the toilet

Use tightly coupled actions

Atomic, inseparable action of using toilet and sink

Less reusability in other situations

Use dependency parameters: objects that reference others by ID

Simple solution used in NOLF2

Disable all objects but the sink after toilet is used, and enable all objects after sink is usedSlide16

Responsibility

"What is my purpose in life?"

Guards responsible for specific areas

Scientists never leave the lab

Tagging objects with the character classes allowed to use it

Specific region tied to guards

Only scientists can use microscopesSlide17

Relevance

"How will my actions affect the player's experience?"

Modern games fit between a simulation and a drama

NPCs should recognize their significance

Rabbits shouldn't be allowed to use dramatic music when being chasedSlide18

Priority

"What is most important right now?"

Aggressive > Investigative > Relaxed

Investigating a dead body vs. being on guard

NPC defending himself vs. drinking coffee

Behavior priorities should persist until behavior is completed

Highest priority goal controls behaviorSlide19

State of Consciousness

"Am I awake?"

Unconscious NPCs have limited actions

C

an snore or wake up

S

hould not be able to talk

When checking bodies, NPCs should know whether the body is conscious or notSlide20

Expected State

"Has anything changed?"

Generalization of consciousness

Ally caught in bear trap, ally is wounded, etc.

Footprints on floor

If object is not as expected the NPC

Investigates

Returns object to its default state

Disturbance threshold

NPC responds when enough disturbances are registeredSlide21

Presence of Others

"How will this action affect other characters?"

NPCs programmed to switch off the light when they exit the room

What if there are other NPCs in the room?

NPCs should coordinate with one anotherSlide22

Coordinated BehaviorSlide23

Coordinated Behavior

NPCs need to be aware of each other too

Messages NPCs need to send each other:

Split Up!

Get Out of My Way!

Get Down!

What's Going On?

Use a blackboard to enable sharing of information among multiple NPCs

Easy but effective solution

Used in NOLF2Slide24

Split Up!

NPCs crowd corridors and rooms

Path reservation

Works best in combat scenarios

Reserve a path during planning

Path becomes more costly to other NPCs

Illusion of flanking and strategy

Maximum Occupancy

Works best in investigative scenarios

First NPC to reach a room flags it as occupied

Additional NPCs approach room but do not enter

Illusion of watching the first NPC investigate

Blackboard coordinates path informationSlide25

Split Up!Slide26

Split Up!Slide27

Get Out of My Way!

NPCs get in each other's line of fire

Is line of fire blocked? Yes

Is obstruction an ally? Yes

Request ally ducks. If ally busy

Step aside and commence firing.

Kung Fu Attack emerges if used in close range melee attacksSlide28

Get Down!

All NPCs exhibit the same behavior

All enemies go prone at the same time

Blackboard coordinates actions

NPC posts AttackProne action

Blackboard counts down ProneTime

Other NPCs do not go prone as long as another NPC is proneSlide29

What's Going On?

NPC is idle while ally is attacked

NPC on patrol steps over dead body

Apply the sensory trigger system used to detect enemies

Detect ally NPC's state

Take appropriate actionSlide30

Human-like NPCsSlide31

Human-like NPCs

Games such as RPG and FPS should improve behavior to be more human-like

We can take into account several factors

Sensory

Memory

Personality

Emotions

Physiological StressorsSlide32

Sensory

NPC's perception of its surroundings

Most important: touch, sight, hearing

Less important: smell, taste

Touch

Detecting if NPC collided with something

Sight

A vision cone based on distance

Affected by lighting and obstacles

Hearing

Listening for player movements, other game events

Affected by proximity and environmentSlide33

Sensory

Smell

Dead corpses should emit a strong stench

Animals are more sensitive to smells

Taste

Humans may like or dislike certain types of foodSlide34

Sensory

Games with stealth mechanics

Thief

Guards visually look for player

Guards react to

corpses

Guards listen for environment noises

&

footsteps

Skyrim

Armor weight, movement speed and proximity affect movement noise

Attacking / casting spells / jumping increase noise

Assassin's Creed

Mostly visualSlide35

Stealth in Skyrim (1:04)Slide36

Memory, Personality, Emotions

How NPCs interact with the player

Memory

NPC learns from interactions

Short-term vs. long-term memory

Personality

Happy, sarcastic, antagonistic, etc.

"Big Five": Extraversion, agreeableness, conscientiousness, neuroticism, openness

Emotions

The mood of NPCs

Happy, sad, angry, etc.Slide37

Memory, Personality, Emotions

Most useful for RPGs

NPCs remember decisions player makes

NPCs have vastly different personalities

NPCs react to player actions

Memorable dialogue

In the (near) future:

More interactive dialogue, less scripted dialogue

Natural language processing, such as in FaçadeSlide38

Interactive NPCs in Façade (13:20)Slide39

Physiological Stressors

Indicators of significant changes in the human body

Muscle fatigue

Pain

Health

Anxiety

Fear

Extreme temperatures

Chemicals

HungerSlide40

Physiological Stressors

Most games implement some stressors

Sims series

Sims have hunger, energy, fun, social, hygiene levels

S.T.A.L.K.E.R.

Radiation poisoning is cured by using med-packs, anti-radiation injections, or drinking vodkaSlide41

Physiological Stressors in Sims (0:50)Slide42

Reputation SystemsSlide43

Reputation Systems

Determines how NPCs react to the player

Makes the game more believable

NPC does not smile and greet you even after you killed their entire village

Varies

gameplay

Different dialogue options

Different events

Different allies / resources

Different endings

Can be NPC-specific / global / localized / event knowledge drivenSlide44

NPC-Specific Reputation

Player actions only affect specific NPCs

Dragon Age II

Supporting blood mages

+ Friendship with Merril

- Friendship with Fenris

Other blood mages still try to kill you

Decisions and responses to the Arishok

Earning his respect means you can fight him one-on-one

Qunari still try to kill you

Town NPCs remain unaffected Slide45

DA2 Friendship with MerrillSlide46

DA2 Friendship PerksSlide47

DA2 Rivalry with FenrisSlide48

DA2 Rivalry PerksSlide49

Global Reputation System

Player actions determine if 'Good' or 'Evil'

All NPCs know what you are

Fable III

Good - Angel wings, Positive responses

Bad - Bat wings, Negative responses

Neutral - Eagle wings

Mass Effect 2

Choose sides - Paragon / Renegade

Problems

Not quite believable - NPCs appear to be psychic

Black and white morality - Not rewarding to be greySlide50

Good Character in Fable IIISlide51

Evil Character in Fable IIISlide52

Reputation in Mass Effect 2Slide53

Grey Morality in Mass Effect 3

General ReputationSlide54

Localized Reputation System

Player reputation only applies within a city or a guild

More believable

City guards would have a central command center

Reasonable to assume all guards share same info

Simpler solution

No need for event-based system

Skyrim

Windhelm

guards do not arrest you for crimes committed in

Whiterun

Standing in Thieves Guild does not affect standing in Dark BrotherhoodSlide55

Localized Reputation in SkyrimSlide56

Event Knowledge Reputation

More realistic: your reputation changes only if NPC has knowledge of an event

NPC is within the area when an event occurs e.g. when an NPC dies or is attacked

NPC comes in contact with another NPC that knows of the event

Reputation changes aren't instantaneous

Player can keep ahead of reputation by eliminating all witnesses of the eventSlide57

Animating NPCsSlide58

Animating NPCs

Despite good NPC behavior, NPCs still seem artificial without smooth animations

In the past: animations were limited to full-body, upper-body, or lower-body

Now body parts should move independently

How do we manage independent layers?Slide59

Animating NPCs

Separate controllers for each body part

Overly complex

Could lead to too many interdependencies

Better: layered animation system

Each layer is categorized by the body region it affects

Animations are prioritized by their importanceSlide60

Animating NPCs

Priorities should make sense

Idle animations have priority of 0

Walks have priority of 5

Attacks have priority of 10

Reactions have priority of 20

Deaths have priority of 100

Each category corresponds to specific body regions

If the category is upper-body, animation data should only be for bones from the waist upSlide61

Animating NPCs: Implementation

Animation controller class

Standard Template Library (STL) map which stores animation instances, sorted by category

Animation instances reference a resource file

Core function PlayAnim()

Can animation be played? (based on category and priority)

Should other animations be stopped?

Animations played from general to more specificSlide62

Skyrim vs Oblivion NPC Animation

(0:08)

(1:46)Slide63

The Ideal NPC

Moves naturally

Realistic movements

Express emotions

Acts normally

Does what they are supposed to do

Behaves like a human being

Responds appropriately

Knows if you are a friend or an enemy

Makes human mistakes