Untitled
By: a guest | Mar 22nd, 2010 | Syntax:
Prolog | Size: 2.07 KB | Hits: 60 | Expires: Never
:- multifile at/3, visited/2, money/2.
% --- Primitive control actions ---------------------------------------
% this section defines the name and the number of parameters of the
% actions available to the planner
%
% primitive_action( dosomething(_,_) ). % underscore means 'anything'
primitive_action( fly(_,_) ).
primitive_action( drive(_,_,_) ).
primitive_action( bus(_,_) ).
primitive_action( visit(_) ).
% --- Precondition for primitive actions ------------------------------
% describe when an action can be carried out, in a generic situation S
%
% poss( doSomething(...), S ) :- preconditions(..., S).
poss( fly(From, To), S ) :-
at(agent,From, S),
flight(From, To),
money(X, S), X >= 10.
poss( bus(From, To), S ) :-
at(agent,From, S),
road(From, To),
money(X,S), X >= 5.
poss( drive(What, From, To), S ) :-
at(agent, From, S),
What = car,
at(What,From, S),
road(From, To),
money(X, S), X >= 1.
poss(visit(City), S ) :-
at(agent,City, S),
not((visited(City, S) )).
% --- Successor state axioms ------------------------------------------
% describe the value of fluent based on the previous situation and the
% action chosen for the plan.
% fluent(..., result(A,S)) :- positive; previous-state, not(negative)
at(agent,Where, result(A, S)) :-
(A = fly(_, Where); A = drive(_, _, Where);A = bus(_, Where) );
at(agent,Where, S) , not(( A = fly(Where, _) ; A = drive(_, Where, _) ; A = bus(Where, _) )).
at(car,Where, result(A, S)) :-
(A = drive(car, _, Where));
at(car, Where, S) , not(( A = drive(car, Where, _) )).
visited(Place, result(A,S)) :-
A = visit(Place);
visited(Place, S), not(A=visit(Place)).
money(X, result(A, S)) :-
A = fly(_,_), money(N,S), X is N -10;
A = drive(_,_,_), money(N,S), X is N -1;
A = bus(_,_), money(N,S), X is N -5 ;
money(X,S),
not((A =fly(_,_) ; A =drive(_,_,_) ; A =bus(_,_))) .
% ---------------------------------------------------------------------
% ---------------------------------------------------------------------