#hide rotate/3. #hide color/4. :- chosenTile(X,Y,N), not row(Y). :- chosenTile(X,Y,N), not col(X). :- chosenTile(X,Y,N), not tile(N). :- chosenRotation(X,Y,R), not row(Y). :- chosenRotation(X,Y,R), not col(X). :- chosenRotation(X,Y,R), not rotation(R). rotate(R,0,R) :- rotation(R). rotate(top,90,right). rotate(top,180,bottom). rotate(top,270,left). rotate(right,90,bottom). rotate(right,180,left). rotate(right,270,top). rotate(bottom,90,left). rotate(bottom,180,top). rotate(bottom,270,right). rotate(left,90,top). rotate(left,180,right). rotate(left,270,bottom). :- not 1 { chosenTile(X,Y,N) : row(Y) : col(X) } 1, tile(N). :- not 1 { chosenTile(X,Y,N) : tile(N) } 1, row(Y), col(X). :- not 1 { chosenRotation(X,Y,R) : rotation(R) } 1, row(Y), col(X). color(X,Y,SR,C) :- chosenTile(X,Y,N), chosenRotation(X,Y,R), tileSide(N,S,C), rotate(S,R,SR). :- color(X,Y,right,C1), color(X+1,Y,left,C2), C1 != C2. :- color(X,Y,bottom,C1), color(X,Y+1,top,C2), C1 != C2.