Dillenbourg (TECFA), Ion Dumitrache
(POLITEHNICA), Catalin Buiu (POLITEHNICA),
Cristian Ceconvciuc (POLITEHNICA)
1. Read from socket.
2. Design problems.
3. Extract function.
4. Memory problems.
1. Read from socket
There is in PROLOG the socket functions which connect,
write and read with. The steps from agents are:
||connect(host,port,ClientSocket)||Connect to the MOO: host is 'tecfamoo.unige.ch', port is 7777 and ClientSocket is a variable|
||write_sock(ClientSocket, string_to_write)||Write via socket something to MOO|
||read_sock(ClientSocket, read_string)||Read something from the MOO via socket|
2. Design problems
In sock_writeln(ClinetSocket,Message) and sock_readln(ClientSocket,Answer)
PROLOG functions Message and Answer variable are string ASCII code type.
Facts who are asserted by agents are atom type. When I want to give some
advice to the other agent I assert one fact like this: fact(advice('page
sherlock something')). After that I call fact(advice(Q)) and transform
Q in ASCII code with name(Q,QQ) function and send QQ to the MOO.
All that is because I can't write Message or Answer called write(Message) function (the result is an ASCII list of contents of Message), but I can write 'page sherlock something' (QQ is like this: "page sherlock something"). Now you can see normally what the agents facts are exchanged... (in the agents log files).
Another design problem was the communication between agents and between agent and MOO, because was necessary to make a difference between MOO facts and Agent facts. The agent send facts who contain the name of the agent who send them (see example communication between Hercule and Sherlock)
3. Extract function
From one string received from the MOO I made the
extraction function which extract different facts or goals who are sending
by the MOO or by the other agent. I made the difference between MOO and
the other agent facts and goals, because it's important for inference part
to know which one send something: the MOO or the other agent. The example
for that is in qextract1.txt
and qextract2.txt (which are
included support.txt file).
I had also some problem with Prolog memory, because
there are many facts asserted who keep memory space occupied, but I found
a solution for that:
- I allocated more memory for both agents (16M as heap memory for each agents);
- I used some Prolog instructions who minimized the memory space like 'garbage_collect' which is called one time per main cycle;
- I allocated more less goals for the agents - it seems that they keep a lot of memory and there is some kind of restrictions for goals.