% Towers of hanoi program from Clocksin & Mellish (p 137)

% Strategy:
%	Stop when there are no more discs on the left.
%	Move N-1 discs from the source pole to the spare pole,
%	using the destination as spare.
%	Move a single disc from the source to the destination.
%	Move N-1 discs from the spare to the destination,
%	using the source as the spare.

hanoi(N) :- move(N, left, centre, right).

move(0, _, _, _) :- !.
move(N, A, B, C) :-
	M is N - 1,
	move(M, A, C, B),
	print('Move a disc from the ', A, ' pole to the ', B, ' pole.'),
	move(M, C, B, A).
