individual npc behavior elizabeth carter cse 348 2/11/2010
TRANSCRIPT
![Page 1: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/1.jpg)
Individual NPC Behavior
Elizabeth CarterCSE 348
2/11/2010
![Page 2: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/2.jpg)
Agenda
• Realistic Character Animation
• Responding to the Player
• Simulated Animals
• Autonomous Characters
• More Humanlike NPCs
![Page 3: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/3.jpg)
Realistic Animation
![Page 4: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/4.jpg)
Realistic Character Animation
• No longer acceptable to animate one part at a time
• Want character to be able to do multiple things at once• Walk, wave, hair blown by breeze
• Layering of animation
• Two methods• Animation Controller• Layered / prioritized animation system
![Page 5: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/5.jpg)
Animation Controller and Layering
• Animation Controller approach• Use separate animation controller for each
body part• Can lead to over complicated code and
interdependencies
• Layering• Made possible via skeletal animation systems• Layers categorized by regions of body that
they affect
![Page 6: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/6.jpg)
Prioritization and Categorization
• Each animation receives priority and category• In implementation discussed…• Priority• Integer, with zero being lowest
• Category• Bit flag enumerator describing affected body area
![Page 7: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/7.jpg)
Animation Controller for Priory and Categorization
• In one implementation• Animation controller class has one• Member variable• Map of animation instances
• Animation instance = struct storing animation resource file refrance and instance data
• Sorted by category
• Core function• Requests play of animation
• Priority utilized to determine if it should be allowed to play
![Page 8: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/8.jpg)
Important Assumptions
• Each frame stored as list of bone rotations [p 66]
• Rotations stored relative to same default pose
• Applying animation to bone overrides any previously applied animation bone rotations
![Page 9: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/9.jpg)
Keeping the Motion Natural
• Blend between animations during transition• Keeps animation from becoming choppy
• Implementation• Store array of quaternions (cache)• Quaternion algebra is method for representing 3
dimensional orientation
• Animation refers to array to gradually blend the animation
![Page 10: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/10.jpg)
Reputation
![Page 11: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/11.jpg)
Responding to the Player
• NPCs should• React to player’s ability• React in situation appropriate manner
• One way to implement this – Reputation system• Prevents • NPC Omniscience• NPC Bob shouldn’t know what happened with NPC
Larry if not involved
![Page 12: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/12.jpg)
Types of Reputation Systems
• Create global reputations based on average of other’s opinions
• Use Centralized authorities to create global reputations inherited by all
![Page 13: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/13.jpg)
Problems with Existing Systems
• Identity• Usually every individual has one known
identity • Problem – identity easily faked
• Ratings• Excessive negative or positive ratings with no
substantiation
![Page 14: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/14.jpg)
Surreal Software Implementation
• Event Driven
• Data Structures• Event Template• Reputation Event• Master Event List• Long Term Memory (per NPC)• Reputation Table (per NPC)
• Only stores• Events involving player• Events where NPC killed someone
![Page 15: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/15.jpg)
Reputation Event
• Triggered when player does something that has positive or negative affect on their reputation• Example• Kills NPC’s friend• Kills NPC’s enemy
![Page 16: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/16.jpg)
Master Event List
• Holds all important actions NPCs privy to
• Stored as list of Reputation Events
• Reputation Event added to this when its created
• Stores complete information about all events
• Events no NPC knows about deleted to keep list small
• Multiple copies of same event receive one entry
![Page 17: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/17.jpg)
Long Term Memory
• References all events in Master Event List that NPC in question was involved in • Witnessed• Heard About
![Page 18: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/18.jpg)
Reputation Table
• Stores NPC’s opinion of player• Each NPC has own opinions• Is list of groups• Group for Player• Group for members of each group
• On recognition of reputation event, reputation effect applied
![Page 19: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/19.jpg)
Reputation Details
• Implemented via dynamic array• Contains reputation meters• One meter for each group• One meter for player
• Meter has • Group ID• 2 Float Variables• Like• Hate
![Page 20: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/20.jpg)
Long Term Memory
• Contains compressed versions of• Reputation events known to NPC
• Data• Event ID• Magnitude of event• Time encountered
![Page 21: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/21.jpg)
Long Term Memory Example
• NPC Bob and NPC Lisa witness the same event• Lisa watches to see player kill another NPC• Bob runs away
• Lisa ‘remembers’ Killed
• Bob ‘remembers’ ShootAt
![Page 22: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/22.jpg)
Long Term Memory Physical Memory Management
• Table consists of references instead of the actual data
• Don’t let NPC learn something they shouldn’t know• Not witness or recipient of information, shouldn’t
know it• If a tree falls in a forest and no one is there to hear
it... • the NPC doesn’t remember the sound of it falling
• Let NPC forget
• Choke Points
![Page 23: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/23.jpg)
How Learning Occurs
• Event Announcers
• Sharing Information
• Memory Match and Updates
![Page 24: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/24.jpg)
Event Announcers
• Spawned by actions at position of object of event• On NPC Bob’s death event announced
immediately • Announcer at body stays and continually
announces Bob’s death
![Page 25: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/25.jpg)
Sharing
• Let the NPCs Gossip• If Eve likes Lisa, they’ll share• If Eve dislikes Lisa she’ll keep the info to
herself
![Page 26: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/26.jpg)
Memory Match and Update
• For each event• NPC checks to see if this event matches
something it’s already stored• Checks subject group, verb, object group, object
individual
• What needs to match• Check group, verb, etc, exactly• Group, verb, object match but not individual
ID • Unknown subject group but matches
everything else• Subject group known of new event but not old
event
![Page 27: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/27.jpg)
Seven Rules For Updating (1)
• Ignore:1. MagnitudenewEvent <= MagnitudeoldEvent
• New Event Subject group Unknown • Same subject group for both• Object individual ID the same for both events
2. Subject groups match and are already known• Old event has maximum magnitude
![Page 28: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/28.jpg)
Seven Rules for Updating (2)
• Update Magnitude in Long Term Memory, apply reputation effects• MagnitudeNewEvent > MagnitudeOldEvent
• New Event contains unknown subject group or subject groups equal
• Object individual IDs the same
![Page 29: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/29.jpg)
Seven Rules for Updating (3)
• Remove existing event and add the one with the greater magnitude, applying reputation effects
1. New event subject group known• Existing event subject group unknown• Object individual IDs match• New Event has new information
2. Subject groups known and match• New event has maximum magnitude
![Page 30: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/30.jpg)
Seven Rules for Updating (4)
• Add new event and apply reputation effects1. Subject groups for either or both unknown• Object individual IDs different
2. Subject groups known and match• Object individual IDs different• Neither even has maximum magnitude
![Page 31: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/31.jpg)
Applying Updates and Incomplete Information
• Applying Update• Modifies own Long Term Memory first• Then notifies Master Event List• If exists there already, update and increase
reference count
• Incomplete Information• Complete the information with peer data• Bob has an event with an unknown subject group• Lisa has a matching event with a known subject
group
![Page 32: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/32.jpg)
Simulating Animals
![Page 33: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/33.jpg)
Animal NPC Behavior
• Usage• Ambient animals• Scenery
• Secondary animals• Some interaction but not focus• Chickens in Zelda
• Primary animals• Primary focus of a game• Hunting situations
• Real Life behavior must be taken into account
![Page 34: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/34.jpg)
Behavior – Simple Animals
• Bugs, Solitary Animals, Flocks of Birds, Schools of Fish• General behaviors studied and mimicked• Birds and fish unique because travel in
flocks/schools• Allow for low level multiagent system behavior
![Page 35: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/35.jpg)
Behavior – Primary and Secondary Animals
• Generally concerns large mammals• Real behavior more varied and intelligent than
that of bugs, fish, etc• Best programmed via state machines• FSMs adequate• Fuzzy logic presents more realistic behavior
![Page 36: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/36.jpg)
Autonomous Characters
![Page 37: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/37.jpg)
Autonomous Characters
• Emergent Gameplay• Players have freedom to explore and solve
problems without restraint• Game world responds appropriately• Player rewarded for creativity and exploration• Example: The Sims, NOLF2
![Page 38: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/38.jpg)
Controlling Autonomous Characters (1)
• Need to not stray too far from what it was meant for
• Ownership of objects prevents NPC Bob from stealing Lisa’s desk when she uses the restroom
• Dependencies• Couple two items together to create atomic
behavior• Toilet usage and hand washing
![Page 39: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/39.jpg)
Controlling Autonomous Characters (2)
• Responsibility• Helps player decide what to do appropriately
• Relevance• NPC’s understanding of relevance to the
storyline helps decrease overreaction of system• Example: NOLF2 rabbit being scared off triggered
very intense music, this is undesirable
• Priority• High priority implies urgency to NPC
![Page 40: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/40.jpg)
Controlling Autonomous Characters (3)
• State of Consciousness• If character is sleeping or unconscious it
shouldn’t be responding to sensory input
• Expected State• Character might expect compatriot to be
patrolling, therefore expects to see patrolling behavior • Unconsciousness would be unexpected and dealt
with according to the game
![Page 41: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/41.jpg)
Character Introspection
• Suggested questions that agent should ask itself in an emergent environment• Ownership – is this mine?• Dependency – is there something I need to do
before x?• Responsibility – what am I supposed to be doing?• Relevance – how will my actions affect gameplay?• Priority – what’s most important right now?• Consciousness – am I conscious?• Expected state – is everything as I expect it to be?• Others – how will what I do affect other NPCs
![Page 42: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/42.jpg)
Coordinated Behavior
![Page 43: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/43.jpg)
Splitting Up
• Don’t have all agents take the same path
• Solutions• Reserve path• Agents reserve pathfinding nodes for themselves
so that everyone doesn’t go the same way
• Adopt maximum occupancy rule• Only allow a certain number of agents at a given
location
• Use inter-agent communication to find out what other agents are doing and plan accordingly
![Page 44: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/44.jpg)
Getting Out Of The Way
• Obstruction by ally can be resolved in 4 ways (regarding firing)• Do nothing• Fire anyway (killing ally)• Agent moves• Ally moves
![Page 45: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/45.jpg)
Inter Agent Communication
• Efficient and intelligent utilization of inter agent communication can enable the agents to behave, as a group, much more intelligently than they otherwise might• NPC can share knowledge with another NPC• NPCs can coordinate behavior
![Page 46: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/46.jpg)
More Humanlike NPCs
![Page 47: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/47.jpg)
Sensory Perception (1)
• First step in making an NPC more humanlike
• Tactile• Achieved through collision detection systems
and smart terrain• Range• Immediate surrounding area on all sides
![Page 48: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/48.jpg)
Sensory Perception (2)
• Visual • Need to model NPC visual system after a person• Sensing region should be cone shaped• should extend to limited distance in front of agent
to simulate binocular vision• Lighting conditions can effect NPC’s sight
realistically
• Audio• Sound attenuates with distance therefore NPC
hearing should degrade with distance from sound• NPC should be able to hear same things player can
hear
![Page 49: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/49.jpg)
Sensory Perception (3)
• Olfactory• Smell should be emitted across some radius
depending on strength of smell• Smell should deteriorate over time as disperses
or get stronger over time if appropriate • Corpse smells worse as time goes by
• Taste• aka Gustatory sensing• Not used very often, could be used for game
beasts – they could get more aggressive when taste raw meat
![Page 50: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/50.jpg)
Memory
• Humans have 3 different kinds of memory• Sensory, short term, long term
• NPC memory• Sensory memory linked to sensory input• Short term memory accomplished by utilizing
timestamp degradation and importance levels• Many ways to implement long term memory• Size management can become an issue
![Page 51: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/51.jpg)
Personality
• Model• “The Big Five”• Extraversion, agreeableness, conscientiousness,
neuroticism, openness
• Implement via a desirability algorithm• Add bias to decision algorithms depending on
agent personality
![Page 52: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/52.jpg)
Emotions
• Eight primary emotions in people• Joy, acceptance, fear, surprise, sadness,
disgust, anger, anticipation
• Current game emotions generally scripted
• Could implement such that different actions instill different emotions • Killing an NPC could invoke sadness, disgust,
fear, etc
![Page 53: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/53.jpg)
Emotions – An Implementation
• One way that Emotions could be given to an agent is by providing an emotional model to the system• Could be divided into 3 parts• Input• Internal reaction• External Reaction
![Page 54: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/54.jpg)
Human Emotions
• Are three popular theories to how we interpret emotion from external stimulus• After external stimulus emotional state alters
as result of physiological state change• Physiological and emotional states
simultaneously affected after receipt of stiumuls
• Emotional states determined by perceived cause of stiumulus
![Page 55: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/55.jpg)
NPC Emotion
• Example implementation from “IPD for Emotional NPC Societies in Games”
• 5 basic emotions modeled• Fear, anger, disgust, sadness, happiness
• Implementation of Norms was included to include social acceptability of an action as a consideration
• Drives included to simulate real world stimulus• Social, energy, rest, and heat
![Page 56: Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010](https://reader038.vdocuments.site/reader038/viewer/2022103007/56649eac5503460f94bb36ba/html5/thumbnails/56.jpg)
Physiological Stressors
• Anything that causes significant change in human body to occur• Muscle fatigue, pain, health, anxiety/fear,
exposure to cold/hot/chemicals, hunger• If agent is hot, should be sweating• If agent comes into contact with chemicals,
should receive chemical burns