Individual NPC Behavior Daniel Phang & Sui Ying Teoh.
-
Upload
ebony-stopper -
Category
Documents
-
view
224 -
download
2
Transcript of Individual NPC Behavior Daniel Phang & Sui Ying Teoh.
![Page 1: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/1.jpg)
Individual NPC Behavior
Daniel Phang & Sui Ying Teoh
![Page 2: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/2.jpg)
NPC - Non-Player Character
• Primary application of AI in games
• Any character not controlled by playero Mobs, Monsters, Enemies
o Allies
o Noncombat or neutral units
o Environment animals
• Function to create an immersive gaming experience for the player
![Page 3: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/3.jpg)
Overview
• NPC Behavior
• Coordinated Behavior
• Human-like NPCs
• Reputation Systems
• Animating NPCs
![Page 4: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/4.jpg)
NPC Behavior
![Page 5: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/5.jpg)
What is NPC Behavior?
• Actions NPCs perform (in-game behavior)o Movemento Environmental interactionso Combato Responses to game eventso Querying and storing information
• Later: animationso Movement: limb and body animationo Emotions: facial expressions, body language
![Page 6: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/6.jpg)
NPC Requirements
• Believable actions
• Realistic behavior
• Fulfill function without impeding
gameplay or other NPCs
• Minimize strain on system
• Make the game fun
![Page 7: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/7.jpg)
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 practicalo NPC should not make the game too difficulto NPC AI needs to conserve system resourceso Unrealistic behavior and cheating is
acceptable if player does not notice
![Page 8: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/8.jpg)
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 scripting
![Page 10: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/10.jpg)
Autonomous Behavior
• Goal-based
• NPCs are more complexo Emergent behavior based on desires, sensory
input, and proximity to objects of interest o Good response to unexpected eventso Human-like behavior: reading books,
drinking water, opening doors, etc.
• Very flexibleo Developers can create an open worldo No need to script many individual characters
• NOLF2, Far Cry 2, Assassin's Creed: Brotherhood
![Page 12: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/12.jpg)
Autonomous Behavior
Simple implementation: Finite State Machines
![Page 13: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/13.jpg)
Autonomous Behavior• Complex NPCs are more chaotic
o NOLF2: Guard leaves post to work in office
• Solution: Apply human conceptso Ownershipo Dependencyo Responsibilityo Relevanceo Priorityo Consciousnesso Expected stateo Presence of others
![Page 14: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/14.jpg)
Ownership
• "Is this object mine to use?"o A guard cannot use a microscope
o A scientist cannot use a gun
• Assign ownership by grouping objects into sets belonging to specific NPCs
• What to do about public objects?o Group them into multiple overlapping sets
o Use a world set
o Don't group them at all
![Page 15: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/15.jpg)
Dependency
• "Is there anything I need to do before using this object?"o NPCs use the sink after going to the toilet
• Use tightly coupled actionso Atomic, inseparable action of using toilet and sinko Less reusability in other situations
• Use dependency parameters: objects that reference others by ID
• Simple solution used in NOLF2o Disable all objects but the sink after toilet is used, and
enable all objects after sink is used
![Page 16: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/16.jpg)
Responsibility
• "What is my purpose in life?"
o Guards responsible for specific areas
o Scientists never leave the lab
• Tagging objects with the character
classes allowed to use it
o Specific region tied to guards
o Only scientists can use microscopes
![Page 17: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/17.jpg)
Relevance
• "How will my actions affect the player's experience?"
• Modern games fit between a simulation and a drama
• NPCs should recognize their significanceo Rabbits shouldn't be
allowed to use dramatic music when being chased
![Page 18: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/18.jpg)
Priority
• "What is most important right now?"
• Aggressive > Investigative > Relaxedo Investigating a dead body vs. being on guardo NPC defending himself vs. drinking coffee
• Behavior priorities should persist until behavior is completedo Highest priority goal controls behavior
![Page 19: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/19.jpg)
State of Consciousness
• "Am I awake?"
• Unconscious NPCs have limited actionso Can snore or wake upo Should not be able to talk
• When checking bodies, NPCs should know whether the body is conscious or not
![Page 20: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/20.jpg)
Expected State
• "Has anything changed?"
• Generalization of consciousnesso Ally caught in bear trap, ally is wounded, etc.o Footprints on floor
• If object is not as expected the NPCo Investigateso Returns object to its default state
• Disturbance thresholdo NPC responds when enough disturbances are
registered
![Page 21: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/21.jpg)
Presence of Others
• "How will this action affect other characters?"o NPCs programmed to switch off the light
when they exit the roomo What if there are other NPCs in the room?
• NPCs should coordinate with one another
![Page 22: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/22.jpg)
Coordinated Behavior
![Page 23: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/23.jpg)
Coordinated Behavior
• NPCs need to be aware of each other too
• Messages NPCs need to send each other:o Split Up!o Get Out of My Way!o Get Down!o What's Going On?
• Use a blackboard to enable sharing of information among multiple NPCso Easy but effective solutiono Used in NOLF2
![Page 24: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/24.jpg)
Split Up!
• NPCs crowd corridors and rooms
• Path reservationo Works best in combat scenarioso Reserve a path during planningo Path becomes more costly to other NPCso Illusion of flanking and strategy
• Maximum Occupancyo Works best in investigative scenarioso First NPC to reach a room flags it as occupiedo Additional NPCs approach room but do not entero Illusion of watching the first NPC investigate
• Blackboard coordinates path information
![Page 25: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/25.jpg)
Split Up!
![Page 26: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/26.jpg)
Split Up!
![Page 27: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/27.jpg)
Get Out of My Way!
• NPCs get in each other's line of fire
1. Is line of fire blocked? Yes2. Is obstruction an ally? Yes3.Request ally ducks. If ally busy4.Step aside and commence firing.
• Kung Fu Attack emerges if used in close range melee attacks
![Page 28: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/28.jpg)
Get Down!
• All NPCs exhibit the same behavior
o All enemies go prone at the same time
• Blackboard coordinates actions
o NPC posts AttackProne action
o Blackboard counts down ProneTime
o Other NPCs do not go prone as long as
another NPC is prone
![Page 29: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/29.jpg)
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
o Detect ally NPC's state
o Take appropriate action
![Page 30: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/30.jpg)
Human-like NPCs
![Page 31: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/31.jpg)
Human-like NPCs
• Games such as RPG and FPS should improve behavior to be more human-like
• We can take into account several factorso Sensory
o Memory
o Personality
o Emotions
o Physiological Stressors
![Page 32: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/32.jpg)
Sensory• NPC's perception of its surroundings
o Most important: touch, sight, hearingo Less important: smell, taste
• Toucho Detecting if NPC collided with something
• Sighto A vision cone based on distanceo Affected by lighting and obstacles
• Hearingo Listening for player movements, other game
eventso Affected by proximity and environment
![Page 33: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/33.jpg)
Sensory
• Smell
o Dead corpses should emit a strong stench
o Animals are more sensitive to smells
• Taste
o Humans may like or dislike certain types of
food
![Page 34: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/34.jpg)
Sensory
• Games with stealth mechanicso Thief
Guards visually look for player Guards react to corpses Guards listen for environment noises &
footstepso Skyrim
Armor weight, movement speed and proximity affect movement noise
Attacking / casting spells / jumping increase noise
o Assassin's Creed Mostly visual
![Page 36: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/36.jpg)
Memory, Personality, Emotions
• How NPCs interact with the player
• Memoryo NPC learns from interactionso Short-term vs. long-term memory
• Personalityo Happy, sarcastic, antagonistic, etc.o "Big Five": Extraversion, agreeableness,
conscientiousness, neuroticism, openness
• Emotionso The mood of NPCso Happy, sad, angry, etc.
![Page 37: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/37.jpg)
Memory, Personality, Emotions
• Most useful for RPGso NPCs remember decisions player makes
o NPCs have vastly different personalities
o NPCs react to player actions
o Memorable dialogue
• In the (near) future:o More interactive dialogue, less scripted
dialogue
o Natural language processing, such as in Façade
![Page 39: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/39.jpg)
Physiological Stressors
• Indicators of significant changes in the human bodyo Muscle fatigueo Paino Healtho Anxietyo Fearo Extreme temperatureso Chemicalso Hunger
![Page 40: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/40.jpg)
Physiological Stressors
• Most games implement some stressors
• Sims series
o Sims have hunger, energy, fun, social,
hygiene levels
• S.T.A.L.K.E.R.
o Radiation poisoning is cured by using med-
packs, anti-radiation injections, or drinking
vodka
![Page 42: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/42.jpg)
Reputation Systems
![Page 43: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/43.jpg)
Reputation Systems
• Determines how NPCs react to the player
• Makes the game more believableo NPC does not smile and greet you even after you
killed their entire village
• Varies gameplayo Different dialogue options
o Different events
o Different allies / resources
o Different endings
• Can be NPC-specific / global / localized / event knowledge driven
![Page 44: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/44.jpg)
NPC-Specific Reputation• Player actions only affect specific
NPCs
• Dragon Age IIo Supporting blood mages
+ Friendship with Merril - Friendship with Fenris Other blood mages still try to kill you
o 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
![Page 45: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/45.jpg)
DA2 Friendship with Merrill
![Page 46: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/46.jpg)
DA2 Friendship Perks
![Page 47: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/47.jpg)
DA2 Rivalry with Fenris
![Page 48: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/48.jpg)
DA2 Rivalry Perks
![Page 49: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/49.jpg)
Global Reputation System• Player actions determine if 'Good' or
'Evil'
• All NPCs know what you are
• Fable IIIo Good - Angel wings, Positive responseso Bad - Bat wings, Negative responseso Neutral - Eagle wings
• Mass Effect 2o Choose sides - Paragon / Renegade
• Problemso Not quite believable - NPCs appear to be
psychico Black and white morality - Not rewarding to
be grey
![Page 50: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/50.jpg)
Good Character in Fable III
![Page 51: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/51.jpg)
Evil Character in Fable III
![Page 52: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/52.jpg)
Reputation in Mass Effect 2
![Page 53: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/53.jpg)
Grey Morality in Mass Effect 3
General Reputation
![Page 54: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/54.jpg)
Localized Reputation System• Player reputation only applies within a
city or a guild
• More believableo City guards would have a central command
centero Reasonable to assume all guards share same
info
• Simpler solutiono No need for event-based system
• Skyrimo Windhelm guards do not arrest you for
crimes committed in Whiteruno Standing in Thieves Guild does not affect
standing in Dark Brotherhood
![Page 55: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/55.jpg)
Localized Reputation in Skyrim
![Page 56: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/56.jpg)
Event Knowledge Reputation
• More realistic: your reputation changes only if NPC has knowledge of an evento NPC is within the area when an event occurs
e.g. when an NPC dies or is attackedo NPC comes in contact with another NPC that
knows of the event
• Reputation changes aren't instantaneouso Player can keep ahead of reputation by
eliminating all witnesses of the event
![Page 57: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/57.jpg)
Animating NPCs
![Page 58: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/58.jpg)
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?
![Page 59: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/59.jpg)
Animating NPCs
• Separate controllers for each body
part
o Overly complex
o Could lead to too many interdependencies
• Better: layered animation system
o Each layer is categorized by the body region
it affects
o Animations are prioritized by their
importance
![Page 60: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/60.jpg)
Animating NPCs
• Priorities should make senseo Idle animations have priority of 0o Walks have priority of 5o Attacks have priority of 10o Reactions have priority of 20o Deaths have priority of 100
• Each category corresponds to specific body regionso If the category is upper-body, animation data
should only be for bones from the waist up
![Page 61: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/61.jpg)
Animating NPCs: Implementation
• Animation controller classo Standard Template Library (STL) map which
stores animation instances, sorted by category
o Animation instances reference a resource fileo Core function PlayAnim()
Can animation be played? (based on category and priority)
Should other animations be stopped? Animations played from general to more
specific
![Page 63: Individual NPC Behavior Daniel Phang & Sui Ying Teoh.](https://reader035.fdocuments.us/reader035/viewer/2022062308/56649c715503460f9492250b/html5/thumbnails/63.jpg)
The Ideal NPC
• Moves naturallyo Realistic movements
o Express emotions
• Acts normallyo Does what they are supposed to do
o Behaves like a human being
• Responds appropriatelyo Knows if you are a friend or an enemy
o Makes human mistakes