I have the following requirement in JADE. I have to create multiple agents whose task is to generate random numbers. Another receiver agent collects all the random numbers generated and sums them up to make a decision. This is the sender agent class extends tickerbehaviour and its tick onTick method is as follows
protected void onTick()
{
ACLMessage msg_LoadDetails = new ACLMessage(ACLMessage.INFORM);
msg_LoadDetails.addReceiver(new AID("LoadCoordinator", AID.ISLOCALNAME));
msg_LoadDetails.setContent(String.valueOf(getLoad()));
LoadConv.send(msg_LoadDetails);
//load = (int)(Math.random()*1000+1);
}
The receiver class extend cyclic behaviour and its action method is as follows
public void action()
{
ACLMessage msg_IncomingLoadDetails = LoadCoordinator.receive();
if(msg_IncomingLoadDetails!=null)
totalLoad = Integer.parseInt(msg_IncomingLoadDetails.getContent());
if(totalLoad>500)
{actioncommand = "off";}
else
{actioncommand = "on";}
System.out.println("The current load is:" +totalLoad+ "; the load will be switched " +actioncommand);
block();
}
The issue here is that the received values are just for one agent which i create (from console). I want to receive values for all created agents. Does this require me create an array of agents? How do i read values from many agent messages? Could some one please help with the code to do so as I am new to JAVA and JADE?