コード例 #1
0
        /// <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;
        }
コード例 #2
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));
        }
コード例 #3
0
 public void SetBeliefs(WorldContext beliefs)
 {
     this.beliefs = beliefs;
 }