%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % CSCI 4220 - Coke Case Mastermind - By: Matthew Reeves % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%% % Initial state for game % %%%%%%%%%%%%%%%%%%%%%%%%%%%% win :- Start = [[x,c,c,c,c,c], [c,c,c,c,c,c], [c,c,c,c,c,c], [c,c,c,c,c,c]], build(Start). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Convert list of lists to a single list to process moves % %%%%%%%%%%%%%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ build([Head|Tail]) :- build(Head, Tail). build(Array, [Head|Tail]) :- append(Array, Head, Built), build(Built, Tail). build(Array, []) :- Acc is 0, move(Array, Acc), write(Array), write(' Game Starting State.'), pretty(Array). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Print current game state in a more visually pleasing way % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% pretty([A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,Y,Z]) :- nl, nl, write(A), write(' '), write(B), write(' '), write(D), write(' '), write(E), write(' '), write(F), write(' '), write(G), nl, write(H), write(' '), write(I), write(' '), write(J), write(' '), write(K), write(' '), write(L), write(' '), write(M), nl, write(N), write(' '), write(O), write(' '), write(P), write(' '), write(Q), write(' '), write(R), write(' '), write(S), nl, write(T), write(' '), write(U), write(' '), write(V), write(' '), write(W), write(' '), write(Y), write(' '), write(Z), nl, nl. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Moves to the left for first row % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move([x,c,c|Rest], Acc) :- Arr = [c,x,x|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was left.'), pretty(Arr). move([Y,x,c,c|Rest], Acc) :- Arr = [Y,c,x,x|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was left.'), pretty(Arr). move([Y,Z,x,c,c|Rest], Acc) :- Arr = [Y,Z,c,x,x|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was left.'), pretty(Arr). move([Y,Z,T,x,c,c|Rest], Acc) :- Arr = [Y,Z,T,c,x,x|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was left.'), pretty(Arr). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Moves to the right for first row % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move([c,c,x|Rest], Acc) :- Arr = [x,x,c|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was right.'), pretty(Arr). move([Y,c,c,x|Rest], Acc) :- Arr = [Y,x,x,c|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was right.'), pretty(Arr). move([Y,Z,c,c,x|Rest], Acc) :- Arr = [Y,Z,x,x,c|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was right.'), pretty(Arr). move([Y,Z,T,c,c,x|Rest], Acc) :- Arr = [Y,Z,T,x,x,c|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was right.'), pretty(Arr). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Moves to the left for second row % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move([A,B,D,E,F,G,x,c,c|Rest], Acc) :- Arr = [A,B,D,E,F,G,c,x,x|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was left.'), pretty(Arr). move([A,B,D,E,F,G,Y,x,c,c|Rest], Acc) :- Arr = [A,B,D,E,F,G,Y,c,x,x|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was left.'), pretty(Arr). move([A,B,D,E,F,G,Y,Z,x,c,c|Rest], Acc) :- Arr = [A,B,D,E,F,G,Y,Z,c,x,x|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was left.'), pretty(Arr). move([A,B,D,E,F,G,Y,Z,T,x,c,c|Rest], Acc) :- Arr = [A,B,D,E,F,G,Y,Z,T,c,x,x|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was left.'), pretty(Arr). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Moves to the right for the second row % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move([A,B,D,E,F,G,c,c,x|Rest], Acc) :- Arr = [A,B,D,E,F,G,x,x,c|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was right.'), pretty(Arr). move([A,B,D,E,F,G,Y,c,c,x|Rest], Acc) :- Arr = [A,B,D,E,F,G,Y,x,x,c|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was right.'), pretty(Arr). move([A,B,D,E,F,G,Y,Z,c,c,x|Rest], Acc) :- Arr = [A,B,D,E,F,G,Y,Z,x,x,c|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was right.'), pretty(Arr). move([A,B,D,E,F,G,Y,Z,T,c,c,x|Rest], Acc) :- Arr = [A,B,D,E,F,G,Y,Z,T,x,x,c|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was right.'), pretty(Arr). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Moves to the left for the third row % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move([A,B,D,E,F,G,H,I,J,K,L,M,x,c,c|Rest], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,M,c,x,x|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was left.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,K,L,M,Y,x,c,c|Rest], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,M,Y,c,x,x|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was left.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,K,L,M,Y,Z,x,c,c|Rest], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,M,Y,Z,c,x,x|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was left.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,K,L,M,Y,Z,T,x,c,c|Rest], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,M,Y,Z,T,c,x,x|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was left.'), pretty(Arr). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Moves to the right for the third row % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move([A,B,D,E,F,G,H,I,J,K,L,M,c,c,x|Rest], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,M,x,x,c|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was right.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,K,L,M,Y,c,c,x|Rest], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,M,Y,x,x,c|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was right.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,K,L,M,Y,Z,c,c,x|Rest], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,M,Y,Z,x,x,c|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was right.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,K,L,M,Y,Z,T,c,c,x|Rest], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,M,Y,Z,T,x,x,c|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was right.'), pretty(Arr). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Moves to the left for the fourth row % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move([A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,x,c,c|Rest], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,c,x,x|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was left.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,Y,x,c,c|Rest], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,Y,c,x,x|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was left.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,Y,Z,x,c,c|Rest], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,Y,Z,c,x,x|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was left.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,Y,Z,T,x,c,c], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,Y,Z,T,c,x,x], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was left.'), pretty(Arr). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Moves to the right for the fourth row % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move([A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,c,c,x|Rest], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,x,x,c|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was right.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,Y,c,c,x|Rest], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,Y,x,x,c|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was right.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,Y,Z,c,c,x|Rest], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,Y,Z,x,x,c|Rest], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was right.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,Y,Z,T,c,c,x], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,Y,Z,T,x,x,c], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was right.'), pretty(Arr). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Moves up and down for the first column % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move([c,B,D,E,F,G,c,I,J,K,L,M,x,O,P,Q,R,S,T,U,V,W,Y,Z], Acc) :- Arr = [x,B,D,E,F,G,x,I,J,K,L,M,c,O,P,Q,R,S,T,U,V,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was down.'), pretty(Arr). move([x,B,D,E,F,G,c,I,J,K,L,M,c,O,P,Q,R,S,T,U,V,W,Y,Z], Acc) :- Arr = [c,B,D,E,F,G,x,I,J,K,L,M,x,O,P,Q,R,S,T,U,V,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was up.'), pretty(Arr). move([A,B,D,E,F,G,c,I,J,K,L,M,c,O,P,Q,R,S,x,U,V,W,Y,Z], Acc) :- Arr = [A,B,D,E,F,G,x,I,J,K,L,M,x,O,P,Q,R,S,c,U,V,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was down.'), pretty(Arr). move([A,B,D,E,F,G,x,I,J,K,L,M,c,O,P,Q,R,S,c,U,V,W,Y,Z], Acc) :- Arr = [A,B,D,E,F,G,c,I,J,K,L,M,x,O,P,Q,R,S,x,U,V,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was up.'), pretty(Arr). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Moves up and down for the second column % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move([A,c,D,E,F,G,H,c,J,K,L,M,N,x,P,Q,R,S,T,U,V,W,Y,Z], Acc) :- Arr = [A,x,D,E,F,G,H,x,J,K,L,M,N,c,P,Q,R,S,T,U,V,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was down.'), pretty(Arr). move([A,x,D,E,F,G,H,c,J,K,L,M,N,c,P,Q,R,S,T,U,V,W,Y,Z], Acc) :- Arr = [A,c,D,E,F,G,H,x,J,K,L,M,N,x,P,Q,R,S,T,U,V,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was up.'), pretty(Arr). move([A,B,D,E,F,G,H,c,J,K,L,M,N,c,P,Q,R,S,T,x,V,W,Y,Z], Acc) :- Arr = [A,B,D,E,F,G,H,x,J,K,L,M,N,x,P,Q,R,S,T,c,V,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was down.'), pretty(Arr). move([A,B,D,E,F,G,H,x,J,K,L,M,N,c,P,Q,R,S,T,c,V,W,Y,Z], Acc) :- Arr = [A,B,D,E,F,G,H,c,J,K,L,M,N,x,P,Q,R,S,T,x,V,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was up.'), pretty(Arr). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Moves up and down for the third column % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move([A,B,c,E,F,G,H,I,c,K,L,M,N,O,x,Q,R,S,T,U,V,W,Y,Z], Acc) :- Arr = [A,B,x,E,F,G,H,I,x,K,L,M,N,O,c,Q,R,S,T,U,V,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was down.'), pretty(Arr). move([A,B,x,E,F,G,H,I,c,K,L,M,N,O,c,Q,R,S,T,U,V,W,Y,Z], Acc) :- Arr = [A,B,c,E,F,G,H,I,x,K,L,M,N,O,x,Q,R,S,T,U,V,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was up.'), pretty(Arr). move([A,B,D,E,F,G,H,I,c,K,L,M,N,O,c,Q,R,S,T,U,x,W,Y,Z], Acc) :- Arr = [A,B,D,E,F,G,H,I,x,K,L,M,N,O,x,Q,R,S,T,U,c,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was down.'), pretty(Arr). move([A,B,D,E,F,G,H,I,x,K,L,M,N,O,c,Q,R,S,T,U,c,W,Y,Z], Acc) :- Arr = [A,B,D,E,F,G,H,I,c,K,L,M,N,O,x,Q,R,S,T,U,x,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was up.'), pretty(Arr). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Moves up and down for the fourth column % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move([A,B,D,c,F,G,H,I,J,c,L,M,N,O,P,x,R,S,T,U,V,W,Y,Z], Acc) :- Arr = [A,B,D,x,F,G,H,I,J,x,L,M,N,O,P,c,R,S,T,U,V,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was down.'), pretty(Arr). move([A,B,D,x,F,G,H,I,J,c,L,M,N,O,P,c,R,S,T,U,V,W,Y,Z], Acc) :- Arr = [A,B,D,c,F,G,H,I,J,x,L,M,N,O,P,x,R,S,T,U,V,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was up.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,c,L,M,N,O,P,c,R,S,T,U,V,x,Y,Z], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,x,L,M,N,O,P,x,R,S,T,U,V,c,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was down.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,x,L,M,N,O,P,c,R,S,T,U,V,c,Y,Z], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,c,L,M,N,O,P,x,R,S,T,U,V,x,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was up.'), pretty(Arr). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Moves up and down for the fifth column % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move([A,B,D,E,c,G,H,I,J,K,c,M,N,O,P,Q,x,S,T,U,V,W,Y,Z], Acc) :- Arr = [A,B,D,E,x,G,H,I,J,K,x,M,N,O,P,Q,c,S,T,U,V,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was down.'), pretty(Arr). move([A,B,D,E,x,G,H,I,J,K,c,M,N,O,P,Q,c,S,T,U,V,W,Y,Z], Acc) :- Arr = [A,B,D,E,c,G,H,I,J,K,x,M,N,O,P,Q,x,S,T,U,V,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was up.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,K,c,M,N,O,P,Q,c,S,T,U,V,W,x,Z], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,x,M,N,O,P,Q,x,S,T,U,V,W,c,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was down.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,K,x,M,N,O,P,Q,c,S,T,U,V,W,c,Z], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,c,M,N,O,P,Q,x,S,T,U,V,W,x,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was up.'), pretty(Arr). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Moves up and down for the sixth column % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move([A,B,D,E,F,c,H,I,J,K,L,c,N,O,P,Q,R,x,T,U,V,W,Y,Z], Acc) :- Arr = [A,B,D,E,F,x,H,I,J,K,L,x,N,O,P,Q,R,c,T,U,V,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was down.'), pretty(Arr). move([A,B,D,E,F,x,H,I,J,K,L,c,N,O,P,Q,R,c,T,U,V,W,Y,Z], Acc) :- Arr = [A,B,D,E,F,c,H,I,J,K,L,x,N,O,P,Q,R,x,T,U,V,W,Y,Z], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was up.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,K,L,c,N,O,P,Q,R,c,T,U,V,W,Y,x], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,x,N,O,P,Q,R,x,T,U,V,W,Y,c], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was down.'), pretty(Arr). move([A,B,D,E,F,G,H,I,J,K,L,x,N,O,P,Q,R,c,T,U,V,W,Y,c], Acc) :- Arr = [A,B,D,E,F,G,H,I,J,K,L,c,N,O,P,Q,R,x,T,U,V,W,Y,x], NewAcc is Acc + 1, move(Arr, NewAcc), write(Arr), write(' Move '), write(NewAcc), write(' was up.'), pretty(Arr). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Once 22 moves have been made puzzle has been solved % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move(_, 22) :- nl, write('Solution Found!'), nl, nl.