Planning (What to do next?) (What to do next?) (What to do next?) (What to do next?) (What to do next?) (What to do next?) CSC3203 - AI in Games
2 Level 12: Planning YOUR MISSION learn about how to create a plan of actions to achieve a certain goal YOUR GOAL be aware of what planning is and what problems can arise in planning process know how to generate a plan for use in the Blocks World using STRIPS
3 What plan? planning: identify a sequence of actions that will (most likely) lead to a given goal cook dinner: take bus to Haymarket; take Metro to X; walk to superstore... image source: http://flickr.com/photos/snapsi42/260902
Write down a plan to get a cup of? coffee (or tea) Plan to spend 3 minutes 4
5 Planning problems A* search space (even for simple problems) can quickly become huge even worse when having to re-plan dynamically - real-time games even worse when state of the world is not fully observable/uncertain or outcome of actions is not deterministic even worse with multiple agents
Simplify Problems simplifying assumptions about the (game) environment fully observable/accessible deterministic finite static discrete image source: http://flickr.com/photos/ontdesign/692369952/ 6
7 Decomposition decomposable problem: can be divided into (independent) sub-problems combining solutions of sub-problems yields solution for parent problem caveat: this hinges on independence of problems (solving one sub-problem does not interfere with solving others) problems can be decomposable, nearly decomposable (some weak interference) or non-decomposable
8 Heuristics techniques that improve average-case performance on a problem-solving task but not necessarily the worst-case performance rules that help reduce search space example: take first solution that is good enough finding good heuristics can be tough
(*) STanford Research Institute Problem Solver** 9 STRIPS image source: http://flickr.com/photos/georgiesharp/10709 very influential; many planners still use STRIPS-like language to describe planning problems/process problem = initial state + available actions + goal plan = initial state + sequence of actions + final state (= goal) (**) it s actually a planner
10 closed world assumption states represented as conjunction of positive statements that do not contain functions or variables; goals as well but may contain variables examples: not a valid state per se At(home) Have(Milk) Have(Tea) At(home) Have(Cuppa) this one is
11 action = action description (AD)+ precondition (PC) + effect (E) AD: what agent returns to env. to do something (also: name of action) PC: conjunction of positive literals that must be true before action applicable some versions allow literals that must be false E: conjunction of positive or negative literals describing situation after action has been applied (add/delete list)
Op(ACTION: Go(there), relocating from h to t PRECOND: At(here) Path(here,there), EFFECT: At(there) At(here)) At(here), Path(here,there) Go(there) here At(there), At(here)) there add list delete list image source: http://flickr.com/photos/snapsi42/260902 12
13 plans: sequence of actions with compatible preconditions and effects that incrementally transform initial state into goal state INITIAL STATE: {} Op(ACT: RightSock, PRE: {}, EFF: RightSockOn) Op(ACT: RightShoe, PRE: RightSockOn, EFF: RightShoeOn) Op(ACT: LeftSock, PRE: {}, EFF: LeftSockOn) Op(ACT: LeftShoe, PRE: LeftSockOn, EFF: LeftShoeOn) GOAL: RightShoeOn LeftShoeOn??
objects states actions blocks A, B, C; Table On(X, Y) Clear(X) Move(X, Y, Z) move X from Y to Z PRE: On(X, Y) Clear(X) Clear(Z) DEL: On(X,Y), Clear(Z) ADD: On(X, Z), Clear(Y) MoveToTable(X) move X to table PRE: Clear(X) On(X, Y) DEL: On(X,Y) ADD: On(X, Table), Clear(Y) image source: http://flickr.com/photos/soft/2340756 A B C 14
15 A B On(A, B) On(B, C) On(C, Table) Clear(A) C? On(A, B) On(B, Table) On(C, Table) Clear(A) Clear(C) A B C
16 On(A, B) On(B, C) On(C, Table) Clear(A) A B C movetotable(a) On(A, Table) On(B, C) On(C, Table) B Clear(A) Clear(B) A C movetotable(b) On(A, Table) On(B, Table) On(C, B A C Table) Clear(A) Clear(B) Clear(C)! move(a, Table, B) On(A, B) On(B, Table) On(C, Table) Clear(A) Clear(C) A B C
Nethack meets STRIPS P A B G C In(P,A) In(G,B) Connected(A,B) Connected(B,C) Connected(B,D) Connected(C,D)? MoveTo(...), PickUp(...), Drop(...)? D In(P,D) Holds(P,G) Connected(A,B) Connected(B,C) Connected(B,D) Connected(C,D) How many steps to do this (minimally)? 17
18 Forward Search forward search = progression planning start from initial state search for sequence of actions adding actions one-by-one such that the goal state is reached problem: many irrelevant actions lead to many irrelevant branches in search space (search space explosion)
19 Backward Search backward search = regression planning start from the goal state and search backward towards initial state benefit: considers only relevant actions problems: more restricted than forward search: many final states may contain goal state; initial state may not be backward-reachable from the goal state without some complementation
Heuristics for Search Relaxation: relax constraints on goal/actions solve transformed problem constrain solution of relaxed problem Sub-goal independence: decompose into independent sub-goals solve sub-problems independently combine sub-problem solutions and add further constraints to obtain solution of the original problem 20
21 Lvl 12 complete SUMMARY planning defined key problem: search space explosion coping strategies: simplifications, decomposition, heuristics STRIPS and the Blocks World backward, forward search
22 Any Questions?
23 Bonus Level original STRIPS paper: www.ai.sri.com/pubs/files/tn043r-fikes71.pdf Russell & Norvig, chapter 11