artificial intelligence in game design event and sense management

25
Artificial Intelligence in Game Design Event and Sense Management

Upload: arlene-leonard

Post on 11-Jan-2016

219 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Artificial Intelligence in Game Design Event and Sense Management

Artificial Intelligence in Game Design

Event and Sense Management

Page 2: 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?– “notify” = run appropriate code related to event

• Shoot at player

• Move towards sound

• Move away from wall…

Created by game engine

Page 3: Artificial Intelligence in Game Design Event and Sense Management

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

Variable State

… …

playerLocation (15, 73)

Patrolling

Chasing

Player within 5 tilespoll

Page 6: Artificial Intelligence in Game Design Event and Sense Management

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

Page 7: Artificial Intelligence in Game Design Event and Sense Management

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– …

Page 8: Artificial Intelligence in Game Design Event and Sense Management

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

Page 9: Artificial Intelligence in Game Design Event and Sense Management

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

Page 10: Artificial Intelligence in Game Design Event and Sense Management

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

Page 11: Artificial Intelligence in Game Design Event and Sense Management

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

Page 12: Artificial Intelligence in Game Design Event and Sense Management

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

Page 13: Artificial Intelligence in Game Design Event and Sense Management

Touch

• If player “bumps” NPC, NPC should perceive player immediately

• Can use collision detection built into game engine

Page 14: Artificial Intelligence in Game Design Event and Sense Management

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

1 2 1

1 2 3 2 1

1 2 3 4 3 2 1

1 2 3 4 5 4 3 2 1

2 3 4 6 5 4 3 2 1

1 2 3 4 5 4 3 2 1

1 2 3 4 3 2 1

1 2 3 2 1

1 2 1

1

wind

Page 15: Artificial Intelligence in Game Design Event and Sense Management

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 ManagerPosition (32, 18)

Orientation 30 degrees

Sight true

Hearing Thresh = 1.0

Position (16, 25)

Orientation 160 degrees

Sight false

Hearing Thresh = 0.1

Position (18, 22)

Orientation 310 degrees

Sight true

Hearing Thresh = 1.0

Page 16: Artificial Intelligence in Game Design Event and Sense Management

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

Gameengine Location (35, 10)

Intensity 100

Medium sound

Page 17: Artificial Intelligence in Game Design Event and Sense Management

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.5Threshold = 1 Signal = 0.5

Threshold = 1

Signal = 0.5Threshold = 0.1

What stupid horn head talk about? Hulk not hear explosion!

Page 18: Artificial Intelligence in Game Design Event and Sense Management

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

Page 19: Artificial Intelligence in Game Design Event and Sense Management

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

A B C

D

EF

A

F

B

C

D

E

sight, sound

sight, sound, smell

smell

sight, sound, smell

sight, sound, smell

sight, sound

Page 23: Artificial Intelligence in Game Design Event and Sense Management

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 tilesplayerMoved (15, 73) Event manager

Player moved

Orc1

Orc3Compute whether (15, 73) is within 5 tiles of current position

Page 24: Artificial Intelligence in Game Design Event and Sense Management

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 ManagerFor Squad 1

Location: (32, 14)

Event ManagerFor Squad 2

Location: (16, 22)

Gameengine

Player moved to (30, 17)

Transmits message to squad

Does not transmit message to squad

Page 25: Artificial Intelligence in Game Design Event and Sense Management

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 ManagerFor Squad 1

npcHit method

Calls method in event manager

Rest of squad notified