示例#1
0
 /// <summary>
 /// This function is called -by the environment- when this agent receives a message from another agent.
 /// It updates the best known position with the most radiation intensity.
 /// </summary>
 /// <param name="Message">The message received from the other agent.</param>
 public void Receive(AgentMessage Message)
 {
     // If the other agent knows a better spot, update the best known position.
     if (Message.Value >= OthersBestValue)
     {
         OthersBestValue = Message.Value;
         OthersBestX     = Message.PX;
         OthersBestY     = Message.PY;
     }
 }
示例#2
0
 /// <summary>
 /// This function is used by all the agents to send messages to eachother.
 /// </summary>
 /// <param name="SendingAgent">Represents the agent who is sending.</param>
 /// <param name="Message">Represents the message which is being sent.</param>
 private void Send(Agent SendingAgent, AgentMessage Message)
 {
     foreach (Agent a in Agents)
     {
         // Check if an agent will receive the message sent by the SendingAgent.
         if (WillTheAgentReceiveTheMessage(SendingAgent, a))
         {
             // Send the message to the agent.
             a.Receive(Message);
         }
     }
 }