Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ch 7.1: Using a Spatial Database for Runtime Spatial Analysis.

Similar presentations


Presentation on theme: "Ch 7.1: Using a Spatial Database for Runtime Spatial Analysis."— Presentation transcript:

1 Ch 7.1: Using a Spatial Database for Runtime Spatial Analysis

2 Purpose  Dynamic environment – player’s actions are unpredictable, player can change environment (i.e. game has a physics engine)  High levels of interactivity, coupled with dynamic environments, require sophisticated AI  AI needs way to process information in environment

3 Example

4 Possible Representations  Static Place “hints” in the game worldPlace “hints” in the game world Analyze world and build a data structureAnalyze world and build a data structure  Dynamic Influence maps (establishes implicit boundaries between opposing forces)Influence maps (establishes implicit boundaries between opposing forces)  Want a solution that represents all relevant data

5 Spatial Database  2D grid overlaid on top of the game world  Multiple independent layers superimposed on the same grid  Most useful layers: OpennessOpenness Area occupancyArea occupancy Area searchArea search Line-of-fireLine-of-fire Light levelLight level

6 Use of Spatial Database  Combine multiple layers to compute composite desirability values AI examines nearby cells, moves accordinglyAI examines nearby cells, moves accordingly Implicitly coordinates behavior of multiple AIsImplicitly coordinates behavior of multiple AIs

7 Openness Layer  Needed for tactics which require certain amount of open space (ex – “Circle of Death”)  Cells contain values that indicate how close it is to a wall/object  If blocked, value = 0; else, value = 1  Propagate influence of 0-value cells to neighbors

8 Example Propagation 0111 00.211 00.20.41 00.20.40.6

9 Uses of Openness Layer  Can determine the direction of increasing/decreasing openness  Can use this gradient to find the middle of the room (high openness) and the walls (low openness)

10 Area Occupancy Layer  More for RTS games, “fog of war”  Each unit propagates an area of influence around itself  Cells with nonzero values are visible  Units update grid values when moving (or created/destroyed)  Used in other genres for AIs to know how populated an area of the world is

11 Uses of Area of Occupancy Layer  Higher values if cells are closer to more agents  Avoid moving into occupied areas when maneuvering  Difference between “fog of war” and occupancy – values depend on distance between AI units for occupancy, not “fog of war”

12 Area Search Layer  Games with stealth components, AI needs to search for player  Scouts in RTS games, uncovering the map  Initialize the layer to zero values  Increment cell values as they enter AI agent’s view arc

13 Implementation for Stealth Games  Guard considers surrounding area a “hidden map”  Has clues to aid search; knows where to begin and where to look  Store database of evidence, bias search towards it  Decay database over time (randomly?)  Automatically coordinates multiple NPCs

14 Thief 3

15 Line-of-Fire Layer  For game genres with ranged weapons  Want to ensure that AIs don’t block each others’ shots  Each cell starts as zero  When AI aims, propagates values in its viewing arc  Each AI ignores its own contribution (temporarily subtract value before reading)

16 Light Level Layer  Needed for games with dynamic lighting  Stealthy characters/vampires would avoid light, guards would prefer light  Initialize to 0s  Each light source propagates values based on current radius, lighting type, intensity, etc.

17 Handling 3D Environments  Single 2D grid can’t represent vertically overlapping areas  Solution: transform grid into one of sub-grids  Assign a sub-grid to each different height  Works well for human environments

18 Potential Issues  Spatial database system could be a performance nightmare  Large grid + high resolution + large # of AIs + frequent updates = Updating certain areas constantly is a waste of time/memory Updating certain areas constantly is a waste of time/memory

19 Optimizations  Pare size of the grid (make cells represent larger areas of environment)  Don’t recalculate static layers  Decompress sub-grids as needed  Combine cells if all values are the same  Use short-circuit evaluation  Update cells only when used

20 Sources  Tozour, Paul, “Using a Spatial Database for Runtime Spatial Analysis,” AI Game Programming Wisdom 2.  HL2 video - http://www.zippyvideos.com/212120745294215. html http://www.zippyvideos.com/212120745294215. html http://www.zippyvideos.com/212120745294215. html  Thief 3 video - http://media.pc.ign.com/media/015/015244/vids _4.html  BSOD image - www.palindrom.agava.ru/en.intro.bsod.html


Download ppt "Ch 7.1: Using a Spatial Database for Runtime Spatial Analysis."

Similar presentations


Ads by Google