home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / prolog / library / prolo_c / exampl55.pro < prev    next >
Text File  |  1986-10-06  |  515b  |  24 lines

  1. /* Program 55 */
  2. /*
  3.   Goal on page 118. For more info on this program
  4.   see the HANOI.PRO program on the Library disk.
  5. */
  6.  
  7. domains
  8.     loc = right ; middle ; left
  9.  
  10. predicates
  11.     hanoi(integer)
  12.     move(integer,loc,loc,loc)
  13.     inform(loc,loc)
  14.  
  15. clauses
  16.     hanoi(N) :- move(N,left,middle,right).
  17.  
  18.     move(1,A,_,C) :- inform(A,C),!.
  19.     move(N,A,B,C) :-
  20.         N1=N-1,move(N1,A,C,B),inform(A,C),move(N1,B,A,C).
  21.  
  22.     inform(Loc1,Loc2):-
  23.         write("\nMove a disk from ",Loc1," to ",Loc2).
  24.