-
Notifications
You must be signed in to change notification settings - Fork 7
execute_agent
execute_agent(Agent_name,(IP, Port), Handler) % Executes the default handler code of the agent at the specified platform.
Agent_name: <atom + > IP: <atom + > Port: <integer +> Handler: <atom +>
This predicate is used for starting the executing of an agent which has already been created (and is not executing) on the specified platform. The predicate calls the associated handler predicate with the default ‘main’ keyword within its arguments. Before execution, it removes any running agent with the same name in the platform. The Agent_name is the agent name of the agent on the platform, IP is the IP address and Port is port number of the platform where the Handler is to be executed.
Assume that an agent named myagent is already created. Let the agent’s handler code be as below:
agent_handler(guid,(IP,Port),main):-
writeln(‘Agent’s main function called!!’),
N is 0,
writeln(‘Value of N is ’),
writeln(N).
?- execute_agent(myagent, (localhost,6000),agent_handler).
On successful execution of the above predicate, the result will be:
Agent’s main function called!!
Value of N is 0
Note: The guid atom as the first argument to the handler code is replaced by the name of the agent whenever agent_create/3 is executed. Hence, in agent_execute/3, only name of the agent to be executed is provided.