public void MultiAVandAC(ref PlanAction receivedAction, WorldDynamic currentState, KeyValuePair <AgentStateStatic, AgentStateDynamic> agent, CSP_Module cspModule, StoryGraph currentGraph, StoryNode currentNode, bool root, ref int globalNodeNumber, ref Queue <StoryNode> queue) { List <PlanAction> actionsList = cspModule.MassiveAssignVariables(ref receivedAction, currentState, agent); AgentStateStatic sCurrentAgent = (AgentStateStatic)agent.Key.Clone(); AgentStateDynamic dCurrentAgent = (AgentStateDynamic)agent.Value.Clone(); KeyValuePair <AgentStateStatic, AgentStateDynamic> currentAgent = new KeyValuePair <AgentStateStatic, AgentStateDynamic>(sCurrentAgent, dCurrentAgent); WorldDynamic statePrefab = (WorldDynamic)currentState.Clone(); foreach (var a in actionsList) { ActionControl(a, currentGraph, currentAgent, statePrefab, currentNode, root, ref globalNodeNumber, ref queue); } // Cleaning actionsList = null; currentNode = null; statePrefab = null; GC.Collect(); }
public AgentStateDynamic(AgentStateDynamic clone) { agentInfo = (AgentStateStatic)clone.agentInfo.Clone(); myCurrentPlan = (Plan)clone.myCurrentPlan.Clone(); myAvailableActions = new List <PlanAction>(clone.myAvailableActions); alive = clone.alive; myGoals = (Goal)clone.myGoals.Clone(); beliefs = (WorldContext)clone.beliefs.Clone(); initiative = clone.initiative; angryAt = (AgentAngryAt)clone.angryAt.Clone(); scared = clone.scared; foundEvidence = (AgentFoundEvidence)clone.foundEvidence.Clone(); if (clone.wantsToGo != null) { wantsToGo = (LocationStatic)clone.wantsToGo.Clone();; } else { wantsToGo = new LocationStatic(); } exploredRooms = new HashSet <LocationStatic>(clone.exploredRooms); wantToEntrap = (WantToEntrap)clone.wantToEntrap.Clone(); talkingWith = (TalkingWith)clone.talkingWith.Clone(); hasHashCode = clone.hasHashCode; hashCode = clone.hashCode; skipedTurns = clone.skipedTurns; timeToMove = clone.timeToMove; }
public TalkingWith(bool talking, AgentStateStatic interlocutor) { this.talking = talking; this.interlocutor = interlocutor; hasHashCode = false; hashCode = 0; }
public AgentAngryAt() { angry = false; objectOfAngry = new AgentStateStatic(); hasHashCode = false; hashCode = 0; }
public AgentAngryAt(bool angry, AgentStateStatic objectOfAngry) { this.angry = angry; this.objectOfAngry = objectOfAngry; hasHashCode = false; hashCode = 0; }
public AgentFoundEvidence(bool foundEvidence, AgentStateStatic evidenceAgainst) { this.foundEvidence = foundEvidence; this.evidenceAgainst = evidenceAgainst; hasHashCode = false; hashCode = 0; }
public TalkingWith() { talking = false; interlocutor = new AgentStateStatic(); hasHashCode = false; hashCode = 0; }
public AgentFoundEvidence() { foundEvidence = false; evidenceAgainst = null; hasHashCode = false; hashCode = 0; }
public WantToEntrap(bool entraping, AgentStateStatic whom, LocationStatic where) { this.entraping = entraping; this.whom = whom; this.where = where; hasHashCode = false; hashCode = 0; }
public BeliefsAboutAgent(BeliefsAboutAgent clone) { info = (AgentStateStatic)clone.info.Clone(); role = clone.role; isAlive = clone.isAlive; inLocation = (LocationStatic)clone.inLocation.Clone(); angryAt = (AgentAngryAt)clone.angryAt.Clone(); }
public WantToEntrap() { entraping = false; whom = new AgentStateStatic(); where = new LocationStatic(); hasHashCode = false; hashCode = 0; }
public BeliefsAboutAgent(AgentStateStatic info, AgentRole role, bool isAlive, LocationStatic inLocation, AgentAngryAt angryAt) { this.info = info; this.role = role; this.isAlive = isAlive; this.inLocation = inLocation; this.angryAt = angryAt; }
public BeliefsAboutAgent() { info = new AgentStateStatic(); role = AgentRole.USUAL; isAlive = true; inLocation = new LocationStatic(); angryAt = new AgentAngryAt(); }
public bool TalkingCheckAtAgent(AgentStateStatic agent) { if (talking && agent == interlocutor) { return(true); } else { return(false); } }
public bool AngryCheckAtAgent(AgentStateStatic agent) { if (angry && agent == objectOfAngry) { return(true); } else { return(false); } }
public bool EntrapingCheckAtAgent(AgentStateStatic agent) { if (entraping && agent == whom) { return(true); } else { return(false); } }
public LocationStatic SearchAgentAmongLocations(AgentStateStatic agent) { foreach (var a in agentsInWorld) { if (a.GetInfo() == agent) { return(a.GetLocation()); } } return(null); }
/// <summary> /// Returns the static part (name) of the location where the searched agent is located. /// </summary> /// <param name="agent"></param> public LocationStatic SearchAgentAmongLocations(AgentStateStatic agent) { foreach (var location in currentStateOfLocations) { if (location.Value.SearchAgent(agent)) { return(location.Key); } } return(null); }
public void AddEmptyAgent() { AgentStateStatic newAgentStateStatic = new AgentStateStatic(); AgentStateDynamic newAgentStateDynamic = new AgentStateDynamic(); agents.Add(newAgentStateStatic, newAgentStateDynamic); // Очистка newAgentStateStatic = null; newAgentStateDynamic = null; GC.Collect(); UpdateHashCode(); }
public TalkingWith(TalkingWith clone) { talking = clone.talking; if (clone.interlocutor != null) { interlocutor = (AgentStateStatic)clone.interlocutor.Clone(); } else { interlocutor = new AgentStateStatic(); } hasHashCode = clone.hasHashCode; hashCode = clone.hashCode; }
public AgentAngryAt(AgentAngryAt clone) { angry = clone.angry; if (clone.objectOfAngry != null) { objectOfAngry = (AgentStateStatic)clone.objectOfAngry.Clone(); } else { objectOfAngry = new AgentStateStatic(); } hasHashCode = clone.hasHashCode; hashCode = clone.hashCode; }
public AgentFoundEvidence(AgentFoundEvidence clone) { foundEvidence = clone.foundEvidence; if (clone.evidenceAgainst != null) { evidenceAgainst = (AgentStateStatic)clone.evidenceAgainst.Clone(); } else { evidenceAgainst = new AgentStateStatic(); } hasHashCode = clone.hasHashCode; hashCode = clone.hashCode; }
public void AddAgentIntoLocation(KeyValuePair <LocationStatic, LocationDynamic> location, KeyValuePair <AgentStateStatic, AgentStateDynamic> agent) { AgentStateStatic sNewAgent = (AgentStateStatic)agent.Key.Clone(); AgentStateDynamic dNewAgent = (AgentStateDynamic)agent.Value.Clone(); KeyValuePair <AgentStateStatic, AgentStateDynamic> newAgent = new KeyValuePair <AgentStateStatic, AgentStateDynamic> (sNewAgent, dNewAgent); location.Value.AddAgent(newAgent); UpdateHashCode(); // Очистка sNewAgent = null; dNewAgent = null; GC.Collect(); }
/// <summary> /// Searches for the specified agent in the list of agents located in the given location, /// returns true on success, and returns false on failure. /// </summary> /// <param name="agent"></param> public bool SearchAgent(AgentStateStatic agent) { // We go through all the agents in the list of agents located in this location. foreach (var a in agentsAtLocations) { // We compare the name of the agent with the name of the desired agent. if (a.Key.GetName().Equals(agent.GetName())) { // Return true if the search is successful. return(true); } } // Otherwise, we return false. return(false); }
public void AddAgent(AgentRole role, bool status, string name) { AgentStateStatic newAgentStateStatic = new AgentStateStatic(); AgentStateDynamic newAgentStateDynamic = new AgentStateDynamic(); newAgentStateStatic.AssignRole(role); newAgentStateStatic.SetName(name); newAgentStateDynamic.SetStatus(status); agents.Add(newAgentStateStatic, newAgentStateDynamic); // Очистка newAgentStateStatic = null; newAgentStateDynamic = null; GC.Collect(); UpdateHashCode(); }
/// <summary> /// Parameterless constructor. /// </summary> public AgentStateDynamic() { agentInfo = new AgentStateStatic(); myCurrentPlan = new Plan(); myAvailableActions = new List <PlanAction>(); alive = true; myGoals = new Goal(); beliefs = new WorldContext(); initiative = 0; angryAt = new AgentAngryAt(); scared = false; foundEvidence = new AgentFoundEvidence(); wantsToGo = new LocationStatic(); exploredRooms = new HashSet <LocationStatic>(); wantToEntrap = new WantToEntrap(); talkingWith = new TalkingWith(); hasHashCode = false; hashCode = 0; skipedTurns = 0; timeToMove = 2; }
public WantToEntrap(WantToEntrap clone) { entraping = clone.entraping; if (clone.whom != null) { whom = (AgentStateStatic)clone.whom.Clone(); } else { whom = new AgentStateStatic(); } if (clone.where != null) { where = (LocationStatic)clone.where.Clone(); } else { where = new LocationStatic(); } hasHashCode = clone.hasHashCode; hashCode = clone.hashCode; }
/// <summary> /// Constructor with parameters. /// </summary> public AgentStateDynamic(bool alive, Goal goals, WorldContext beliefs, AgentStateStatic agentInfo) { this.agentInfo = agentInfo; myCurrentPlan = new Plan(); myAvailableActions = new List <PlanAction>(); SetStatus(alive); SetGoal(goals); SetBeliefs(beliefs); SetInitiative(0); AgentAngryAt angryAt = new AgentAngryAt(false, null); SetObjectOfAngry(angryAt); ScaredOff(); AgentFoundEvidence foundEvidence = new AgentFoundEvidence(false, null); AddEvidence(foundEvidence); WantToEntrap wantToEntrap = new WantToEntrap(false, null, null); SetEntrap(wantToEntrap); TalkingWith talkingWith = new TalkingWith(false, null); SetTalking(talkingWith); SetTargetLocation(null); exploredRooms = new HashSet <LocationStatic>(); hasHashCode = false; hashCode = 0; skipedTurns = 0; timeToMove = 2; }
/// <summary> /// Add the agent to the existing collection of agents using only the specified role and name. /// </summary> /// <param name="role"></param> /// <param name="name"></param> public void AddAgent(AgentRole role, string name) { // Create empty instances of the static and dynamic parts of the agent. AgentStateStatic newAgentStateStatic = new AgentStateStatic(); AgentStateDynamic newAgentStateDynamic = new AgentStateDynamic(); // Assign the role and name of the static part. newAgentStateStatic.AssignRole(role); newAgentStateStatic.SetName(name); // We give the dynamic part a link to the static part. newAgentStateDynamic.SetAgentInfo(newAgentStateStatic); // We combine both parts into one and add to the collection. agents.Add(newAgentStateStatic, newAgentStateDynamic); // Очистка newAgentStateStatic = null; newAgentStateDynamic = null; GC.Collect(); UpdateHashCode(); }
/// <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)); }