1 / 25

Artificial Intelligence in Game Design

Artificial Intelligence in Game Design. Event and Sense Management. Event Management. Dozens/hundreds of NPCs Hundreds of possible events that may affect them Player visible Explosion heard Collision with wall … How to efficiently notify NPCs affected by events?

lixue
Download Presentation

Artificial Intelligence in Game Design

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. Artificial Intelligence in Game Design Event and Sense Management

  2. Event Management • Dozens/hundreds of NPCs • Hundreds of possible events that may affect them • Player visible • Explosion heard • Collision with wall • … • How to efficiently notify NPCs affected by events? • “notify” = run appropriate code related to event • Shoot at player • Move towards sound • Move away from wall… Created by game engine

  3. Polling • Game engine maintains list of values related to game state • Each time frame, cycle through active NPCs • Examine values that would affect NPC(transitions from current state of NPC) • Very inefficient if many NPCs/possible events Patrolling poll Player within 5 tiles Chasing

  4. Event Manager • Maintains list of “listener” NPCs for each event type • When game engine changes state, notifies event manager • Event manager calls code in all NPCs listening for that event Event manager Game engine Player moved

  5. Event Manager • NPCs register as listener for different events • Can register/unregister dynamically as state changes Treasure room Throne room Event manager

  6. Sense Management • Question: When should character know about event? • Told by event manager/react to message from event handler • Answer: If it would be physically plausible for the character to have sensed the event Hears explosion Too far away Inside soundproofed building

  7. Sight • Simple approach: distance based • Notify NPC when player < d units away • Many games much more sophisticated! • Goal: Use “stealth” to avoid or ambush enemies • Splinter Cell • Ghost Recon • …

  8. Sight • Raycasting • Compute what is visible from NPC point of view • Same code used to determine what is visible from camera POV to render game each frame

  9. Sight • Sight Cone • Visual perception defined by cone in direction NPC is facing • Usually 120 degrees vertical, 220 degrees horizontal • Only notify NPC about events within that cone

  10. Sight • Darkness • Idea: Player should be able to hide in shadows • Game engine computes light level at each point when rendering • Player in area with light level < threshold  NPC not notified about player

  11. Sight • Camouflage • Idea: Characters against background of same color are less visible • Project rays from NPC past player to find object directly behind them • If color of that object ≈ color of player, do not notify NPC

  12. Hearing • Transmitted in all directions • Always heard unless character in soundproofed area • Attenuates with distance • Character will not hear once below threshold of hearing • Slower than light • Characters at great distance will not hear immediately Will hear 3 seconds later 1 km

  13. Touch • If player “bumps” NPC, NPC should perceive player immediately • Can use collision detection built into game engine

  14. Smell • Animals can detect scent of other animals • Can follow scent in direction of increasing signal to player (like smart terrain) • Greater time spent in one area  greater scent level • Depends on wind direction wind

  15. Sense Manager • Acts like event manager for sensory input • Characters register with sense manager • Provide sensory information: • Position • Orientation (for sight) • Sense information (including thresholds) Sense Manager

  16. Sense Manager • Events from game engine include sensory data • Location • Intensity at source • Medium (sight, sound, etc.) • Sense manager determines which NPCs to notify based on their properties, and physics of game Sense Manager Game engine

  17. Attenuation-Based Sensing • Can implement all senses as attenuation for simplicity • Signal received by character = intensity at event source distance from event source • Character notified if signal strength ≥ threshold for that sense • Works best in worlds consisting of open areas What stupid horn head talk about? Hulk not hear explosion! Signal = 2.5Threshold = 1 Signal = 0.5Threshold = 1 Signal = 0.5Threshold = 0.1

  18. Attenuation-Based Sensing • Can apply to sight as well • Intensity at source based on size of object • Shadow decreases intensity at source • Proportional to light level • Camouflage decreases intensity at source • Proportional to difference from background • Still need checks for sight cone, visibility

  19. Graph-based Sensing • Simplifies sensing in “dungeon” worlds with many rooms • Graph defines how signals propagate between rooms • Nodes = rooms • Edges = signals that travel from one room to another sight, sound, smell sight, sound, smell B A B C C A sight, sound sight, sound, smell D smell One-way glass D F E sight, sound Ventilation shaft F E

  20. Graph-based Sensing • When sense manager receives event: • Determines which room it occurs in • Determines which other rooms it may also propagate to Smell propagated to B, D, F Sight, sound propagated to A, B, D A B C Sight propagated to C Sight propagated to B, C D One-way glass Sight propagated to D F E Ventilation shaft

  21. Graph-based Sensing • Sense manager then verifies that NPCs in rooms can actually perceive event • Are characters actually in line of sight? • Do sounds attenuate below threshold of hearing? • … A B C Explosion not visible, but above threshold of hearing Explosion in line of sight D One-way glass F Not tested since room E not connected E Ventilation shaft

  22. Event Manager • Event manager can maintain queue of events • Notify NPCs when processor cycles available • Prioritize important events Event manager Game engine Player moved

  23. Broadcasting • Event manager notifies all registered NPCs about event • Each NPC must decide in their code whether event applies to them • Simple to implement, but may not be efficient Patrolling Event manager playerMoved (15, 73) Player within 5 tiles Chasing Compute whether (15, 73) is within 5 tiles of current position

  24. Narrowcasting • Multiple event handlers instead of one • Each handles related subset of NPCs • Determines whether message passed on to its NPCs • More efficient since fewer messages sent overall Transmits message to squad Event Manager For Squad 1 Location: (32, 14) Squad 1 Game engine Player moved to (30, 17) Event Manager For Squad 2 Location: (16, 22) Does not transmit message to squad Squad 2

  25. Narrowcasting • Useful for messages within squad • NPC hit, changing its status • Sends message to Event Manager • Event Manager notifies rest of squad Rest of squad notified Event Manager For Squad 1 npcHit method Squad 1 Calls method in event manager

More Related