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
5. STRIPS planning
5
Given:
Initial state
Goal
Available actions
6. STRIPS planning
6
Given:
Initial state
Goal
Available actions
Find:
A sequence of actions that achieves the goal
E.g.: [Left, Down, Left, Up, …]
7. Planning Domain Description Language
7
Planning Domain Definition Language (PDDL)
Formal language for specifying planning problems
Formal syntax similar to a programming language
Includes STRIPS and ADL, and many more features
Provides the ground for performing a direct comparison
between planning techniques and evaluating against
classes of problems
8. Planning Domain Description Language
8
Blocks world domain
Initial state: s0 Α
Β
Α Β C C
Goal: g
s0 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
16. Planning Domain Description Language
16
On(A,B) (on a b)
On(A,B) (not (on a b))
On(A,B) On(B,C) (and (on a b) (on b c))
On(x,y) (on ?x ?y)
17. The blocks world example in PDDL
17
Blocks world domain
Available predicates (:predicates …)
Available actions (:action …)
18. The blocks world example in PDDL
18
Blocks world domain
Available predicates (:predicates
(on ?x ?y) (clear ?x)
)
19. The blocks world example in PDDL
19
Blocks world domain
Available action (:action move
:parameters (?b ?x ?y)
:precondition (and
(on ?b ?x) (clear ?b)
(clear ?y))
:effect (…)
)
20. The blocks world example in PDDL
20
Blocks world domain
Available action (:action move-to-table
:parameters (?b ?x)
:precondition (…)
:effect (…)
)
21. The blocks world example in PDDL
21
Blocks world problem
Available objects (:objects …)
Initial state (:init …)
Goal (:goal …)
22. The blocks world example in PDDL
22
Blocks world domain
Available objects (:objects
a b c table
)
23. The blocks world example in PDDL
23
Blocks world domain
Initial state (:init
(on a table) (clear a)
(on b table) (clear b)
Α Β Γ
(on c table) (clear c)
)
24. The blocks world example in PDDL
24
Blocks world domain
Goal (:goal
Α
(and (on a b) (on b c) )
Β
Γ
)
25. The blocks world example in PDDL
25
blocks-domain.txt: blocks-problem1.txt:
(define (domain gripper) (define (problem gripper1)
(:requirements :strips) (:domain gripper)
(:predicates (on ?x ?y) (clear ?x)) (:objects a b c table)
(:action move (:init
:parameters (?b ?x ?y) (on a table) (on b table) (on c table)
:precondition (and (on ?b ?x) (clear ?b) (clear ?y)) (clear a) (clear b) (clear c)
:effect (and (not (on ?b ?x)) )
(not (clear ?y))
(on ?b ?y) (:goal (and (on a b) (on b c)))
(clear ?x))) )
…
26. Using PDDL planners
26
Planning Domain Definition Language (PDDL)
International Planning Competition 1998 – today
SAT Plan
TL Plan Planning problems in
PDDL, e.g., Blocks
FF world, Storage, Trucks,
…
BlackBox
SHOP2
TALPlanner
Direct comparison between
… planning techniques! E.g.,
evaluation of heuristics, …
27. Using PDDL planners: Blocks world
27
blackbox –o blocks-domain.txt –f blocks-problem1.txt
----------------------------------------------------
Begin plan
Α Β C
1 (move b table c)
2 (move a table b)
End plan
---------------------------------------------------- Α
Β
C
28. Using PDDL planners: Blocks world
28
blackbox –o blocks-domain.txt –f blocks-problem2.txt
----------------------------------------------------
Begin plan G
1 (move e b d) D E F
2 (move b table e) Α Β C
3 (move g f table)
4 (move f c g)
5 (move b e c) Α
6 (move e d f) Β
7 (move d a e) C
8 (move b c a) D
E
9 (move c table d)
F
10 (move b a c)
G
11 (move a table b)
End plan
29. Using PDDL planners
29
We can use blackbox (or any other off-the-self PDDL
planner) for any problem we can write in PDDL!
30. Using PDDL planners: Sokoban
30
We can use blackbox (or any other off-the-self PDDL
planner) for any problem we can write in PDDL!
Let’s do this for Sokoban
31. Using PDDL planners: Sokoban
31
Available predicates
Available actions
Available objects
Initial state
Goal
49. Building your own PDDL planner
49
Pyperplan
Lightweight STRIPS planner written in Python. Developed during
the planning course at Albert-Ludwigs-Universität Freiburg
2010/2011, GNU General Public License 3
https://bitbucket.org/malte/pyperplan
Source code of academic planners
BlackBox:
http://www.cs.rochester.edu/u/kautz/satplan/blackbox/
FastForward: http://www.loria.fr/~hoffmanj/ff.html
FastDownward: http://www.fast-downward.org/
ANTLR Parser Generator
http://www.antlr.org/
http://www.antlr.org/grammar/1222962012944/Pddl.g
50. Building your own PDDL planner
50
Quick overview of the provided PROLOG code
Good for quick prototyping ;-)
51. Building your own PDDL planner
51
Quick overview of the provided PROLOG code
Works with SWI Prolog 6.x (tested with 6.0.2)
Predicates provided
parsePDDL(+DomainFile, +ProblemFile)
get_init(-InitialState)
get_goal(-Goal)
satisfies_goal(+State)
progress(+State, -Action, -NextState)
h(+State, -Value)
{dfs,astar}planner(+DomainFile, +ProblemFile)
52. Planning Domain Description Language
52
Planning Domain Definition Language (PDDL)
International Planning Competition 1998 – today
SAT Plan
TL Plan
FF Sokoban
BlackBox
SHOP2
TALPlanner
Direct comparison between
… planning techniques! E.g.,
evaluation of heuristics, …
53. Using PDDL planners
53
FastDownward [Helmert 2006]
Introduced a new type of heuristic that is not based on
an empty list of negative actions
Efficient implementation of all notable forward search
methods and heuristics (including the more recent ones)
Requires a number of preprocessing steps that
transforms the STRIPS planning problem…
54. Using PDDL planners
54
FastDownward [Helmert 2006]
Introduced a new type of heuristic that is not based on
an empty list of negative actions
Efficient implementation of all notable forward search
methods and heuristics (including the more recent ones)
Requires a number of preprocessing steps that
transforms the STRIPS planning problem…
Can be used as a framework to evaluate forward
search planning methods
61. Using PDDL planners: Sokoban
61
Notice that the planner does not know anything
about the planning problem we are solving
The heuristics we tried are domain independent
goal count
hmax
hadd
FF
We will see how each one works in Lecture 4 (after
we first go over planning graphs that are needed)
62. Next lecture
62
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
63. Bibliography
63
Material
Artificial Intelligence: A Modern Approach 2nd Ed. Stuart Russell, Peter
Norvig. Prentice Hall, 2003 Section 11.4
References
PDDL - The Planning Domain Definition Language. Drew McDermott,
Malik Ghallab, Adele Howe, Craig Knoblock, Ashwin Ram, Manuela
Veloso, Daniel Weld, David Wilkins. Technical report, Yale Center for
Computational Vision and Control, TR-98-003, 1998.
Unifying SAT-Based and Graph-Based Planning. Henry Kautz, Bart
Selman. In Proceedings of the International Joint Conference on
Artificial Intelligence (IJCAI), 1999
The Fast Downward Planning System. Malte Helmert. Artificial
Intelligence Research (JAIR), Vol. 26, 2006