コード例 #1
0
        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();
        }
コード例 #2
0
        public void AddEmptyAgent()
        {
            AgentStateStatic  newAgentStateStatic  = new AgentStateStatic();
            AgentStateDynamic newAgentStateDynamic = new AgentStateDynamic();

            agents.Add(newAgentStateStatic, newAgentStateDynamic);

            // Очистка
            newAgentStateStatic  = null;
            newAgentStateDynamic = null;
            GC.Collect();

            UpdateHashCode();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        /// <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));
        }
コード例 #6
0
        /// <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();
        }
コード例 #7
0
 public void AddAgent(AgentStateStatic newAgentStatic, AgentStateDynamic newAgentStateDynamic)
 {
     agents.Add(newAgentStatic, newAgentStateDynamic);
     UpdateHashCode();
 }