/* Basic Agent Class. Encapsulates P2P abilities (client + server) and goal oriented behavor. */ :-[prolog_object]. :-[client]. :-[server]. /* Self centered test agent: its client component talks to its server component on a local port. */ start:- agent(behave,2000,localhost,2000,agatha). /* - runs a goal in background - listens on a local port as a server - sets up client side communication with a remote server on a given host and port */ agent(Goal,LocalPort,RemoteHost,RemotePort,Password):- server(LocalPort,Password), client(RemoteHost,RemotePort,Password), bg(serve), bg(Goal). behave:-behave(5). behave(N):- for(I,1,N), sleep(1), ask(println(message(I,from(default_agent)))), I=N.