%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%% A reader and his "switcher" friend %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% The switcher and the reader are at the door. %%% The light is switched off %%% The reader wish to read the book on the table %%% He needs 5 (sequential) minutes to end the reading of the book %%% The light must be on for reading, of course %%% The power switch is in a house corner %%% When switched on, light turns off automatically after two minutes %%% (Therefore the switcher need switching-on it again). %%% The move point2point actions have different lengths. %%% The goal is to allow the reader to end the reading of the book %%% and to put the switcher in the same place as the reader %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Developped and encoded by DFP, May 2010 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% You'll discover the plan with :-bmap(9). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%% WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! %%% set loopcontrol to off in BMAP (needed at the beginning of the plan) %%% Otherwise, add a faked fluent to ensure all states are different %%% simply uncommenting the following line %%% fluent(time,0,100). initially(time eq 0). caused([],time ++). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% agent(switcher). agent(reader). %%% positions: %% 1. door - 2. switch - 3. table position(1). position(2). position(3). %%%% fluent(at(X),1,3) :- agent(X). fluent(light_on,0,1). fluent(all_read,0,1). %%%%%%%% ACTION with duration %%%%%%%% action([X], move(1,2), 3) :- agent(X). action([X], move(2,1), 3) :- agent(X). action([X], move(1,3), 4) :- agent(X). action([X], move(3,1), 4) :- agent(X). action([X], move(2,3), 1) :- agent(X). action([X], move(3,2), 1) :- agent(X). action([switcher], switch_on, 1). action([reader], read, 1). %%%%%%%% EXECUTABILITY %%%%%%%% executable([X], move(A,B), [at(X) eq A]) :- action([X], move(A,B),_). executable([switcher], switch_on, [at(switcher) eq 2]). executable( [reader], read, [at(reader) eq 3, light_on eq 1]). %%%%%%%% EFFECTS %%%%%%%% causes(light_on eq 1, [actocc([switcher], switch_on)],2). causes(light_on eq 0, [actocc([switcher], switch_on)^(-1) eq 0, actocc([switcher], switch_on) eq 0],1). causes(all_read eq 1, [actocc([reader], read)^(-4), actocc([reader], read)^(-3), actocc([reader], read)^(-2), actocc([reader], read)^(-1), actocc([reader], read) ]). causes(at(X) eq B, [actocc([X],move(A,B))^(Dneg) gt actocc([X],move(A,B))^(Dmeg)]) :- action([X],move(A,B),D), Dmeg is -D, Dneg is 1-D. %%%%%%%% Initial State and Goal initially(at(X) eq 1) :- agent(X). initially(light_on eq 0). initially(all_read eq 0). %%%%% goal(all_read eq 1). goal(at(switcher) eq at(reader)). %%% This minimizes the unessential switch-on actions plan_cost(plan leq 16). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%