PROGRAM "philippe" LOAD "cal.pl" CAPABILITIES { // Mental actions {true} Treated(X,Content,Y) { not received(X,propose,content(price(Content,Y)))} {True} Updateotheroffer(Z,X,Y) {not lastotheroffer(Z), lastotheroffer(X), not otheroffer(X), otheroffer(Y)} {True} Updatecurrentoffer(X,Y) {not currentoffer(X), currentoffer(Y)} {TRUE} Updateoffer(X,Y,Z) {not currentoffer(X), not lastoffer(Y), lastoffer(X), currentoffer(Z)} } BELIEFBASE { %preferences about items selling price prefmax(rentcar,500). prefmin(rentcar,300). prefmax(plane,400). prefmin(plane,200). currentoffer(0). otheroffer(0). lastoffer(0). lastotheroffer(0). % calculate the next offer nextoffer(N):- currentoffer(Z), otheroffer(O), plus(Z,O,P), times(P,0.5,N). % reframe condition reframecondition(X) :- currentoffer(X), lastoffer(X), otheroffer(Z), lastotheroffer(Z). % emulate the knowledge about a planning rule concerning an alternative plan to go somewhere % 3APL does not provide introspection for planning rule achieve(plane,go(sydney)). } GOALBASE { } PLANBASE{} PG-RULES { // a request has been received that need to be treated <- received(X,request,content(Content)) and not sent(X,propose,content(price(Content,W))) and prefmax(Content,Y) and currentoffer(W) and lastoffer (L) | {Updateoffer(L,W,Y); Send(X,propose,content(price(Content,Y))); bargain(X,Content)} } PR-RULES { bargain(X,Content) <- received(X,request,content(Content)) and received(X,propose,content(price(Content,Y))) and otheroffer(W) and currentoffer(Z) and lastotheroffer(P) | {Treated(X, Content, Y); Updateotheroffer(P,W,Y); minus(Z,Y,R)?; If R < 10 then Send(X,accept,content(price(Content,Y))) else nextoffer(X,Content)}, bargain(X,Content) <- received(X,accept,content(price(Content,Y))) | {Treated(X,Content,Y)}, reframe(X,Content) <- not sent(X,reqpurpose,why(Content)) | {Send(X,reqpurpose,why(Content)); reframe(X,Content)} , reframe(X,Content) <- received(X,inform,because(Y)) and achieve(P,Y) and not sent(X,inform,content(achieve(Y,P)))| {Send(X,inform,content(achieve(Y,P)))} , // accept received offer or calculate the next offer or branch to reframing nextoffer(X,Request)<- prefmin(Request,M) and currentoffer(Z) and lastoffer(W)| {nextoffer(N)?; if N > M then {Updateoffer(Z,W,N); Send(X,propose,content(price(Request,N))); bargain(X,Request)} else { Updateoffer(Z,W,M); if not reframecondition(M) then {Send(X,propose,content(price(Request,M))); bargain(X,Request)} else reframe(X,Request) } } }