1 / 56

Individual NPC Behavior

Individual NPC Behavior. Elizabeth Carter CSE 348 2/11/2010. Agenda. Realistic Character Animation Responding to the Player Simulated Animals Autonomous Characters More Humanlike NPCs. Realistic Animation. Realistic Character Animation.

radley
Download Presentation

Individual NPC Behavior

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Individual NPC Behavior Elizabeth Carter CSE 348 2/11/2010

  2. Agenda • Realistic Character Animation • Responding to the Player • Simulated Animals • Autonomous Characters • More Humanlike NPCs

  3. Realistic Animation

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

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

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

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

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

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

  10. Reputation

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

  12. Types of Reputation Systems • Create global reputations based on average of other’s opinions • Use Centralized authorities to create global reputations inherited by all

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

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

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

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

  17. Long Term Memory • References all events in Master Event List that NPC in question was involved in • Witnessed • Heard About

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

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

  20. Long Term Memory • Contains compressed versions of • Reputation events known to NPC • Data • Event ID • Magnitude of event • Time encountered

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

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

  23. How Learning Occurs • Event Announcers • Sharing Information • Memory Match and Updates

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

  25. Sharing • Let the NPCs Gossip • If Eve likes Lisa, they’ll share • If Eve dislikes Lisa she’ll keep the info to herself

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

  27. Seven Rules For Updating (1) • Ignore: • MagnitudenewEvent <= MagnitudeoldEvent • New Event Subject group Unknown • Same subject group for both • Object individual ID the same for both events • Subject groups match and are already known • Old event has maximum magnitude

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

  29. Seven Rules for Updating (3) • Remove existing event and add the one with the greater magnitude, applying reputation effects • New event subject group known • Existing event subject group unknown • Object individual IDs match • New Event has new information • Subject groups known and match • New event has maximum magnitude

  30. Seven Rules for Updating (4) • Add new event and apply reputation effects • Subject groups for either or both unknown • Object individual IDs different • Subject groups known and match • Object individual IDs different • Neither even has maximum magnitude

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

  32. Simulating Animals

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

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

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

  36. Autonomous Characters

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

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

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

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

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

  42. Coordinated Behavior

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

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

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

  46. More Humanlike NPCs

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

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

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

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

More Related