/// <summary> /// A method that creates an initial state of the world based on user preferences. /// </summary> public void CreateInitialState() { if (manualInput) // Demo story { // === LOCATIONS CREATING === // We create locations, determine their names and the presence of evidence in them. List <string> locationNames = CreateLocationsNamesList(locationsCounter); List <bool> locationsEvidences = CreateLocationsEvidencesList(locationsCounter); Dictionary <LocationStatic, LocationDynamic> locations = CreateLocationSet(locationNames, locationsEvidences); // The first step in creating the initial state is setting up the environment, that is - locations. CreateEnviroment(locations); // === AGENTS CREATING === // We create sets of attributes for agents: names, states, roles, goals, and beliefs. List <string> names = CreateAgentsNamesList(agentsCounter); List <bool> statuses = CreateStatusesList(agentsCounter); List <AgentRole> roles = CreateAgentsRolesList(agentsCounter); List <Goal> goals = CreateGoalSet(roles); List <WorldContext> beliefs = CreateBeliefsSet(agentsCounter); // The second step in creating the initial state is the creation of agents, initially with empty goals and beliefs, // since they are highly dependent on the agents themselves existing in the "world". We'll finish setting this up in the next step. CreateAgents(names, statuses, roles, goals, beliefs, GetRandomLocationName(locationNames), agentsCounter); // We randomly assign an initiative value to the agents to determine the order of their turn, and sort the agents on the initiative. DistributionOfInitiative(); currentStoryState.OrderAgentsByInitiative(); // The third step in creating an initial state is assigning to agents their goals and beliefs. // === Goals === // // Go through all the agents in the world. foreach (var agent in currentStoryState.GetAgents()) { // If the agent's goal is to save/kill someone. if (agent.Value.GetGoal().goalTypeIsStatus == true) { // Unless the agent has the role of the killer. if (agent.Key.GetRole() != AgentRole.KILLER) { // Then his goal is that the killer must be neutralized. agent.Value.GetGoal().GetGoalState().AddAgent(AgentRole.KILLER, false, "???"); } // If the agent is the killer. else if (agent.Key.GetRole() == AgentRole.KILLER) { int agentCounter = 0; int playerCounter = 1; int killerCounter = NumberOfKillers(); // Then we go through all the agents. foreach (var anotherAgent in currentStoryState.GetAgents()) { // And for everyone who is not a killer... if (anotherAgent.Key.GetRole() != AgentRole.KILLER) { agentCounter++; // ...add a new "victim" to the goals. if (agentCounter == (currentStoryState.GetAgents().Count() - playerCounter - killerCounter)) { agent.Value.GetGoal().GetGoalState().AddAgent(AgentRole.PLAYER, false, anotherAgent.Key.GetName()); } else { agent.Value.GetGoal().GetGoalState().AddAgent(AgentRole.USUAL, false, anotherAgent.Key.GetName()); } } } } } } // === Beliefs === // // We go through all the agents in the world. foreach (var agent in currentStoryState.GetAgents()) { // For each separately. foreach (var anotherAgent in currentStoryState.GetAgents()) { // If the agent meets himself. if (agent.Equals(anotherAgent)) { continue; } else { // Otherwise, copies the name of the selected agent and by default does not consider him a killer. agent.Value.GetBeliefs().AddAgentInBeliefs(anotherAgent, AgentRole.USUAL); } } } } }