influence maps

111
Lecture 17 – Influence Maps CSci 4511 – Intro to AI 3.21.11 baylor University of Minnesota

Upload: dung

Post on 14-Dec-2015

17 views

Category:

Documents


5 download

DESCRIPTION

Artificial intelligent, influence maps, machine learning, game theory,

TRANSCRIPT

Page 1: Influence Maps

Lecture 17 – Influence Maps

CSci 4511 – Intro to AI3.21.11baylor

University of Minnesota

Page 2: Influence Maps

We begin our story with a bunch of problems…

Page 3: Influence Maps

Terrain Reasoning

• Old fashioned war• Strategies:

– Strengthen front– Attack flank

• Pincer– Ambush rear

Page 4: Influence Maps

Terrain Reasoning

• Old fashioned war• Strategies:

– Strengthen front– Attack flank

• Pincer– Ambush rear

• But where are those?

Page 5: Influence Maps

Problem 1. Finding Flanks

• Old fashioned war• Strategies:

– Strengthen front– Attack flank

• Pincer– Ambush rear

• But where are those?

Group units close to each other

Page 6: Influence Maps

Problem 1. Finding Flanks (contd.)

• Old fashioned war• Strategies:

– Strengthen front– Attack flank

• Pincer– Ambush rear

• But where are those?

Draw line through cores(so can tell who’s behind or side)

Page 7: Influence Maps

Problem 1. Finding Flanks (contd.)

• Old fashioned war• Strategies:

– Strengthen front– Attack flank

• Pincer– Ambush rear

• But where are those?

Perpendicular line is the FrontSides = Flanks, Behind = Rear

Flank

Flank

Rear

Fron

t

Page 8: Influence Maps

Problem 1. Finding Flanks (contd.)

• Old fashioned war• Strategies:

– Strengthen front– Attack flank

• Pincer– Ambush rear

• But where are those?

How do we make a computer understand that?

Flank

Flank

Rear

Fron

t

Page 9: Influence Maps

MOUT• Don’t get to play tanks and trenches much

anymore– Stupid nuclear bombs

• MOUT – Military Operation in Urban Terrain– Cities– Filled with hiding spots– And civilians

• And enemies who look like civilians• We care because of the CNN effect. And stuff

• Modern training is for individual combat, non-lethal combat, checkpoints, etc

Page 10: Influence Maps

Problem 2. City Defense

building,1 door,2 windows

wall,2m / 7ft

wall,1m / 3ft

deepwater

bridge w.1m / 3ft walls

stairs,from water

?Where do we put:• Snipers• Sentries• Sentry guns• Heavy weapons• Traps• Ambush

Image courtesy of William van der Sterren

Page 11: Influence Maps

Problem 2. City Defense

building,1 door,2 windows

wall,2m / 7ft

wall,1m / 3ft

deepwater

bridge w.1m / 3ft walls

stairs,from water

?

Sniperlong range view,enclosed space,

Checkpointchokepoint

Bad for Sniperlong range view but exposed

We can see this but how can a computer “see” it?

Page 12: Influence Maps

Terrain Reasoning

• These problems are instances of terrain reasoning

• Computers can’t “see”– Sees raw data, not groupings, relationships– Humans very good at this

• Understanding the space is important

Page 13: Influence Maps

Problem 3. Path Finding

Plenty of algorithms for finding paths…

Page 14: Influence Maps

Path Finding (contd.)

• Plenty of things should influence path• Some are semi-permanent

– Terrain type– Light (for games where you sneak around)– Sound (ditto)

• Some are dynamic– Enemies– Buildable/destroyable walls (RTSes, Tower Defense,

Red Faction)– Fog of War– Treasure– Mobile Targets (e.g., ball in soccer)

Page 15: Influence Maps

Problem 3. Path Finding

Plenty of algorithms for finding paths…But they don’t take into account things like risk

Page 16: Influence Maps
Page 17: Influence Maps

Building

• Several game types require building– Most obviously Real Time Strategies (RTSes)

• Factors– Place walls where they safeguard the most /

most important items– Place buildings near defense– Place buildings near resources

Page 18: Influence Maps

Placing farms near each other make them easier to defendwith walls, nearby troops

Problem 4. Building location

Page 19: Influence Maps

Building

• Several game types require building– Most obviously Real Time Strategies (RTSes)

• Factors– Place walls where they safeguard the most /

most important items– Place buildings near defense– Place buildings near resources

• Also, Area of Effect (AoE) attacks

Page 20: Influence Maps

Placing farms near each other make them easier to defendwith walls, nearby troops

…but also make themmore vulnerable toAoE attacks

Problem 5. Bomb placement

Page 21: Influence Maps

Building (contd.)

• Lots of games need to be able to place things in a good place– So they need to understand their environment

• Includes types that haven’t been made yet– Urban renewal games– Lemonade stands– Parties (e.g., Hello Kitty Party Pals)– Shopping games (PaperDoll Tower Defense)– Synergy games

• Clownfish & Anemones, Cinnabon & Weight Watchers

Page 22: Influence Maps

6. Ever-Popular Real Estate Game!

• We want to build a house

• Close to roads good• Elves are good, but

not too close• Don’t build near

haunted castles

Where should we build?

Page 23: Influence Maps

How Do We Solve These?

Page 24: Influence Maps

7. One More Example…

• Should we attack that army?

Us

Them

Lots more ofThem

Page 25: Influence Maps

Attenuated Threat Radius

• Assume each unit is worth a certain amount (danger/attack strength)

• Each has a “threat radius”– Represents reach of unit (if ranged)– Also spots unit can reach quickly

• Threat drops off with distance

Note fancy big words!

Page 26: Influence Maps

Red TankBase Value: 10Propagation Divisor: 2Propagation Distance: 3

Page 27: Influence Maps

7. One More Example…

• Add unit values to map, Sum values

Us

Them

Lots more ofThem

Page 28: Influence Maps

7. One More Example…

• Should we attack that army?

Us

Them

Lots more ofThem

One ofours

Page 29: Influence Maps

7. One More Example…

• Quantitative representation– Computer can

reason with this• Computationally

simple and fast– Just adds and

multiplies– Linear growth in

computation time

Page 30: Influence Maps

8. Reminder: Go is Hard

• 10761 games– vs. 1040 vs. 10120

• Champion: Not Yet• Brute Force does

not scale very well

for computers

Page 31: Influence Maps

Influence Maps

• Created in 1969 by Albert Zobrist– Computers didn’t “understand” spatial patterns

• This capability is important to human problem solving

– Looking to capture human-like “visual organization”• Divide the world into a grid• Each piece adds a number to the grid• Values “flow” through the grid

– Like oil/water (borders) or electric charge (intensity)• Add it all up and you understand the world

– Note: You still have to decide how to use the info

Page 32: Influence Maps

Multiple Maps• Can have more than one type of influence

– Represent different concerns / factors– Can use all of them at the same time

• Sum across influence types / maps• Can select relevant maps at run time

– Can be specific to goal, agent, state, personality, etc.• All started with Go

– Goals: Pieces grouped into armies, influence of armies, segmentation of board

– Maps: Borders, # empty squares in segment (safety), breathing spaces in chain, # stones in chain, # neighbors

Zobrist, A. L., "A model of visual organization for the game of GO," AFIPS Conf. Proc., 1969

Page 33: Influence Maps

Anything You Want

In GO• Influence• Concentration• Tension• Instability

For an RTS• Borders• Resources• Defensibility• Line of fire• Fog of war

Page 34: Influence Maps

Types of Influence Maps• Passability• Resources• Exploration• Threat• Light level• Historical• Emotion (fear, beauty, etc.)• Anything you make up• Desirability Map

– Summation of the above

Page 35: Influence Maps

Light Map, Action Quake 2

Page 36: Influence Maps

Propagation• Can propagate however you want

– Predefined actor halo, rules– Auto-propagation - linear, exponential, Gaussian, etc.

• Can have different “conductance” for each tile– Walls or mountains could block– Roads or supply lines might spread influence more

Page 37: Influence Maps

Roadsspreadinfluence

Lakesblock it(for tanks)

Page 38: Influence Maps

Problems Revisited

Page 39: Influence Maps

6. Ever-Popular Real Estate Game!

Elf

Evil Castle

Road that looks like water

Page 40: Influence Maps

Place A Grid Over The Map

Page 41: Influence Maps

Convert Map Into Something Easy For Us To Reason With

O O O O OO O

O O O

O O O OO

R R RR

RR

RE

XO

Page 42: Influence Maps

Convert Grid To Numbers

1 1 1

1

1 1

1

0 0 0 0 0

00

0000

0

00

00

0 0

Normal land is worth 0Road is worth 1

Page 43: Influence Maps

Live close to elves, but not too close

1

-1-1

-1

-1-1

1100

1

1

1

11

00

0 0

00

100

Page 44: Influence Maps

Stay away from evil castles

-2-2

-2

-2 -2

-2

-2

-2

-1 -1 -1 -1

-1

-1

-1

0 0 0 0 0

0

0

0

0

Page 45: Influence Maps

Each Object Affects The Area Around It

-2-2

-2

-2 -2

-2

-2

-2

-1 -1 -1 -1

-1

-1

-1

0 0 0 0 0

0

0

0

0

Squares next to castle worth -2

Squares next to those squares worth -1

Page 46: Influence Maps

Add The Values Together

0 0

0 0

0 0

0

1 1 1

1 -2 -1

-2 -2 -1 -1

-2

-2 -2 -1 2

-2

Page 47: Influence Maps

We Build At The Highest Number0 0

0 0

0 0

0

1 1 1

1 -2 -1

-2 -2 -1 -1

-2

-2 -2 -1 2

-2Right here

Page 48: Influence Maps

We Build At The Highest Number

Right here

Page 49: Influence Maps

Placing farms near each other make them easier to defendwith walls, nearby troops

…but also make themmore vulnerable toAoE attacks

Problem 5. Bomb placementProblem 4. Building location

Page 50: Influence Maps

Shortest distance doesn’t use cover, good way to get shot

A* runs a lot faster when you do it this way

Problem 3. Path Finding

Page 51: Influence Maps

Waypoints are marked as being visible to the enemy, factors into the node cost

A lot more work for A*

Note: Color, like danger, fades with distance

Page 52: Influence Maps

Problem 1. Finding Flanks

• Old fashioned war• Strategies:

– Strengthen front– Attack flank

• Pincer– Ambush rear

How a human sees the situation

Flank

Flank

Rear

Fron

t

Page 53: Influence Maps
Page 54: Influence Maps

0 = border / no man’s land

Page 55: Influence Maps

Ferretman, AI Game Programming Wisdom volume 1

Page 56: Influence Maps

Problem 2. City Defense

building,1 door,2 windows

wall,2m / 7ft

wall,1m / 3ft

deepwater

bridge w.1m / 3ft walls

stairs,from water

?

Sniperlong range view,enclosed space,

Checkpointchokepoint

Bad for Sniperlong range view but exposed

We can see this but how can a computer “see” it?

Page 57: Influence Maps
Page 58: Influence Maps
Page 59: Influence Maps

What Makes A Good Sniping Spot?• Inconspicuous• Overlooking distant locations• Overlooking key locations• Target locations lack cover• Hard to reach from target locations• Nearby cover for sniper• Hard to surprise• Flank protected• Have freedom of movement• “Focus”

Page 60: Influence Maps

Data We Need

• Line of sight• Travel time from one point to another• Distance from one point to another• Which part of area do we belong to

– Are we in a specific room, courtyard, etc.

Page 61: Influence Maps

Waypoint relations• (potential) “interaction” or influence

between two waypoints• directional, leveled [0..1]

Examples• nearby cover from threat• hard to reach from target• overlooking key locations• hard to surprise

Case: Tactical Assessment

Page 62: Influence Maps

0

0.5

1

1.5

0 100 200

Relation: nearby cover from threat• the amount of nearby cover

from threat and nearby positions

Case: Tactical Assessment

0.0

0.5

1.0

weapon performance

protection

2/9 = 0.22

Page 63: Influence Maps

Case: Tactical Assessment

nearbycoverfromseen threatseast ofposition

Page 64: Influence Maps

Focus• concentration of relations in certain

direction (sphere sector)–If long LoS in one direction but

not another, focus is high–If long LoS in all directions, no focus

• Useful for determining flank protection

Case: Tactical Assessment

Page 65: Influence Maps

No focus

Partial focus (blocked 3 directions, open 3 directions)

Page 66: Influence Maps

Case: Tactical Assessment

focuseast(E,NE,SE, Eup, Edown)

Page 67: Influence Maps

Case: Tactical Assessment

localproperty:light level

Page 68: Influence Maps

Terrain Characteristics Used

Page 69: Influence Maps

• William’s formula for CGF for AQ2– 17 ingredients– Checks in 26 directions

• Specifics for this example (map)– 480 waypoints– 10 seconds to calculate on a PIII/500

• Done off-line– 24KB of sniping ratings

Technical Notes (so far)

Page 70: Influence Maps

Making Your Own Formula

• How William created the CGF for AQ2 formula– 10% Analysis – 40% Experimenting– 50% Tuning

Page 71: Influence Maps

• Store Sniping behavior at each waypoint– Time spent sniping

• Time spent at location• Time spent zoomed in• Shots fired

– Damage done while sniping– Damage taken while sniping

• Breakdown by– Sniping spot– Weapon used– Direction faced

Adding History

Page 72: Influence Maps

Case: Tactical Assessment

positivesnipingexperience,after40 rounds,non-directional

Page 73: Influence Maps

Case: Tactical Assessment

snipingeast,usinggeometry+ physics+ learning

Page 74: Influence Maps

Case: Tactical Assessment

trafficdata (all teams)after40 rounds

Page 75: Influence Maps

Case: Tactical Assessment

snipingeast,usinggeometry+ physics+ learning+ tactical

game playanalysis

Page 76: Influence Maps

waypoints

line of sight / fire

level design terrain analysis game round analyse activity + rerank locationsgame round

game round

paths + travel time

sniper spotanalysis [~20 s]

sniperactivity

snipingratings

sniping activitytracking [ 0.0s]

reinforcementlearning [0.1s]

traffic +kills ...

sniperactivityphysics

Results

Case: Tactical Assessment

Page 77: Influence Maps

Bonus Problems!

Page 78: Influence Maps

9. Track and Predict

• Target runs behind something and now we can’t see him

• Want to predict where he’s going to pop out

Page 79: Influence Maps

9. Track and Predict

house

window

AI actor

threat

door

Situation (top view)

Slides stolen directly from William

Page 80: Influence Maps

?

?

9. Track and Predict

Where to look for the threat? What to aim for?

Page 81: Influence Maps

!?

9. Track and Predict

Option: assume threat static after moving out of sight(often incorrect)

Page 82: Influence Maps

!?

9. Track and Predict

Option: assume threat continues last observed movement(incorrect after a little while)

Page 83: Influence Maps

The waypoint grid(overlay)

9. Track and Predict

Page 84: Influence Maps

The waypoint grid(AI “view”)

9. Track and Predict

Page 85: Influence Maps

Extrapolate movement along waypoints(valid paths, movement speed known).

Threat no longer “leaves” the house!

9. Track and Predict

Page 86: Influence Maps

Use known line-of-sight for “negative”observations.Exclude some likely threat movements.

9. Track and Predict

Page 87: Influence Maps

9. Track and Predict• How can we use the waypoint graph?

– Restrict guesses to valid movements– Estimate the threats’ movement speed– Exclude visible potential movements

that were not observed

• Predict a likely path– Path best aligned with last observed direction– Using per waypoint traffic statistics– Towards most attractive nearby objective– Towards strongest defensive position

• WWiD (unrelated to terrain reasoning)– Could ask “what would i do in their situation?”

Page 88: Influence Maps

9. Track and Predict

Where to aim?• Where you think the threat will likely reappear

Good guesses• Visible spot closest to threat• First visible spot on predicted path• If you think he’s coming back for you…

– First visible spot on shortest path back to you• Any nearby portal (door, window, hole, ...)

Page 89: Influence Maps

1

2

3

Threat turns to attack (1) or moves to nearest attack position (2), or continues movement (3)

9. Track and Predict

Page 90: Influence Maps

10. Grenade Handling

• Can’t (or don’t want to) shoot at enemies? Throw grenades!

• Best part – grenades bounce!• Humans good at this, AI bad• You do not want to compute this at run-time

– If you’re going to rebound, there are sooomany places you can throw

– Physics are imprecise so you gotta Monaco it• Precompute, store results in terrain map

– Mark the good spots in your map

Page 91: Influence Maps
Page 92: Influence Maps
Page 93: Influence Maps
Page 94: Influence Maps

Information to track to determine value of spot as a grenade tossing spot

AI is much easier with good debugging tools

Page 95: Influence Maps

Have no direct shot at enemy. But we could throw a grenade from the green spot

Page 96: Influence Maps

We know we can hit this because we pre-computed it long before the game began

Page 97: Influence Maps

Hey, how’d he do that?

Page 98: Influence Maps

Grenades: A Warning

• To throw grenades, need to know– Where to stand– Point to aim at

• Grenades and other bouncy things require you to be very precise– Clean ray trace is not good enough

• If you are just a little off, very bad things can happen

Page 99: Influence Maps

It’s very important to be very precise. Or very bad things could happen

good

bad

oops, we clipped the wall

Page 100: Influence Maps

11. Team Maneuvers

• Choosing an avenue of approach• Bounding overwatch

– One person moves, the other covers him• Keeping clear lines of fire• Keeping to cover• Flanking

Page 101: Influence Maps

11. Team Maneuver

how toattack thethreats asa team?

1

23

Page 102: Influence Maps

11. Team Maneuver

Approach• Initially, sequentially for each member

– evaluate nearby waypoints (within r ) for position improvement

– claim best position p– move up

to position p• Repeat on

memberinitiative

Page 103: Influence Maps

Things To Evaluate For Each Waypoint

• Travel time to / from threat, power-up, ...• Nearby cover and flank protection• Tactical rating of position• Min projected distance to team member

– Spread out a bit• Keep out of friendly line-of-fire• Maintain visual contact with enemy

Page 104: Influence Maps

11. Team Maneuver

how toattack thethreats asa team?

1

23

Page 105: Influence Maps

11. Team Maneuver

evaluate foreach waypoint:-distance to

threat-spread-nearby cover-not claimed-etc.

and claimbest position…

1

23

Page 106: Influence Maps

11. Team Maneuver

member1claims positionand will move up

1

23

Page 107: Influence Maps

11. Team Maneuver

member2evaluatesand picksbest positiongivenexisting andclaimedpositions

12

3

Page 108: Influence Maps

11. Team Maneuver

same formember3

however, inthe search radius, thebest spotmight not bethat good(LOF blocked)…

12

3

Page 109: Influence Maps

11. Team Maneuver

upon arrival,member3indeed seesa blockedline-of-fire

he quicklyexecutesthe sameprocedurefrom hisnew spot…

!#%&!12

3

Page 110: Influence Maps

11. Team Maneuver

now member3moves upagain toa good position…

in an obstaclerich environment,you’ll get flankingfor free…

12

3

Page 111: Influence Maps

Questions?