%%%%%%%%%%%%%%%%%%% HERCULE % 11.10.97 12.00 :-[support]. :-[fchain_h]. :-[answers]. /********** MAIN PREDICATE **********************************************/ main:- statistics(runtime,_), new_client('tecfamoo.unige.ch',7777,ClientSocket), assert(socket(ClientSocket)), print('New Socket opened...'),nl, write('Connect Hercule...'),nl, write('Mood ARTIFICIAL...'),nl, write('Move in Detective''s Home...'),nl, write('Initializate mistery...'),nl, sock_writeln(ClientSocket,"connect hercule bt"),sleep(5), % sock_writeln(ClientSocket,"add_other #4243"), sock_writeln(ClientSocket,"@mood ARTIFICIAL"),sleep(1), sock_writeln(ClientSocket,"@move me to Detective's Home"),sleep(3), sock_writeln(ClientSocket,"init_mona"),sleep(5), sock_writeln(ClientSocket,"page sherlock Bonjour, Sherlock. I am HercuLOG. We have to solve the mystery together!"),sleep(2), qloopread([]), % REASONING LOOP repeat, garbage_collect, write('I''m thinking now...'),nl, think, write('I''m asking some questions, if I have to...'),nl, ask2moo, write('I''m reading again, maybe it''s something...'),nl, qloopread([]), goal(mystery_solved), fact(criminal(X)), write('I found the criminal. '),write(X),write(' do it!'),nl, appenda("page sherlock The criminal is ",X,Mes), sock_writeln(ClientSocket,"page sherlock We have solved the mystery. I hope Pierre will agree with our solution!"), sw(ClientSocket, Mes, 2), sock_writeln(ClientSocket,"page sherlock I am disconnecting now. Ciao.."), sock_writeln(ClientSocket,"@quit"), close_socket(ClientSocket), statistics(runtime,[_,T]), write(time=T),nl, statistics, !. /********************* INTERACTION WITH MOO ******************************/ ask2moo:- socket(S), %%%% now writes all the advices without waiting for an answer forall( fact(advice(Q)), ( name(Q,QA), sock_writeln(S,QA),sleep(4), qloopread([]), rf(advice(Q)) ) ), write('I am issuing the COMMANDS !!!'),nl, % writes the commands and waiting for an answer forall( fact(command(Q)), ( name(Q,QA), sock_writeln(S,QA), qloopread(Q), %ATTN: next forall will be complete deleted when all MOO answers will be ok. forall( answer(QA,QX), ( %ATTN: next 2 lines will be deleted when the MOO answer in the right way... name(X1,QX), memansw(Q,X1), (extrf(QX,XX)) ) ), rf(command(Q)), rfmemansw(Q) ) ). ask2moo:-fail.