%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Sam Lloyd's puzzle with 16 cells and 15 tiles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Coded by DFP, June 2010, %%% as required for the by ASP competition 2009 %%% http://dtai.cs.kuleuven.be/events/ASP-competition/Benchmarks/15Puzzle.shtml %%% by Lengning Liu, Miroslaw Truszczynski, and Martin Gebser %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%% 1 2 3 4 (Y) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 1 % 0 1 2 3 % 2 % 4 5 6 7 % 3 % 8 9 10 11 % 4 %12 13 14 15 %(X)%%%%%%%%%%%%%%%%%% tile(N) :- interval(N,0,15). %%% entry(N). %%% direction(n). direction(w). direction(s). direction(e). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Action Theory %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fluent(at(N),0,15) :- tile(N). action(move(D)) :- direction(D). %%%%%%%% executable(move(n), [at(0) geq 4]). executable(move(s), [at(0) leq 11]). executable(move(e), [at(0) neq 3,at(0) neq 7,at(0) neq 11,at(0) neq 15]). executable(move(w), [at(0) neq 0,at(0) neq 4,at(0) neq 8,at(0) neq 12]). %%%%%%%%% causes(move(n), at(0) eq at(0)^(-1) - 4, []). causes(move(s), at(0) eq at(0)^(-1) + 4, []). causes(move(w), at(0) eq at(0)^(-1) - 1, []). causes(move(e), at(0) eq at(0)^(-1) + 1, []). %%%%%%%%% causes(move(n), at(N) eq at(0)^(-1),[at(N) eq at(0)-4]) :- tile(N), N > 0. causes(move(s), at(N) eq at(0)^(-1),[at(N) eq at(0)+4]) :- tile(N), N > 0. causes(move(e), at(N) eq at(0)^(-1),[at(N) eq at(0)+1]) :- tile(N), N > 0. causes(move(w), at(N) eq at(0)^(-1),[at(N) eq at(0)-1]) :- tile(N), N > 0. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Expected Goal goal(at(N) eq N) :- tile(N). %%%%% Initial state, retrieved from ASP competition input initially(at(N) eq 4*(X-1) + Y-1 ) :- in0(X,Y,N). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% Instance 10 moves %%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %in0(1,1,1). in0(1,2,2). in0(1,3,3). in0(1,4,7). %in0(2,1,8). in0(2,2,4). in0(2,3,5). in0(2,4,6). %in0(3,1,9). in0(3,2,10). in0(3,3,0). in0(3,4,11). %in0(4,1,12). in0(4,2,13). in0(4,3,14). in0(4,4,15). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% Instance 20 moves %%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% in0(1,1,1). in0(1,2,2). in0(1,3,7). in0(1,4,6). in0(2,1,8). in0(2,2,4). in0(2,3,3). in0(2,4,11). in0(3,1,0). in0(3,2,10). in0(3,3,5). in0(3,4,15). in0(4,1,9). in0(4,2,12). in0(4,3,13). in0(4,4,14). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% Instance .init1 -> 35 moves %%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%in0(1,1,4). %%%in0(1,2,0). %%%in0(1,3,3). %%%in0(1,4,6). %%%in0(2,1,12). %%%in0(2,2,1). %%%in0(2,3,11). %%%in0(2,4,7). %%%in0(3,1,9). %%%in0(3,2,5). %%%in0(3,3,10). %%%in0(3,4,15). %%%in0(4,1,13). %%%in0(4,2,8). %%%in0(4,3,14). %%%in0(4,4,2). %%% %%%%%%%%%%%%%%%%