I'm fairly new to visual prolog and wondering how can I integrate the code I found on this link.
When I create a console project in Visual Prolog the code in main.pro is:
/*****************************************************************************
Copyright (c) 2013 My Company
******************************************************************************/
implement main
open core
clauses
run():-
console::init(),
succeed(). % place your own code here
end implement main
goal
mainExe::run(main::run).
So, my question is where to insert the code of tower of hanoi on this link?
For your convenience, here's the code:
/* Program ch16e05.pro */
DOMAINS
loc =right;middle;left
PREDICATES
hanoi(integer)
move(integer,loc,loc,loc)
inform(loc,loc)
CLAUSES
hanoi(N):-
move(N,left,middle,right).
move(1,A,_,C):-
inform(A,C),!.
move(N,A,B,C):-
N1=N-1, move(N1,A,C,B),
inform(A,C),move(N1,B,A,C).
inform(Loc1, Loc2):-nl,
write("Move a disk from ", Loc1, " to ", Loc2).
Thanks in advance for any help.
Since the link in your question is broken I provide a new link. You find a PDF of the original turbo Prolog owners handbook here:
Internet Archive, Turbo Prolog Owners Handbook 1987 (1987)
http://archive.org/details/bitsavers_borlandturOwnersHandbook1987_8438592
Therein is the same code with DOMAINS, PREDICATES and CLAUSES. According to the following wikipedia entry, you can move the turbo Prolog code almost unchanged into a visual Prolog system.
Visual Prolog, Hanoi Example
http://en.wikipedia.org/wiki/Visual_Prolog#Hanoi_Example
Use 'predicates' for your public predicates in the interface of the class. And use 'class predicates' for your private predicates in the implementation of the class.
Bye