Resume
Hanoi is a very popular game in acient years. Here’s an implentation of Hanoi with prolog.
Code
hanoi(N) :- move(N,left,center,right).
move(0,_,_,_) :- !.
move(N,A,B,C) :-
M is N-1,
move(M,A,C,B),
inform(A,B),
move(M,C,B,A).
inform(X,Y) :- write('Move from '), write(X), write(' to '), write(Y), write('.'), nl.
Result
?- hanoi(3).
Move from left to center.
Move from left to right.
Move from center to right.
Move from left to center.
Move from right to left.
Move from right to center.
Move from left to center.
true.