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 world Analyze world and build a data structure Dynamic 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: Openness Area occupancy Area search Line-of-fire Light level

6 Use of Spatial Database
Combine multiple layers to compute composite desirability values AI examines nearby cells, moves accordingly Implicitly 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 1 0.2 1 0.2 0.4 1 0.2 0.4 0.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 Updating certain areas constantly is a waste of time/memory
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

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 - Thief 3 video - BSOD image -


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

Similar presentations


Ads by Google