home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Borland Plateform / Turbo Prolog 2 / EXAMPL34.PRO < prev    next >
Encoding:
Prolog Source  |  1986-04-23  |  903 b   |  28 lines

  1.                /* Program 34 */
  2. predicates
  3.    move(char,integer,integer,integer,integer)
  4.    start
  5.    changestate(integer,integer)
  6. goal
  7.    start.
  8. clauses
  9.    start:-
  10.        graphics(1,1,4),
  11.        line(1000,1000,1000,31000,2),
  12.        line(1000,31000,31000,31000,2),
  13.        line(31000,31000,31000,1000,2),
  14.        line(31000,1000,1000,1000,2),
  15.        changestate(15000,15000).
  16.    changestate(X,Y):-
  17.         readchar(Z),move(Z,X,Y,X1,Y1),changestate(X1,Y1).
  18.    move('r',X,31000,X,31000):- !.
  19.    move('r',X,Yold,X,Ynew):- !,Ynew=Yold+100,dot(X,Yold,3).
  20.    move('l',X,1000,X,1000):- !.
  21.    move('l',X,Yold,X,Ynew):- !,Ynew=Yold-100,dot(X,Yold,3).
  22.    move('u',1000,Y,1000,Y):- !.
  23.    move('u',Xold,Y,Xnew,Y):- !,Xnew=Xold-100,dot(Xold,Y,3).
  24.    move('d',31000,Y,31000,Y):- !.
  25.    move('d',Xold,Y,Xnew,Y):- !,Xnew=Xold+100,dot(Xold,Y,3).
  26.    move('*',_,_,_,_):- !,exit.
  27.    move(_,X,Y,X,Y).
  28.