Homework 7
|
The purpose of the assignment is to provide an introduction to planning.
| a | |
| b | c |
and goal state is:
| a |
| b |
| c |
| a |
| b |
| c |
| a |
- A simple STRIPS planner has been implemented in Prolog. Note a key point is the text uses an effect list of conjuncts while the planner uses and add and delete list. The effect is added to the action preconditions to produce the next state. The delete list is removed from preconditions; the add list is added to the preconditions.
Below is the definition of the text blocks world. There are two parts:
- Actions - Defines the actions planner can execute. Defined somewhat differently than the text using an add and delete list rather than one effect list. Format of is:
- action name and parameters
- preconditions
- delete list of conjuncts to delete from the state as the action effect
- add list of conjuncts to add to the state as the action effect.
For example, the move operation is defined as:
actions(move(B,X,Y),
[on(B,X), clear(B), clear(Y), block(B)],
[on(B,X), clear(Y)],
[on(B,Y), clear(X)]).Negative terms, such as Øhave(cake) can be represented as not(have(cake)).
- Planning problem - Defines the problem initial and goal states to be solved using the defined actions.
For example, in the following planner problem, the initial state is:
[on(a, table), on(b,table), on(c,table), clear(a), clear(b), clear(c), block(a), block(b), block(c)]
a b c and goal state is:
[on(c,table), on(a,b), on(b,c), clear(a) ]
a b c test :- planner(
[on(a, table), on(b,table), on(c,table), clear(a), clear(b), clear(c), block(a), block(b), block(c)],
[on(c,table), on(a,b), on(b,c), clear(a) ]).
/* Define legal (1) actions (2) preconditions (3) delete list (4) add list */ actions(move(B,X,Y), [on(B,X), clear(B), clear(Y), block(B)], [on(B,X), clear(Y)], [on(B,Y), clear(X)]).actions(moveToTable(B,X), [on(B,X), clear(B), block(B)], [on(B,X)], [on(B,table), clear(X)])./* Define initial and goal states of planning problem */ test :- planner( [on(a, table), on(b,table), on(c,table), clear(a), clear(b), clear(c), block(a), block(b), block(c)], [on(c,table), on(a,b), on(b,c), clear(a) ]).
Starting
- Download TextStrips.pro
- Copy and save the above test program for the blocks world as Test.pl
- In Prolog:
- Consult TextStrips.pro
- Consult Test.pl
In Prolog enter:
?- test.