 // Asks to the Agent for the next action int[] action = **this**.GetAction(agent); **long** elapsedTime = agent.GetElapsedTime(); 
 interactions[actualAgent].SetAction(action); interactions[actualAgent].SetElapsedTime(elapsedTime); 
 } 
// Makes the actions made by the Agents for (int actualAgent = 0; actualAgent < **this**.agents.size(); 
actualAgent++) 
 { 
 Agent agent = **this**.agents.get(actualAgent); int[] action = interactions[actualAgent].GetAction(); 
 **this**.MakeAction(agent, action); 
 } 
// If Good and Evil Agents are in the same cell one of them doesn't move if (**this**.goodAgent.GetLocation() == **this**.evilAgent.GetLocation()) 
 // If the Good Agent didn't move the Evil Agent doesn't move if (**this**.goodAgent.GetLocation() == goodCell) **this**.LocateAgent(**this**.evilAgent, evilCell.GetNumber()); 
 // If the Evil Agent didn't move the Good Agent doesn't move else if (**this**.evilAgent.GetLocation() == evilCell) **this**.LocateAgent(**this**.goodAgent, goodCell.GetNumber()); 
 // If both Agents had move one of them doesn't move **else** if (new Random().nextInt(2) == 0) **this**.LocateAgent(**this**.goodAgent, goodCell.GetNumber()); else this.LocateAgent(**this**.evilAgent, evilCell.GetNumber()); 
// Set rewards to the Agents for (int actualAgent = 0; actualAgent < **this**.agents.size(); 
actualAgent++) 
 { 
 Agent agent = **this**.agents.get(actualAgent); 
 // Evaluates the Agent action in the Environment
 **double** obtainedReward = **this**.EvaluateAction(agent, interactions[actualAgent]); 
 interactions[actualAgent].SetReward(obtainedReward); } 
// Update the rewards of all cells by dividing by 2 for (int index = 1; index <= **this**.space.GetNumberOfCells(); 
index++) 
 { 
 Cell cell = **this**.space.GetCell(index); 
 cell.SetReward(cell.GetReward() / 2); 
 } 
// Update the reward to 0 of all cells where there is an Agent for (Agent agent:**this**.agents) 
 { Cell cell = agent.GetLocation(); 
 cell.SetReward(0.0); 
 } 
}