Presentation is loading. Please wait.

Presentation is loading. Please wait.

Artificial Intelligence in Game Design Event and Sense Management.

Similar presentations


Presentation on theme: "Artificial Intelligence in Game Design Event and Sense Management."— 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 VariableState …… playerLocation(15, 73) Patrolling Chasing Player within 5 tiles poll

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 Player moved Orc1 Orc3 Explosion Orc2 Orc3 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 Player in throne room Orc1 Orc3 Player in treasure room Orc2 Orc3 Orc1

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 121 12321 1234321 123454321 234654321 123454321 1234321 12321 121 1 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 Position(32, 18) Orientation30 degrees Sighttrue HearingThresh = 1.0 Position(16, 25) Orientation160 degrees Sightfalse HearingThresh = 0.1 Position(18, 22) Orientation310 degrees Sighttrue HearingThresh = 1.0

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 Location(35, 10) Intensity100 Mediumsound

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 Signal = 2.5 Threshold = 1 Signal = 0.5 Threshold = 1 Signal = 0.5 Threshold = 0.1 What stupid horn head talk about? Hulk not hear explosion!

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 One-way glass Ventilation shaft ABC D E F A F B C D E sight, sound sight, sound, smell smell sight, sound, smell sight, sound

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

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? –…–… One-way glass Ventilation shaft ABC D E F Explosion in line of sight Explosion not visible, but above threshold of hearing Not tested since room E not connected

22 Event Manager Event manager can maintain queue of events –Notify NPCs when processor cycles available –Prioritize important events Event manager Player moved Orc1 Orc3 Explosion Orc2 Orc3 Game engine Player moved Events Player moved Explosion

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 Chasing Player within 5 tiles playerMoved (15, 73) Event manager Player moved Orc1 Orc3 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 Squad 1 Squad 2 Event Manager For Squad 1 Location: (32, 14) Event Manager For Squad 2 Location: (16, 22) Game engine Player moved to (30, 17) Transmits message to squad Does not transmit message to squad

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


Download ppt "Artificial Intelligence in Game Design Event and Sense Management."

Similar presentations


Ads by Google