/// <summary> /// Adds an agent to the environment. The agent should already have a name and its name should be unique. /// </summary> /// <param name="agent">The concurrent agent that will be added</param> public void AddAgent(ReactiveAgent agent) { if (agent == null || agent.IsNull) { throw new ArgumentNullException(nameof(agent)); } if (Agents.Exists(agent.AgentId)) { // todo => throw new ArgumentException("Trying to add an agent " + agent.AgentId.ClassId + " with an existing key: " + agent.AgentId); //todo should be done only in reference Agents.Remove(agent.AgentId); } Agents.Add(agent); //todo should be done only in reference if (!_agentsReference.Exists(x => x.AgentId.Equals(agent.AgentId))) { _agentsReference.Add(agent); } }
public bool ExistsAgent(IAgentId agentId) { return(Agents.Exists(agentId)); }