import planner. import cp. main => % One 1-rotation: Init = [2,3,7,4,1,6,11,8,5,9,10,12,13,14,15,16], % 2,1 % Init = [2,7,4,8,1,3,11,12,5,6,9,10,13,14,15,16], % 1,2,1 % Init = [7,4,11,8,2,3,9,12,1,5,6,10,13,14,15,16], % 1,2,3 % Init = [3,4,11,8,1,2,10,12,6,5,7,15,9,13,14,16], % 1,2,3,2,2,3 % Init = [8,12,7,15,1,4,2,10,3,6,11,14,5,9,13,16 ], % 4,4,4,1,2,3,2,2,3 % Init = [8,12,7,15,1,14,16,13,3,10,11,9,5,2,4,6 ], % Random puzzle % Init = [2,4,16,11,15,7,12,1,8,9,14,3,10,5,13,6], % swap 15<->16 (GAP says 53 moves,but that's probably not optimal ) % Init = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,15 ], % time(best_plan_unbounded(Init, 10,L,Cost)), % Neng-Fa's original (2,1 problem: heap error) % time(best_plan(Init, 10,L,Cost)), % solve 2,1 problem in 2.2 seconds % time(plan(Init, L)), % solves 2,1 problem: heap error % time(best_plan(Init, 9,L,Cost)), % solves 2,1 problem in 0.376 seconds % time(best_plan(Init, 9,L,Cost)), % solves 2,1 problem in 0.376 seconds % solve 4,4,4,1,2,3,2,2,3 in 2.42s % time(best_plan(Init, 10,L,Cost)), % solves 2,1 problem in 2.2s seconds % solve 4,4,4,1,2,3,2,2,3 in 8.8s % time(best_plan(Init, L)), time(best_plan(Init, 40,L,Cost)), writeln(L), writeln(len=L.length), writeln(cost=Cost), nl. % hakank: go2 => % One 1-rotation: % Init = [2,3,7,4,1,6,11,8,5,9,10,12,13,14,15,16], % 2,1 % Init = [2,7,4,8,1,3,11,12,5,6,9,10,13,14,15,16], % 1,2,1 % Init = [7,4,11,8,2,3,9,12,1,5,6,10,13,14,15,16], % 1,2,3 % Init = [3,4,11,8,1,2,10,12,6,5,7,15,9,13,14,16], % 1,2,3,2,2,3 % Init = [8,12,7,15,1,4,2,10,3,6,11,14,5,9,13,16 ], % 4,4,4,1,2,3,2,2,3 % Init = [8,12,7,15,1,14,16,13,3,10,11,9,5,2,4,6 ], % Random puzzle Init = [2,4,16,11,15,7,12,1,8,9,14,3,10,5,13,6], % swap 15<->16 (GAP says 53 moves,but that's probably not optimal ) % Init = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,15 ], Limit :: 2..20, indomain(Limit), writeln(limit=Limit), if time(best_plan(Init, Limit,L,Cost)) then writeln(L), writeln(len=L.length), writeln(cost=Cost), nl else fail end, nl. final(Goal) => Goal=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]. % table % 1, 2, 3, 7, 11, 10, 9, 5, % move 1 (around 6) action([M1,M2,M3,M4,M5,M6,M7,M8,M9,M10,M11,M12,M13,M14,M15,M16],To,M,Cost) ?=> M=1, Cost=1, To=[M5,M1,M2,M4,M9,M6,M3,M8,M10,M11,M7,M12,M13,M14,M15,M16]. % 2, 3, 4, 8, 12, 11, 10, 6, % move 2 (around 7) action([M1,M2,M3,M4,M5,M6,M7,M8,M9,M10,M11,M12,M13,M14,M15,M16],To,M,Cost) ?=> M=2, Cost=1, To=[M1,M6,M2,M3,M5,M10,M7,M4,M9,M11,M12,M8,M13,M14,M15,M16]. % 5, 6, 7, 11, 15, 14, 13, 9, % move 3 (around 10) action([M1,M2,M3,M4,M5,M6,M7,M8,M9,M10,M11,M12,M13,M14,M15,M16],To,M,Cost) ?=> M=3, Cost=1, To=[M1,M2,M3,M4,M9,M5,M6,M8,M13,M10,M7,M12,M14,M15,M11,M16]. % 6, 7, 8, 12, 16, 15, 14, 10, % move 4 (around 11) action([M1,M2,M3,M4,M5,M6,M7,M8,M9,M10,M11,M12,M13,M14,M15,M16],To,M,Cost) => M=4, Cost=1, To=[M1,M2,M3,M4,M5,M10,M6,M7,M9,M14,M11,M8,M13,M15,M16,M12].