%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% PEG SOLITAIRE %%% csplib #037 - see www.csplib.org %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% It needs 31 actions. %%% Call :- bmap(31). %%% Strategy: leftmost 37.6s %%% Strategy: left_ffc: ???? %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Chessboard: cell(0,2). cell(0,3). cell(0,4). cell(1,2). cell(1,3). cell(1,4). cell(2,0). cell(2,1). cell(2,2). cell(2,3). cell(2,4). cell(2,5). cell(2,6). cell(3,0). cell(3,1). cell(3,2). cell(3,3). cell(3,4). cell(3,5). cell(3,6). cell(4,0). cell(4,1). cell(4,2). cell(4,3). cell(4,4). cell(4,5). cell(4,6). cell(5,2). cell(5,3). cell(5,4). cell(6,2). cell(6,3). cell(6,4). %%% Directions direction(north). direction(west). direction(east). direction(south). %%% Cell Neighbourough close(X,Y, north, X1,Y) :- X1 is X-1. close(X,Y, south, X1,Y) :- X1 is X+1. close(X,Y, east, X,Y1) :- Y1 is Y+1. close(X,Y, west, X,Y1) :- Y1 is Y-1. jump(X,Y, north, X1,Y) :- X1 is X-2. jump(X,Y, south, X1,Y) :- X1 is X+2. jump(X,Y, east, X,Y1) :- Y1 is Y+2. jump(X,Y, west, X,Y1) :- Y1 is Y-2. %%%%%%%%% AGENT %%%%%%%% agent(a). %%%%%%%% FLUENT %%%%%%%% fluent( occupied(X,Y), 0, 1 ) :- cell(X,Y). %%%%%%%% ACTION %%%%%%%% action([a], move(X,Y,Dir)) :- cell(X,Y), direction(Dir), close(X,Y,Dir,X1,Y1), cell(X1,Y1), jump(X,Y,Dir,X2,Y2), cell(X2,Y2). %%%%%%%% EXECUTABILITY %%%%%%%% executable([a], move(X,Y,Dir), [ occupied(X,Y) eq 1, occupied(X1,Y1) eq 1, occupied(X2, Y2) eq 0]):- action([a], move(X,Y,Dir)), close(X,Y,Dir, X1,Y1), jump(X,Y,Dir, X2,Y2). %%%%%%% EFFECTS %%%%%%%% causes(occupied(X,Y) eq 0, [actocc([a],move(X,Y,Dir))]) :- action([a],move(X,Y,Dir)). causes(occupied(X1,Y1) eq 0, [actocc([a],move(X,Y,Dir))]) :- action([a],move(X,Y,Dir)), close(X,Y,Dir,X1,Y1). causes(occupied(X2,Y2) eq 1, [actocc([a],move(X,Y,Dir))]) :- action([a],move(X,Y,Dir)), jump(X,Y,Dir,X2,Y2). %%%%%%%% Initial State and Goal initially(occupied(3,3) eq 0). initially(occupied(X,Y) eq 1) :- cell(X,Y), neq_pair(X,Y,3,3). goal(occupied(X,Y) eq 0) :- cell(X,Y), neq_pair(X,Y,3,3). goal(occupied(3,3) eq 1). %%% To remove simple symmetries: holds(occupied(3,1) eq 0,1). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% neq_pair(X1,_Y1,X2,_Y2) :- neq(X1,X2). neq_pair(X,Y1,X,Y2) :- neq(Y1,Y2). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%