Esempio n. 1
0
 // TODO goals are not prioritized (first in is highest priority)
 public bool AddGoal(AgentGoal goal)
 {
     goals.Add(goal);
     return(true);
 }
        /// <summary>
        /// Levels are hardcoded into here
        /// </summary>
        /// <param name="level"></param>
        private void SetupLevel(int level)
        {
            int numTimePeriods;
            int numAgents;
            int startingAgentHealth;

            switch (activeLevel)
            {
            case 0:
                numTimePeriods      = 5;
                numAgents           = 3;
                startingAgentHealth = 4;

                // Agents
                gameState = new GameState(numTimePeriods, TIME_WINDOW_MIN, TIME_WINDOW_MAX, gameResources);
                gameState.AddAgent(new TrustAgent("Trustworthy Tim", numTimePeriods, numAgents, startingAgentHealth, gameState.GetNextAgentID()));
                gameState.AddAgent(new BetrayAgent("Betrayal Bill", numTimePeriods, numAgents, startingAgentHealth, gameState.GetNextAgentID()));
                gameState.AddAgent(new TitForTatAgent("TitForTat Tom", numTimePeriods, numAgents, startingAgentHealth, gameState.GetNextAgentID()));

                // Goals
                gameState.AddGoal(new AgentGoal(gameState.GetAgentByID(0), AgentCondition.ALIVE, numTimePeriods - 1));
                gameState.ForwardPropogate(0);
                break;

            case 1:
                numTimePeriods      = 7;
                numAgents           = 5;
                startingAgentHealth = 4;

                gameState = new GameState(numTimePeriods, TIME_WINDOW_MIN, TIME_WINDOW_MAX, gameResources);
                gameState.AddAgent(new TrustAgent("Mr. Trustables", numTimePeriods, numAgents, startingAgentHealth, gameState.GetNextAgentID()));
                gameState.AddAgent(new BetrayAgent("Backstab Barry", numTimePeriods, numAgents, startingAgentHealth, gameState.GetNextAgentID()));
                gameState.AddAgent(new TitForTatAgent("Titmouse Fortat", numTimePeriods, numAgents, startingAgentHealth, gameState.GetNextAgentID()));
                gameState.AddAgent(new TitForTatAgent("Tat For Tit", numTimePeriods, numAgents, startingAgentHealth, gameState.GetNextAgentID()));
                gameState.AddAgent(new BullyAgent("Foobar'n Baz", numTimePeriods, numAgents, startingAgentHealth, gameState.GetNextAgentID()));

                gameState.AddGoal(new AgentGoal(gameState.GetAgentByID(0), AgentCondition.ALIVE, 0));
                gameState.AddGoal(new AgentGoal(gameState.GetAgentByID(0), AgentCondition.ALIVE, 1));
                gameState.AddGoal(new AgentGoal(gameState.GetAgentByID(4), AgentCondition.DEAD, numTimePeriods - 1));
                gameState.ForwardPropogate(0);
                break;

            case 2:
                numTimePeriods      = 9;
                numAgents           = 6;
                startingAgentHealth = 5;

                gameState = new GameState(numTimePeriods, TIME_WINDOW_MIN, TIME_WINDOW_MAX + 1, gameResources);
                gameState.AddAgent(new BullyAgent("The Dragon", numTimePeriods, numAgents, startingAgentHealth, gameState.GetNextAgentID()));
                gameState.AddAgent(new TrustAgent("Princess", numTimePeriods, numAgents, startingAgentHealth, gameState.GetNextAgentID()));
                gameState.AddAgent(new MemoryAgent("A Bystander", numTimePeriods, numAgents, startingAgentHealth, gameState.GetNextAgentID()));
                gameState.AddAgent(new MemoryAgent("Bystander B", numTimePeriods, numAgents, startingAgentHealth, gameState.GetNextAgentID()));
                AgentGoal newGoal = new AgentGoal(gameState.GetAgentByID(0), AgentCondition.DEAD, numTimePeriods / 2);         // kill the bully by halfway
                gameState.AddAgent(new SimpleGoalAgent("Angry Knight", numTimePeriods, numAgents, startingAgentHealth, gameState.GetNextAgentID(), newGoal));
                AgentGoal newGoal2 = new AgentGoal(gameState.GetAgentByID(0), AgentCondition.DEAD, numTimePeriods - 1);        // kill the bully by halfway
                gameState.AddAgent(new SimpleGoalAgent("Level-Headed Knight", numTimePeriods, numAgents, startingAgentHealth, gameState.GetNextAgentID(), newGoal2));


                gameState.AddGoal(new AgentGoal(gameState.GetAgentByID(0), AgentCondition.DEAD, numTimePeriods - 1));           // kill the bully by the end
                gameState.AddGoal(new AgentGoal(gameState.GetAgentByID(1), AgentCondition.ALIVE, numTimePeriods - 1));          // kill the bully by the end
                gameState.ForwardPropogate(0);
                break;

            default:
                break;
            }
        }
 public SimpleGoalAgent(string name, int numTimePeriods, int numAgents, int health, int agentID, AgentGoal goal) :
     base(name, numTimePeriods, numAgents, health, agentID)
 {
     this.Goal = goal;
 }