1 artificial intelligence in games class 6 steve rabin [email protected]

67
1 Artificial Intelligence in Games Class 6 Steve Rabin [email protected] www.aiwisdom.com/uw

Upload: margaret-dixon

Post on 17-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

1

Artificial Intelligence in GamesClass 6

Steve [email protected]/uw

Page 2: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

2

Pathfinding Project Any issues? Due next week

Port A* to your own game Requirement (100%)

Service path requests one at a time (FIFO) Have agents show their final path with

lines/arrows Bonus (+100%)

Show the open and closed list in different colors Have a toggle button to watch search step-by-

step

Page 3: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

3

Reading Assignmentfor Next Week Chapter 6

6.1 Waypoint Tactics 6.2 Tactical Analyses 6.3 Tactical Pathfinding 6.4 Coordinated Action

Page 4: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

4

Game Agents

Page 5: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

5

Game Agents May act as an

Opponent Ally Neutral character

Continually loops through the Sense-Think-Act cycle Optional learning or remembering

step

Page 6: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

6

Sense-Think-Act Cycle:Sensing

Agent can have access to perfect information of the game world May be expensive/difficult to tease out

useful info Game World Information

Complete terrain layout Location and state of every game object Location and state of player

But isn’t this cheating???

Page 7: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

7

Sensing:Enforcing Limitations Human limitations? Limitations such as

Not knowing about unexplored areas Not seeing through walls Not knowing location or state of

player Can only know about things seen,

heard, or told about Must create a sensing model

Page 8: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

8

Sensing: Human Vision Model for Agents How should we model agent

vision?

Page 9: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

9

Sensing: Human Vision Model for Agents Get a list of all objects or agents; for each:

1. Is it within the viewing distance of the agent? How far can the agent see? What does the code look like?

2. Is it within the viewing angle of the agent? What is the agent’s viewing angle? What does the code look like?

3. Is it unobscured by the environment? Most expensive test, so it is purposely last What does the code look like?

Page 10: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

10

Sensing: Human Vision Model for Agents

Enemy

Player

View Distance

Wall

Page 11: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

11

Sensing: Human Vision Model for Agents Is it within the viewing angle of the

agent?

90°

45°

60°

30°Viewing Angle

Page 12: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

12

Sensing: Human Vision Model for Agents Is it within the viewing angle of the

agent?

0.0

0.707

0.5

0.866

90°

45°

60°

30°Dot ProductViewing Angle

Page 13: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

13

Sensing: Human Vision Model for Agents Is it unobscured by the

environment? How would you do this better? How would you do this perfect?

Page 14: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

14

Sensing: Human Vision Model for Agents

Page 15: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

15

Sensing: Human Vision Model for Agents

Page 16: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

16

Sensing: Human Vision Model for Agents

Page 17: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

17

Sensing: Human Vision Model for Agents

Page 18: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

18

Sensing: Human Vision Model for Agents

Page 19: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

19

Sensing: Human Vision Model for Agents

Page 20: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

20

Sensing: Human Vision Model for Agents

Page 21: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

21

Sensing: Human Vision Model for Agents

Page 22: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

22

Sensing: Human Vision Model for Agents

Page 23: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

23

Sensing: Human Vision Model for Agents

Page 24: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

24

Sensing: Human Vision Model for Agents

Page 25: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

25

Sensing: Human Vision Model for Agents

Page 26: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

26

DigiPen Vision Demo

Page 27: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

27

Sensing: Human Vision Model for Agents Let's get more real

Hard to see camouflaged objects Hard to see non-moving characters Hard to identify peripheral objects Hard to identify far away objects Vision should be based on head

direction, not body direction

Page 28: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

28

Sensing:Vision Model Isn’t vision more than just detecting

the existence of objects?

What about recognizing interesting terrain features? What would be interesting to an agent?

Demo!

Page 29: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

29

Sensing:Human Hearing Model Humans can hear sounds

Can recognize sounds Knows what emits each sound

Can sense volume Indicates distance of sound

Can sense pitch Sounds muffled through walls have more

bass Can sense location

Where sound is coming from

Page 30: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

30

Sensing:Modeling Hearing How do you model hearing

efficiently? Do you model how sounds reflect off

every surface? How should an agent know about

sounds?

Page 31: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

31

Sensing:Modeling Hearing Efficiently Event-based approach

When sound is emitted, it alerts interested agents

Use distance and zones to determine how far sound can travel

Page 32: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

32

Sensing:Modeling Hearing Efficiently

Page 33: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

33

Sensing:Communication Agents might talk amongst

themselves! Guards might alert other guards Agents witness player location and

spread the word Model sensed knowledge through

communication Event-driven when agents within

vicinity of each other

Page 34: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

34

Sensing: Player Reputation (Gunslinger) Chapter 8.6 – A Dynamic

Reputation System Based on Event Knowledge

Bandit

M e m o ry E le m e n t

1

2

3

5

R e p u t a t i o n Tab l e

G r o u p R e p u t a t i o n

Farm e rs N e utral

Lawm e n H ate

B andits L ike

P laye r H ate

To wnspe o ple N e utral

P e r - N P C M e m o r y

M as t e r E ve n t L i s t

1 . B andit K ille d Farm e r

2 . P laye r Aide d Lawm an

3 . P laye r K ille d B andit

4 . P laye r Trade dW ith To wnspe rso n

5 . [...]

Page 35: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

35

Sensing: Player Reputation –Reputation Event

Subject Group Player

Verb DidViolenceTo

Object Group Bandit

Object Individual Joe

Magnitude 75 (Killed)

Where 50, 20, 138 (In front of Saloon)

When High noon

Template KilledBanditTemplate

Reference Count Known by 11 NPCs

Reputation Effects Bandits hate player more.Lawmen like player more.Farmers like player more.

Page 36: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

36

Sensing: Player Reputation in Fable Five opinion values are in range [-

1,1] Morality [Evil, Good] Renown [Contemptible, Renowned] Scariness [Ridiculous, Scary] Agreeableness [Offensive, Agreeable] Attractiveness [Ugly, Attractive]

Page 37: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

37

Sensing: Player Reputation in Fable Player has hero stats of 5 opinion

values Player can check at any time Player has sense of self Unobserved acts have an affect on villagers

Each NPC has a relative opinion Only directly witnessed acts or overheard

acts Absolute opinion = hero stats + relative

opinion

Page 38: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

38

Sensing: Player Reputation in Fable Event-driven opinion deeds are

posted (like Greg Alt’s article) DEED_CRIME_WEAPON_OUT DEED_CRIME_VANDALISM DEED_EXPRESSION_HEROIC_STANCE DEED_EXPRESSION_FLIRT DEED_RECEIVE_GIFT_ROMANTIC DEED_RECEIVE_GIFT_FRIENDLY ...

Page 39: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

39

Sensing:Reaction Times Agents shouldn’t see,

hear, communicate instantaneously

Players notice! Build in artificial reaction

times Vision: ¼ to ½ second Hearing: ¼ to ½ second Communication: > 2

seconds

Page 40: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

40

Sense-Think-Act Cycle:Thinking Sensed information gathered Must process sensed information Two primary methods

Process using pre-coded expert knowledge

Use search to find an optimal solution

Page 41: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

41

Thinking:Expert Knowledge

Many different systems Finite-state machines Production systems Decision trees Logical inference

Encoding expert knowledge is appealing because it’s relatively easy Can ask just the right questions As simple as if-then statements

Problems with expert knowledge Not very scalable

Page 42: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

42

Thinking:Search Employs search algorithm to find

an optimal or near-optimal solution A* pathfinding common use of

search

Page 43: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

43

Thinking:Machine Learning If imparting expert knowledge and

search are both not reasonable/possible, then machine learning might work

Examples: Reinforcement learning Neural networks Decision tree learning

Not often used by game developers Why?

Page 44: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

44

Thinking:Flip-Flopping Decisions Must prevent flip-flopping of

decisions Reaction times might help keep it

from happening every frame Must make a decision and stick with

it Until situation changes enough Until enough time has passed Baseball example

Page 45: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

45

Sense-Think-Act Cycle:Acting Sensing and thinking steps invisible to

player Acting is how player witnesses

intelligence Numerous agent actions, for example:

Change locations Pick up object Play animation Play sound effect Converse with player Fire weapon

Page 46: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

46

Acting:Showing Intelligence Adeptness and subtlety of actions

impact perceived level of intelligence Enormous burden on asset generation Agent can only express intelligence in

terms of vocabulary of actions Current games have huge sets of

animations/assets Must use scalable solutions to make

selections

Page 47: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

47

Extra Step in Cycle:Learning and Remembering Optional 4th step Not necessary in many games

Agents don’t live long enough Game design might not desire it

Page 48: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

48

Learning Remembering outcomes and

generalizing to future situations Simplest approach: gather

statistics If 80% of time player attacks from left Then expect this likely event

Adapts to player behavior

Page 49: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

49

Remembering Remember hard facts

Observed states, objects, or players For example

Where was the player last seen? What weapon did the player have? Where did I last see a health pack?

Memories should fade Helps keep memory requirements lower Simulates poor, imprecise, selective human

memory

Page 50: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

50

Remembering within the World All memory doesn’t need to be stored

in the agent – can be stored in the world

For example: Agents get slaughtered in a certain area Area might begin to “smell of death” Agent’s path planning will avoid the area Simulates group memory

Page 51: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

51

Game AgentCooperation

Page 52: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

52

Game Agent Cooperation How might agents cooperate?

With one other NPC? In a mob "kung-fu" style? In a squad? On a baseball team? As part of a 5000 person invasion?

Page 53: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

53

Game Agent Cooperation Three interesting methods

1. Individuals communicate and arbitrate between themselves

2. Invisible manager coordinates3. Blackboard architecture

Page 54: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

54

Individual Communication Scalability problem Requires handshaking and

arbitration Can you imagine doing this with

SendMsg and OnMsg? What is necessary for optimal

cooperation?

Page 55: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

55

Manager Cooperation Agent assignment

Get list of agents Assign each agent a task

Task assignment Compose list of tasks Prioritize Assign tasks to best candidate

Playbook cooperation Preplanned assignments based on situation

Exhaustive analysis Some permutation of tasks/agents is optimal

Score each permutation and pick best

Page 56: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

56

Blackboard Architecture Complex problem is posted on

a shared communication space Agents propose solutions Solutions scored and selected Continues until problem is solved

Alternatively, use concept to facilitate communication and cooperation

Page 57: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

57

Blackboard Architecture ExampleUnits compete for missions on blackboard

Skill Required Priority Data

Mission 1:

Capacity

Skill Required Priority Data

Mission 2:

Capacity

Skill Required Priority Data

Mission n:

Capacity

Skill Proficiency

Skill Proficiency

Skill Proficiency

Unit 1

Skill Proficiency

Skill Proficiency

Skill Proficiency

Unit 2

Skill Proficiency

Skill Proficiency

Skill Proficiency

Unit n

Arbitration Mechanism

Page 58: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

58

“Blackboard” for Pathfinding

1

1 1

1

1A

B

E

1

1 1

1A

B

E

50

Reserved

(A) (B)

Page 59: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

Extra

59

Page 60: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

60

Fun Exercise:

You'll need a piece of paper...

Page 61: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

61

Geek Logik(The Book)

Page 62: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

62

Geek Logik: Should you go to the doctor? (p88)

CP

D

ENES

703100

23

3

Page 63: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

63

Geek Logik: Do you have a snowball's chance in hell with her? (p12)

R

K

EESS

CC

A

AWG hyhy

h

y

100

3

2

Page 64: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

64

Geek Logik: Is your personal grooming adequate? (p98)

RSFP

EA

G a

1125

25214225

212

Page 65: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

65

Geek Logik: Should you join a gym? (p100)

10

1DCFS

TM

FS

Page 66: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

66

Geek Logik: Vote for One (In-Class Exercise)

1. Should you go to the doctor?

2. Do you have a snowball's chance in hell with her?

3. Is your personal grooming adequate?

4. Should you join a gym?

Page 67: 1 Artificial Intelligence in Games Class 6 Steve Rabin steve.rabin@gmail.com

67

Questions?