i currently write a Solver for the Basic Instant-Insanity. My program tells me alltime "NO" as it cant find a solution for my problem and i am to confused to find a fail. Can anyone provide me some help? Even a simple tip can be enough. Thanks alot!
ps: i am using GNU Prolog 1.4.5
pps : solutionnormal(l) should print me l with the cube list in it.
/*
| |
| 3 |
-----------------
| 5 | 1 | 6 | 2 |
-----------------
| |
| 4 |
numeration of grid faces, for our problem is 1,2,5,6 interesting
*/
%basecubes
cube(1,[r,w,w,b,r,g]).
cube(2,[r,b,w,g,b,w]).
cube(3,[r,g,b,b,g,w]).
cube(4,[r,r,r,b,w,g]).
%possible rotations
rotate(S, [X1,X2,X3,X4,X5,X6]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X3,X2,X5,X4,X6,X1]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X5,X2,X6,X4,X1,X3]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X6,X2,X1,X4,X3,X5]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X6,X1,X4,X5,X3,X2]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X4,X1,X3,X5,X2,X6]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X3,X1,X2,X5,X6,X4]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X2,X1,X6,X5,X4,X3]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X2,X6,X5,X3,X4,X1]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X5,X6,X4,X3,X1,X2]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X4,X6,X1,X3,X2,X5]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X1,X6,X2,X3,X5,X4]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X5,X4,X3,X2,X1,X6]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X3,X4,X1,X2,X6,X5]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X1,X4,X6,X2,X5,X3]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X6,X4,X5,X2,X3,X1]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X6,X5,X2,X1,X3,X4]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X2,X5,X3,X1,X4,X6]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X3,X5,X4,X1,X6,X2]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X4,X5,X6,X1,X2,X3]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X2,X3,X1,X6,X4,X5]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X1,X3,X4,X6,X5,X2]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X4,X3,X5,X6,X2,X1]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
rotate(S, [X5,X3,X2,X6,X1,X4]) :- cube(S, [X1,X2,X3,X4,X5,X6]).
%my list
l([cube1,cube2,cube3,cube4]).
%solutionnormal().
solutionnormal([cube1,cube2,cube3,cube4]) :-
getfaces([cube1,cube2,cube3,cube4],1,L1), frontdiff(L1),
getfaces([cube1,cube2,cube3,cube4],2,L2), backdiff(L2),
getfaces([cube1,cube2,cube3,cube4],5,L5), leftdiff(L5),
getfaces([cube1,cube2,cube3,cube4],6,L6), rightdiff(L6),
cube1(1, cube1),
rotate(2, cube2),
rotate(3, cube3),
rotate(4, cube4).
%get a list of faces on this side
getfaces([C1,C2,C3,C4], X, List) :-
List = [fd_nth(C1, X),fd_nth(C2,X),fd_nth(C3,X),fd_nth(C4,X)].
%all diff for list
frontdiff(L1) :- fd_all_different(L1).
backdiff(L2) :- fd_all_different(L2).
leftdiff(L5) :- fd_all_different(L5).
rightdiff(L6) :- fd_all_different(L6).