% Run this with prova[.bat] ex050.prova -t -1
% Demonstrate that indefinitely alive agents are terminated by a message on
%    protocol 'self' with performative 'shutdown'
% In order to terminate an agent remotely,
%    1. sent an agreed message to the agent
%        (normally, you can agree on the use of performative 'shutdown'),
%    2. intercept the message with a reaction rule which will send a 'self'
%        'shutdown' message that will terminate the agent. Note that any messages
%        appearing after the external 'shutdown' and 'internal' shutdown
%        will still be executed.
% The example also is a reminder that goals X(Payload)
%    with predicates X other than 'eval' or 'solve' are
%    sent as messages on protocol 'self' with performative equal to X and payload 'Payload'

:- toto(hello()).
:- shutdown(payload()).

% Shutdown procedure
shutdown() :-
	println(["Shutdown complete."]).

rcvMsg(XID,Protocol,From,Perf,Payload|Context) :-
	println([From,Protocol,Perf,Payload]," "). 
