intro to ai strips planning & applications in video-games lecture2-part1

47
INTRODUCTION TO AI STRIPS PLANNING .. and Applications to Video-games! May 2012 Stavros Vassos, University of Athens, Greece [email protected]

Upload: stavros-vassos

Post on 25-Jun-2015

341 views

Category:

Technology


1 download

DESCRIPTION

This is a short course that aims to provide an introduction to the techniques currently used for the decision making of non-player characters (NPCs) in commercial video games, and show how a simple deliberation technique from academic artificial intelligence research can be employed to advance the state-of-the art. For more information and downloading the supplementary material please use the following links: http://stavros.lostre.org/2012/05/19/video-games-sapienza-roma-2012/ http://tinyurl.com/AI-NPC-LaSapienza

TRANSCRIPT

Page 1: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

INTRODUCTION TO AI

STRIPS PLANNING

.. and Applications to Video-games!

May 2012Stavros Vassos, University of Athens, Greece [email protected]

Page 2: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

2

Lecture 1: Game-inspired competitions for AI research,

AI decision making for non-player characters in games

Lecture 2: STRIPS planning, state-space search

Lecture 3: Planning Domain Definition Language (PDDL),

using an award winning planner to solve Sokoban

Lecture 4: Planning graphs, domain independent

heuristics for STRIPS planning

Lecture 5: Employing STRIPS planning in games:

SimpleFPS, iThinkUnity3D, SmartWorkersRTS

Lecture 6: Planning beyond STRIPS

Course overview

Page 3: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

Goal Oriented Action Planning (GOAP)3

Video Games:

Finite State Machines

Decision Diagrams

Behavior Trees

Goal Oriented Action Planning

Academic AI on agents:

Knowledge representation, First-order logic,

Classical planning, Planning with preferences, …

Belief-Desire-Intention architecture, Agent-based

programming, …

Probabilistic reasoning, Bayesian networks,

Utility theory, Markov Decision Processes, …

Page 4: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

Goal Oriented Action Planning (GOAP)4

Search for a plan that achieves the goal in the current

state

Move

into room

Move

to door

Unlock

door

Kick

door

Preconditions: Door open

Effects: In room

Preconditions: -

Effects: At door

Preconditions: Hold key

Effects: Door open

Preconditions: -

Effects: Door open

In room

Page 5: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

Goal Oriented Action Planning (GOAP)5

Search for a plan that achieves the goal in the current

state

There is a standard formalism for representing such

problems in AI literature and a large body of work!

Video-games: The best strategy is to use the existing

formalism and take advantage of the work in the

literature

Page 6: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

6

Lecture 1: Game-inspired competitions for AI research,

AI decision making for non-player characters in games

Lecture 2: STRIPS planning, state-space search

Lecture 3: Planning Domain Definition Language (PDDL),

using an award winning planner to solve Sokoban

Lecture 4: Planning graphs, domain independent

heuristics for STRIPS planning

Lecture 5: Employing STRIPS planning in games:

SimpleFPS, iThinkUnity3D, SmartWorkersRTS

Lecture 6: Planning beyond STRIPS

Course overview

Page 7: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning7

Typical description of a planning problem:

Initial state

Goal

Available actions

Typical solution of a planning problem:

A sequence of actions that when executed in the initial state results in a state that satisfies the goal condition.

Planning: The automatic discovery of such solutions

Page 8: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

What is a planning problem?8

Let’s start with a simple example..

Page 9: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

9

Given:

Initial state

What is a planning problem?

Page 10: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

10

Given:

Initial state

Goal

What is a planning problem?

Page 11: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

11

Given:

Initial state

Goal

Available actions

What is a planning problem?

Page 12: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

12

Given:

Initial state

Goal

Available actions

Find:

A sequence of actions that achieves the goal

E.g.: [Left, Down, Left, Up, …]

What is a planning problem?

Page 13: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

13

Given:

Initial state

Goal

Available actions

Find:

A sequence of actions that achieves the goal

A method that is capable of finding a solution for every

initial state and goal

What is a planning problem?

Page 14: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

14

Given:

Initial state

Goal

Available actions

Find:

A sequence of actions that achieves the goal

A method that is capable of finding a solution for every

application domain

What is a planning problem?

Page 15: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

Use of planning in real applications15

Scheduling

Hubble Space Telescope

Page 16: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

Use of planning in real applications16

KIVA Robots: robots make inventory isles move

instead of workers

youtube link

Page 17: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

Use of planning in real applications17

Autonomous agents with planning capabilities for

specifying the behavior (Intelligent Agents/

Cognitive Robots)

UAV DARPA Grand/Urban Challenge, Honda

ASIMO

Page 18: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

18

Typical description of a planning problem:

Initial state

Goal

Available actions

STRIPS planning

Page 19: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning19

Blocks world domain

Initial state: s0

Goal: g

Available actions: moving a block

from the table to the top of another block

from the top of another block to the table

from the top of one block to the top of another block

Α Β C

Α

Β

C

s0 g

Page 20: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning20

Initial state

Representation of the properties of thedomain using first order logic literals

Blocks world

On(b,x): block b is on top of x, where x is another

block or the table

Clear(x):

a block can be placed on top of x

Α Β C

On(Α,Table)On(Β,Table)On(C,Table)

Clear(Α)Clear(Β)Clear(C)

s0

Page 21: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning21

Initial state

Representation of the properties of thedomain using first order logic literals

Ground and function-free

Completely specified based on a closed-world assumption

Α Β C

On(Α,Table)On(Β,Table)On(C,Table)

Clear(Α)Clear(Β)Clear(C)

s0

Page 22: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning22

Α Β C

On(Α,Table)On(Β,Table)On(C,Table)

Clear(Α)Clear(Β)Clear(C)

On(Α,Α)On(Α,Β) On(Α,C)On(Β,Α) On(Β,Β) On(Β,C) On(C,Α)On(C,Β) On(C,C) On(Α,Α) On(Α,Β) On(Α,C) On(Table,Α)On(Table,Β) On(Table,C) On(Table,Table) Clear(Table)

Initial state

Closed-world assumption

Any literal not mentioned in the description of the state are assumed to be false!

s0

Page 23: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning23

Goal

Representation of the properties of thedomain using first order logic literals

Ground and function-free

Partially specified (no closed-world assumption)

A state s satisfies goal g if it contains allliterals in g (more literals may be in s)

Α

Β

C

On(Α,Β)On(Β,C)

g

Page 24: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning24

The initial state and goal

condition are described using

first-order logic literals:

ground

function-free

positive

the list of literals typically

forms a logical conjunction

Α Β C

On(Α,Table)On(Β,Table)On(C,Table)

Clear(Α)Clear(Β)Clear(C)

On(Α,Β)On(Β,C)

s0 g

Α

Β

C

Page 25: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning25

Available actions

Move:

from the table to the

top of another block

from the top of

another block to the

table

from the top of one

block to the top of

another block

Α Β C

s0

On(Α,Table)On(Β,Table)On(C,Table)

Clear(Α)Clear(Β)Clear(C)

Page 26: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning26

Available actions

Move:

from the table to the

top of another block

from the top of

another block to the

table

from the top of one

block to the top of

another block

Α Β C Α

Β

C

Move(Β,Table,C)

s0 s1

On(Α,Table)On(Β,Table)On(C,Table)

Clear(Α)Clear(Β)Clear(C)

???

Page 27: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning27

Available actions

Preconditions: literals

denoting what needs to

be in the state for the

action to be applicable

Effects: literals denoting

how the state is

transformed when the

action is applied.

Α Β C Α

Β

C

Move(Β,Table,C)

s0 s1

On(Α,Table)On(Β,Table)On(C,Table)

Clear(Α)Clear(Β)Clear(C)

???

Page 28: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning28

Available actions

Preconditions:

On(b,x)

Clear(b)

Clear(y)

Effects:

On(b,y)

Clear(x)

On(b,x)

Clear(y)

Α Β C Α

Β

C

Move(Β,Table,C)

s0 s1

On(Α,Table)On(Β,Table)On(C,Table)

Clear(Α)Clear(Β)Clear(C)

???

Page 29: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning29

Available actions

Preconditions:

On(Β,Table)

Clear(Β)

Clear(C)

Effects:

On(Β,C)

Clear(Table)

On(Β,Table)

Clear(C)

Α Β C Α

Β

C

Move(Β,Table,C)

s0 s1

On(Α,Table)On(Β,Table)On(C,Table)

Clear(Α)Clear(Β)Clear(C)

???

Page 30: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning30

Available actions

Preconditions:

On(Β,Table)

Clear(Β)

Clear(C)

Effects:

On(Β,C)

Clear(Table)

On(Β,Table)

Clear(C)

Move(Β,Table,C)

On(Α,Table)On(Β,Table)On(C,Table)

Clear(Α)Clear(Β)Clear(C)

On(Α,Table)On(Β,C)

On(C,Table)Clear(Α)Clear(Β)

Clear(Table)

Α Β C Α

Β

C

s0 s1

Page 31: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning31

Available actions

Preconditions:

On(b,x)

Clear(b)

Clear(y)

Effects:

On(b,y)

Clear(x)

On(b,x)

Clear(y)

Move(C,Table,Α)

s1 s2

???

???Α

Β

C

On(Α,Table)On(Β,C)

On(C,Table)Clear(Α)Clear(Β)

Clear(Table)

Page 32: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning32

Available actions

Preconditions:

On(C,Table)

Clear(C)

Clear(Α)

Effects:

On(C,Α)

Clear(Table)

On(C,Table)

Clear(Α)

???

Move(C,Table,Α)

s1 s2

On(Α,Table)On(Β,C)

On(C,Table)Clear(Α)Clear(Β)

Clear(Table)

Α

Β

C

???

Page 33: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning33

Available actions

Preconditions:

On(Α,Table)

Clear(Α)

Clear(Β)

Effects:

On(Α,Β)

Clear(Table)

On(Α,Table)

Clear(Β)

Move(Α,Table,Β)

s1 s2

On(Α,Table)On(Β,C)

On(C,Table)Clear(Α)Clear(Β)

Clear(Table)

Α

Β

C

???

Α

Β

C

Page 34: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning34

Available actions

Preconditions:

On(Α,Table)

Clear(Α)

Clear(Β)

Effects:

On(Α,Β)

Clear(Table)

On(Α,Table)

Clear(Β)

Move(Α,Table,Β)

s1 s2

On(Α,Table)On(Β,C)

On(C,Table)Clear(Α)Clear(Β)

Clear(Table)

Α

Β

C

On(Α,Β)On(Β,C)

On(C,Table)Clear(Α)

Clear(Table)

Α

Β

C

Page 35: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning35

Move(Β,Table,C)

On(Α,Table)On(Β,Table)On(C,Table)

Clear(Α)Clear(Β)Clear(C)

On(Α,Table)On(Β,C)

On(C,Table)Clear(Α)Clear(Β)

Clear(Table)

Α Β C Α

Β

C

s0 s1

Move(Α,Table,Β)

s2

On(Α,Β)On(Β,C)

On(C,Table)Clear(Α)

Clear(Table)

Α

Β

C

Page 36: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning36

On(Α,Table)On(Β,Table)On(C,Table)

Clear(Α)Clear(Β)Clear(C)

On(Α,Table)On(Β,C)

On(C,Table)Clear(Α)Clear(Β)

Clear(Table)

Α Β C Α

Β

C

s0 s1 s2

On(Α,Β)On(Β,C)

On(C,Table)Clear(Α)

Clear(Table)

Α

Β

C

Α

Β

C

On(Α,Β)On(Β,C)

g

Move(Β,Table,C) Move(Α,Table,Β)

Page 37: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning37

Is our STRIPS representation of the

blocks world correct?

Consider moving back blocks A

and B back to the tableOn(Α,Β)On(Β,C)

On(C,Table)Clear(Α)

Clear(Table)

Α

Β

C

Page 38: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning38

On(Α,Table)On(Β,C)

On(C,Table)Clear(Α)Clear(Β)

Α Β CΑ

Β

C

s2 s3 s4

On(Α,Β)On(Β,C)

On(C,Table)Clear(Α)

Clear(Table)

Α

Β

C

Move(A,B,Table) Move(B,C,Table)

???

Page 39: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning39

Is our STRIPS representation of the

blocks world correct?

Consider moving back blocks A

and B back to the table

Clear(Table) needs to be treated

differently

Move(b,x,y)

MoveToTable(b,x)

On(Α,Β)On(Β,C)

On(C,Table)Clear(Α)

Clear(Table)

Α

Β

C

Page 40: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning40

Init( On(Α,Table) On(Β,Table) On(C,Table)

Clear(Α) Clear(Β) Clear(C) )

Goal( On(Α,Β) On(Β,C) )

Action( Move(b,x,y),PRECONDITIONS: On(b,x) Clear(b) Clear(y)

EFFECTS: On(b,y) Clear(x) On(b,x)

Clear(y) )

Action( MoveToTable(b,x),PRECONDITIONS: On(b,x) Clear(b)

EFFECTS: On(b,Table) Clear(x) On(b,x) )

Page 41: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning41

Init( On(Α,Table) On(Β,Table) On(C,Table)

Clear(Α) Clear(Β) Clear(C) )

Goal( On(Α,Β) On(Β,C) )

Action( Move(b,x,y),PRECONDITIONS: On(b,x) Clear(b) Clear(y)

EFFECTS: On(b,y) Clear(x) On(b,x)

Clear(y) )

Action( MoveToTable(b,x),PRECONDITIONS: On(b,x) Clear(b)

EFFECTS: On(b,Table) Clear(x) On(b,x) )

! Variables that appear in preconditions and effects

need to be parameters of the action schema

Page 42: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning42

Init( On(Α,Table) On(Β,Table) On(C,Table)

Clear(Α) Clear(Β) Clear(C) )

Goal( On(Α,Β) On(Β,C) )

Action( Move(b,x,y),PRECONDITIONS: On(b,x) Clear(b) Clear(y)

EFFECTS: On(b,y) Clear(x) On(b,x)

Clear(y) )

Action( MoveToTable(b,x),PRECONDITIONS: On(b,x) Clear(b)

EFFECTS: On(b,Table) Clear(x) On(b,x) )

! Variables that appear in preconditions and effects

need to be parameters of the action schema

Page 43: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning43

Init( On(Α,Table) On(Β,Table) On(C,Table)

Clear(Α) Clear(Β) Clear(C) )

Goal( On(Α,Β) On(Β,C) )

Action( Move(b,x,y),PRECONDITIONS: On(b,x) Clear(b) Clear(y)

EFFECTS: On(b,y) Clear(x) On(b,x)

Clear(y) )

Action( MoveToTable(b,x),PRECONDITIONS: On(b,x) Clear(b)

EFFECTS: On(b,Table) Clear(x) On(b,x) )

! Variables that appear in preconditions and effects

need to be parameters of the action schema

Page 44: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning44

Init( On(Α,Table) On(Β,Table) On(C,Table)

Clear(Α) Clear(Β) Clear(C) )

Goal( On(Α,Β) On(Β,C) )

Action( Move(b,x,y),PRECONDITIONS: On(b,x) Clear(b) Clear(y)

EFFECTS: On(b,y) Clear(x) On(b,x)

Clear(y) )

Action( MoveToTable(b,x),PRECONDITIONS: On(b,x) Clear(b)

EFFECTS: On(b,Table) Clear(x) On(b,x) )

! Simplified STRIPS version of Figure 11.4 in AIMA 2nd Ed.

Page 45: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning45

Gripper domain

Init( On-Table(Α) On-Table(Β) On-table(C)

Clear(Α) Clear(Β) Clear(C) Grip-Empty )

Goal( On(Α,Β) On(Β,C) )

Action( Pick-up(x), … )

Action( Put-down(x), … )

Action( Stack(top,below), … )

Action( Unstack(top,below), … )

Page 46: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

STRIPS planning46

Reasoning about action and change

Since 1971 that STRIPS planning was proposed by R. E. Fikes and N. J. Nilsson, more expressive planning formalisms have been developed based on STRIPS!

ADL allows open worlds, conditional effects, quantifiers [Pednault 1988]

Situation calculus [McCarthy, Hayes 1969] [Reiter 2001] is based on first-order logic allowing rich representations

Action languages A, Fluent calculus, Event calculus, …

Page 47: Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part1

Bibliography47

Material

Artificial Intelligence: A Modern Approach 2nd Ed. Stuart Russell, Peter

Norvig. Prentice Hall, 2003 Section 11.1

References

STRIPS: A new approach to the application of theorem proving to

problem solving. Richard E. Fikes, Nils J. Nilsson. Artificial Intelligence,

Vol. 2, No. 3-4, 1971.

Synthesizing plans that contain actions with context-dependent effects.

E. P. D. Pednault. Computational Intelligence, Vol. 4, No. 3. 1988.

Some Philosophical Problems from the Standpoint of Artificial

Intelligence. John McCarthy, Patrick J. Hayes. Machine Intelligence, Vol.

4, 1969.

Knowledge in Action: Logical Foundations for Specifying and

Implementing Dynamical Systems. Raymond Reiter. MIT Press, 2001.