for Towers of Hanoi, the output should look like this:
?-move(3,[1,2,3],[],[],A1,B1,C).
A1=[].
B1=[1,2,3]
C=[].
I know how to do this:
move(1,[H|T],B,C,A1,B1,C) :-
A1 = T,
B1 = [H|B],
C1 = C.
move(N,A,B,C,A1,B1,C) :-
N>1,
M is N-1,
move(M,[H|T],C,B,A1,B1,C),
move(1,[H|T],B,_,A1,B1,C),
move(M,C,B,[H|T],A1,B1,C).
But the next question is: "rewrite the program to provide illustrations of towers after every move". Its output should look like this:
?- move(3,tower(a,[1,2,3]),tower(b,[]),tower(c,[]),A,B,C).
a[2 3] b[1] C[]
a[3] b[1] C[2]
a[3] b[] C[1 2]
a[] b[3] C[1 2]
a[1] b[3] C[2]
a[1] b[2 3] C[]
a[] b[1 2 3] C[]
A = tower(a, [])
B = tower(b,[1, 2, 3])
C = tower(c,[])
How can this be done?