/// <summary> /// This method creates a separate agent using the information passed to it. /// Then it places the agent on the environment and passes information about it to it. /// </summary> public void CreateAgent(string name, bool status, AgentRole role, Goal goals, WorldContext beliefs, string spawnLocationName) { // We clone locations from the world. Dictionary <LocationStatic, LocationDynamic> locations = currentStoryState.CloneLocations(); // We construct a new agent, from static and dynamic parts. AgentStateStatic newAgentStateStatic = new AgentStateStatic(name, role); AgentStateDynamic newAgentStateDynamic = new AgentStateDynamic(status, goals, beliefs, newAgentStateStatic); KeyValuePair <AgentStateStatic, AgentStateDynamic> newAgent = new KeyValuePair <AgentStateStatic, AgentStateDynamic>(newAgentStateStatic, newAgentStateDynamic); // Add the agent to the list of agents. currentStoryState.AddAgent(newAgent, currentStoryState.GetLocationByName(spawnLocationName)); // We transfer information about the locations in the world to the agent. newAgent.Value.GetBeliefs().SetLocationsInWorld(locations); // We inform the agent in which location it was created. newAgent.Value.GetBeliefs().SetMyLocation(newAgent.Value.GetBeliefs().GetLocationByName(spawnLocationName)); newAgent.Value.GetBeliefs().AddAgentInBeliefs(newAgent, newAgent.Key.GetRole()); newAgent.Value.GetBeliefs().GetAgentByName(newAgent.Key.GetName()). SetLocation(newAgent.Value.GetBeliefs().GetLocationByName(spawnLocationName)); }