artificial intelligence in game design terrain analysis

18
Artificial Intelligence in Game Design Terrain Analysis

Upload: solomon-logan

Post on 02-Jan-2016

229 views

Category:

Documents


0 download

TRANSCRIPT

Artificial Intelligence in Game Design

Terrain Analysis

Terrain Analysis

• Features of terrain have good/bad influence over map areas– Good locations Possible goals to move to– Bad locations Places to avoid when moving

High ground = good

Open space = bad

Slow to travel through = bad

Cover = good

Terrain Analysis

• Must be based on realistic estimates of how terrain affects play

• Game engine based – Example: Engine reduces hit probability by

50% when target > 100 feet above– Factor into NPC deciding to move to high

ground– Most likely for “overhead perspective”

combat games

• Visibility based– Relevant for FPS games– Example: NPCs in shadow not visible to

player– NPC should move to such areas

Terrain Analysis

• “Dangerous” terrain elements– Things that can damage

character

• Terrain that might expose character to attack– Areas that force character to

move slowly

– Areas where character has chance of getting stuck

– Often related to edge costs, but not always

• Some slow terrain offers cover• Forrest, darkness, etc.

GASOLINE

GASOLINE

Terrain Example

-1 -2 -2 -2 -1

-1 -2 -3 -2 -1

-1 -1 -1 -1 -2 -2 -2 -1

-1 -2 -1 -1 -1 -1 -1 -1

-1 -1 -1

-2 -2 -2 -2 -2 -2 -2 -2 -2

-2 -2 -2 -2 -2 -2 -2 -2 -2

-2 -2 -2 -2 -2 -2 -2 -2 -2

Terrain and Influence

• Areas have influence over other areas• Examples:

– High ground

– Shadow

– Cover

Influence over

Influence over

Influence over

Influence over

Levels of Influence

• Amount of influence may depend on relative values between areas

• Influence of area i over area j for some property P = f (P(i), P(j))– May be simple difference k × (P(i) – P(j))

Example: height(i ) = 50 height(j ) = 10 k = 0.2 Influence_Strength (i, j ) = 8

– Must be based on how game engine defines advantage of area i over area j

High influence over

Low influence over

Influence and Distance

• Usual assumption: Influence of terrain decreases with distance– Linear dropoff out to some “range” R– Influence_Strength (i, j ) treated like “strength”– Given distance D (i, j ) –

Influence (i, j ) = Influence_Strength (i, j ) × (R – D(i, j ) )/R

0 1 2 3 41234 55

Influence over other areas 40 feet below this one at distances 1 - 4 Influence over area 3 units

away and 40 feet lower = 2.0

Influence Example

BHeight = 50

CHeight = 20

AHeight = 40 D

Height = 30

Influence Over

A B C D

A - - 20 * 0.2 * 0.5 = 2.0

10 * 0.2 * 0.25 = 0.5

B 10 * 0.2 * 0.75 = 1.5

- 30 * 0.2 * 0.75 = 4.5

20 * 0.2 * 0.5 = 2.0

C - - - -

D - - 10 * 0.2 * 0.75 = 1.5

-

Total Influence

BHeight = 50

CHeight = 20

AHeight = 40 D

Height = 30

• Influence over others – influence others have over it• Total influence of area i = Σ influcence (i, j) – Σ influcence (j, i)

j j

Total Influence

A B C D

2.0 + 0.5 – 1.5 = 1.0

1.5 + 4.5 + 2.0 = 8.0

-2.0 - 4.5 - 1.5 = -8.0

1.5 - 0.5 - 2.0 = -1.0

Combined Influences

• Total influence may involve many factors– A is lower ground than B

– A has cover while B does not

– Influence of cover = 4.0

• Influence of B over A from height = 1.5• Influence of A over B from cover = 4• A has total influence over B of 2.5

BHeight = 50A

Height = 40

Combined Influences

• Must also factor in unit-based influence maps– Good location controlled by enemy is bad place to move to!

• Example:• Influence of B over D from height = 2.0• Influence of D over B from cannon = 3.0• Total influence of D over B = 1.0

– B no longer a good place to move to!• May not know that until you move there!

BHeight = 50

CHeight = 20

DHeight = 30

Map Analysis

• Complex analysis of crucial map areas– Crucial for randomly generated terrain– Example: Leaders: Clash of Nations

• Goals:– Identify chokepoints between different game zones– Identify hotspots that have influence over chokepoints

Map Analysis

• Smoothing (image analysis) used to remove small areas of impassible objects– Area around impassible tile T passible T removed from

analysis

Map Analysis

• Random path generation often used

– For large number of examples:• Select two random waypoints• Use Dijkstra/A* to find shortest path between them• Keep track of waypoints on path• Store waypoints, path for each

– Waypoints with large number of paths are candidate chokepoints

Map Analysis

• Verify chokepoints– For each candidate chokepoint

rerun tests that passed through it

– If resulting paths significantly longer (or infinite!) chokepoint confirmed

Tactical Waypoints in Dungeons

• More difficult for dungeon world– Tile centers may not give all good tactical locations

Best tactical location based on cover

Best tactical location based on shadow

Tactical Waypoints in Dungeons

• Automatic creation– Subdivide area into smaller tiles– Find tiles with highest influences over other tiles– Create new waypoints there– Computationally intensive, but only need to do once

Influence over other points, few points with influence over it