:-object hanoi.
        main :-
                disks(4, peg1,peg2,peg3).

        disks(1, P1,P2,_) :-
                !,
                disk_move(1, P1,P2).

        disks(N, P1,P2,P3) :-
                N1 is N - 1,
                disks(N1, P1,P3,P2),
                disk_move(N, P1,P2),
                disks(N1, P3,P2,P1).

        disk_move(DiskN, PegFrom, PegTo) :-
                format('move disk~w from ~w to ~w~n',  [DiskN, PegFrom, PegTo]).

:-end_object hanoi.

