home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / proglang / pie2.arj / GRAPH.PRO < prev    next >
Text File  |  2000-01-01  |  3KB  |  131 lines

  1.  
  2.   % converse/0
  3.   converse():-
  4.     temp(S),
  5.     S = quit,
  6.     !,
  7.     purge.
  8.   converse():-
  9.     retract(temp(S)),
  10.     doctor(S),
  11.     write(": "),
  12.     readln(P),
  13.     patient(P),
  14.     !,
  15.     converse.
  16.  
  17.   converse():-
  18.     doctor(""),
  19.     write(": "),
  20.     readln(P),
  21.     patient(P),
  22.     !,
  23.     converse.
  24.  
  25.   % doctor/1
  26.   doctor(""):-
  27.     retract(topics(R)),
  28.     not R = "",
  29.     write("You just said ",`"),
  30.     write(R,`"),
  31.     nl,
  32.     write("Tell me more..."),
  33.     nl.
  34.   doctor(""):-
  35.     retract(responses(R)),
  36.     assertz(responses(R)),
  37.     write(R),
  38.     nl.
  39.   doctor(S):-
  40.     respond(S),
  41.     assert(topics(S)),
  42.     nl.
  43.   doctor(_):-
  44.     retract(topics(R)),
  45.     not R = "",
  46.     write("You just said ",`"),
  47.     write(R,`"),
  48.     nl,
  49.     write("Tell me more..."),
  50.     nl.
  51.  
  52.   % patient/1
  53.   patient(S):-
  54.     patresponses(S),
  55.     not(member(S,["","why","yes","no","maybe"])),
  56.     write("You are repeating yourself."),
  57.     nl,
  58.     write(": "),
  59.     readln(S2),
  60.     !,
  61.      patient(S2).
  62.  
  63.   patient(S):-
  64.     assert(patresponses(S)),
  65.     assert(temp(S)).
  66.  
  67.   % purge/0
  68.   purge():-
  69.     retract(translate(_,_)),
  70.     fail.
  71.   purge():-
  72.     retract(temp(_)),
  73.     fail.
  74.   purge():-
  75.     retract(responses(_)),
  76.     fail.
  77.   purge():-
  78.     retract(topics(_)),
  79.     fail.
  80.   purge():-
  81.     retract(patresponses(_)),
  82.     fail.
  83.   purge().
  84.  
  85.   % respond/1
  86.   respond(""):-
  87.     fail.
  88.   respond(S):-
  89.     fronttoken(S,T,_),
  90.     translate(T,T2),
  91.     write(T2," ").
  92.   respond(S):-
  93.     fronttoken(S,_,S2),
  94.     !,
  95.     respond(S2).
  96.  
  97.   % responses/1
  98.   responses("How are you this beautiful day?").
  99.   responses("Did you have a happy childhood?").
  100.   responses("Do you hate your father?").
  101.   responses("I'm not sure I understand").
  102.   responses("Go on ").
  103.   responses("Do you have friends?").
  104.   responses("Why don't you talk about something else?").
  105.   responses("Do you like your Computer Methods teacher?").
  106.  
  107.   % temp/1
  108.   temp("").
  109.  
  110.   % translate/2
  111.   translate("unhappy","Why are you unhappy?").
  112.   translate("think","Why do you think that?").
  113.   translate("you","Let's not talk about me.").
  114.   translate("hate","So you hate to tell me more.").
  115.   translate("what","Why do you ask?").
  116.   translate("want","What would you do with it?").
  117.   translate("need","We all need many things.").
  118.   translate("why","Remember, therapy is good for you.").
  119.   translate("know","How do you know that?").
  120.   translate("murder","I don't like killing.").
  121.   translate("kill","It is wrong to kill").
  122.   translate("jerk","Don't you ever call me a jerk!").
  123.   translate("never","Don't be negative; think positive!").
  124.   translate("failure","Make it a success").
  125.   translate("stupid","Stupid is not a nice word").
  126.   translate("sure","It is good to be confident").
  127.  
  128. member(X,[X|_]).
  129. member(X,[_|Rest]):-
  130.     !,
  131.     member(X,Rest).