%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Bob is in the park. %%% Mary is at home. %%% Bob wishes to call Mary to join him. %%% Between the park and Mary's house there is a narrow road. %%% The door is old and heavy. %%% First Bob need to ring the bell. %%% Then they can open the old door in cooperation. %%% Mary cannot leave the house if the door is closed. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Solutions with %%% :-bmap(T). %%% for T in [5..18] %%% The two agents agent(bob). agent(mary). %%% Three places %%% Park -> 0 %%% narrow road -> 1 %%% Mary's house -> 2 place(0). place(1). place(2). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fluent(stay(X),0,2) :- agent(X). fluent(door,0,1). fluent(bell,0,1). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% action([X],move(A,B)) :- place(A), place(B), 1 is abs(A-B), %%% Prolog style agent(X). action([X],ring) :- agent(X). action([X],push) :- agent(X). action([X],pull) :- agent(X). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% executable([X],move(0,1),[stay(X) eq 0]) :- agent(X). executable([X],move(1,0),[stay(X) eq 1]) :- agent(X). executable([X],move(1,2),[stay(X) eq 1, door eq 1]) :- agent(X). executable([X],move(2,1),[stay(X) eq 2, door eq 1]) :- agent(X). executable([X],ring,[stay(X) eq 1]) :- agent(X). executable([X],push,[stay(X) eq 1, bell eq 1]) :- action([X],push). executable([X],pull,[stay(X) eq 2, bell eq 1]) :- action([X],pull). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% causes(stay(X) eq B, [actocc([X],move(A,B))]) :- action([X],move(A,B)). %%% Boolean Bell causes(bell eq 1, [actocc([X],ring),bell eq 0]) :- action([X],ring). causes(bell eq 0, [actocc([X],ring),bell eq 1]) :- action([X],ring). %%% Door causes(door eq 1,[actocc([X],push),actocc([Y],pull)]) :- action([X],push), action([Y],pull). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Bob at the park, Mary at home initially(stay(bob) eq 0). initially(stay(mary) eq 2). initially(bell eq 0). initially(door eq 0). %%% Both at the park goal(stay(bob) eq 0). goal(stay(mary) eq 0). %%%%%%%%%%%%%%%%%%%%%