public bool AssignVariables(ref PlanAction action, WorldDynamic currentState, KeyValuePair<AgentStateStatic, AgentStateDynamic> initiator) { if (action is Entrap || action is CounterEntrap) { foreach (var agent in currentState.GetAgents()) { if ((agent.Key.GetRole() == AgentRole.USUAL || agent.Key.GetRole() == AgentRole.PLAYER) && agent.Value.GetStatus() && !currentState.GetLocation(currentState.SearchAgentAmongLocations(agent.Key)).Value.SearchAgent(initiator.Key) && !agent.Equals(initiator)) { action.Arguments.Add(agent); action.Arguments.Add(initiator); action.Arguments.Add(currentState.GetLocationByName(currentState.SearchAgentAmongLocations(initiator.Key).GetName())); return true; } } return false; } else if (action is Fight || action is CounterFight) { foreach (var agent in currentState.GetAgents()) { if ((agent.Key.GetRole() == AgentRole.USUAL || agent.Key.GetRole() == AgentRole.PLAYER) && agent.Value.GetStatus() && currentState.GetLocation(currentState.SearchAgentAmongLocations(initiator.Key)).Value.SearchAgent(agent.Key)) { action.Arguments.Add(initiator); action.Arguments.Add(agent); action.Arguments.Add(currentState.GetLocation(currentState.SearchAgentAmongLocations(initiator.Key))); return true; } } return false; } else if (action is InvestigateRoom || action is CounterInvestigateRoom) { foreach (var killer in currentState.GetAgents()) { if (killer.Key.GetRole() == AgentRole.KILLER && killer.Value.GetStatus()) { action.Arguments.Add(initiator); action.Arguments.Add(killer); action.Arguments.Add(currentState.GetLocationByName(currentState.SearchAgentAmongLocations(initiator.Key).GetName())); return true; } } return false; } else if (action is Kill || action is CounterKill) { foreach (var agent in currentState.GetAgents()) { if ((agent.Key.GetRole() == AgentRole.USUAL || agent.Key.GetRole() == AgentRole.PLAYER) && agent.Value.GetStatus() && currentState.GetLocation(currentState.SearchAgentAmongLocations(initiator.Key)).Value.SearchAgent(agent.Key)) { action.Arguments.Add(agent); action.Arguments.Add(initiator); action.Arguments.Add(currentState.GetLocation(currentState.SearchAgentAmongLocations(initiator.Key))); return true; } } return false; } else if (action is Move || action is CounterMove) { if (action.Arguments.Count() != 0) { List<string> arguments = new List<string>(); foreach (var argument in action.Arguments) { arguments.Add((string)argument); } action.Arguments.Clear(); action.Arguments.Add(initiator); action.Arguments.Add(currentState.GetLocationByName(arguments[1])); action.Arguments.Add(currentState.GetLocationByName(arguments[2])); return true; } else { action.Arguments.Add(initiator); action.Arguments.Add(currentState.GetLocationByName(currentState.SearchAgentAmongLocations(initiator.Key).GetName())); if (initiator.Value.GetTargetLocation() != null && initiator.Key.GetRole() != AgentRole.PLAYER && currentState.SearchAgentAmongLocations(initiator.Key).ConnectionChecking(initiator.Value.GetTargetLocation())) { action.Arguments.Add(currentState.GetLocationByName(initiator.Value.GetTargetLocation().GetName())); return true; } else { KeyValuePair<LocationStatic, LocationDynamic> randLoc = currentState. GetRandomConnectedLocation(currentState.GetLocationByName(currentState.SearchAgentAmongLocations(initiator.Key).GetName())); if (currentState.GetLocationByName(currentState.SearchAgentAmongLocations(initiator.Key).GetName()). Key.ConnectionChecking(randLoc.Key)) { action.Arguments.Add(randLoc); return true; } } } return false; } else if (action is NeutralizeKiller || action is CounterNeutralizeKiller) { foreach (var killer in currentState.GetAgents()) { if (killer.Key.GetRole() == AgentRole.KILLER && killer.Value.GetStatus()) { action.Arguments.Add(initiator); action.Arguments.Add(killer); action.Arguments.Add(currentState.GetLocation(currentState.SearchAgentAmongLocations(initiator.Key))); return true; } } return false; } else if (action is Reassure || action is CounterReassure) { foreach (var agent in currentState.GetAgents()) { if (agent.Key.GetRole() == AgentRole.USUAL && agent.Value.GetStatus() && currentState.GetLocation(currentState.SearchAgentAmongLocations(initiator.Key)).Value.SearchAgent(agent.Key) && !agent.Key.Equals(initiator.Key) && agent.Value.AngryCheck()) { action.Arguments.Add(agent); action.Arguments.Add(initiator); action.Arguments.Add(currentState.GetAgentByName(agent.Value.GetObjectOfAngry().GetObjectOfAngry().GetName())); break; } } foreach (var killer in currentState.GetAgents()) { if (killer.Key.GetRole() == AgentRole.KILLER && killer.Value.GetStatus()) { action.Arguments.Add(killer); break; } } action.Arguments.Add(currentState.GetLocation(currentState.SearchAgentAmongLocations(initiator.Key))); return true; } else if (action is Run || action is CounterRun) { action.Arguments.Add(initiator); action.Arguments.Add(currentState.GetLocation(currentState.SearchAgentAmongLocations(initiator.Key))); action.Arguments.Add(currentState. GetRandomLocationWithout(currentState.GetLocationByName(currentState.SearchAgentAmongLocations(initiator.Key).GetName()))); return true; } else if (action is NothingToDo) { action.Arguments.Add(initiator); } else if (action is TellAboutASuspicious || action is CounterTellAboutASuspicious) { foreach (var agent in currentState.GetAgents()) { if (agent.Key.GetRole() == AgentRole.USUAL && agent.Value.GetStatus() && currentState.GetLocation(currentState.SearchAgentAmongLocations(initiator.Key)).Value.SearchAgent(agent.Key)) { action.Arguments.Add(agent); break; } } action.Arguments.Add(initiator); action.Arguments.Add(currentState.GetLocation(currentState.SearchAgentAmongLocations(initiator.Key))); action.Arguments.Add(currentState.GetRandomLocationWithout (currentState.GetLocationByName(currentState.SearchAgentAmongLocations(initiator.Key).GetName()))); return true; } else if (action is Talk || action is CounterTalk) { action.Arguments.Add(initiator); foreach (var agent in currentState.GetAgents()) { if (agent.Value.GetStatus() && currentState.GetLocation(currentState.SearchAgentAmongLocations(initiator.Key)).Value.SearchAgent(agent.Key) && agent.Key.GetName() != initiator.Key.GetName()) { action.Arguments.Add(agent); return true; } } return false; } return false; }