示例#1
0
        public void GetOneAction()
        {
            RandomVacuumAgent agent      = new RandomVacuumAgent();
            VacuumPerception  perception = new VacuumPerception(VacuumLocation.A, VacuumStatus.Clean);

            var result = agent.GetAction(perception);

            Assert.IsTrue(result == VacuumAction.NoOp || result == VacuumAction.Left || result == VacuumAction.Right || result == VacuumAction.Suck);
        }
        public void GetAgentPerception()
        {
            TrivialVacuumEnvironment environment = new TrivialVacuumEnvironment();

            environment.SetStatus(VacuumLocation.A, VacuumStatus.Clean);
            var agent = new RandomVacuumAgent();

            agent.Location = VacuumLocation.A;

            var result = environment.GetPerception(agent);

            Assert.AreEqual(VacuumLocation.A, result.Location);
            Assert.AreEqual(VacuumStatus.Clean, result.Status);
        }
        public void ExecuteLeftAction()
        {
            TrivialVacuumEnvironment environment = new TrivialVacuumEnvironment();

            environment.SetStatus(VacuumLocation.A, VacuumStatus.Clean);
            var agent = new RandomVacuumAgent();

            agent.Location = VacuumLocation.B;

            environment.ExecuteAction(agent, VacuumAction.Left);

            Assert.AreEqual(VacuumLocation.A, agent.Location);
            Assert.AreEqual(-1, agent.Performance);
            Assert.AreEqual(VacuumStatus.Clean, environment.GetStatus(VacuumLocation.A));
        }
        public void ExecuteSuckActionOnDirtyStatus()
        {
            TrivialVacuumEnvironment environment = new TrivialVacuumEnvironment();

            environment.SetStatus(VacuumLocation.A, VacuumStatus.Dirty);
            var agent = new RandomVacuumAgent();

            agent.Location = VacuumLocation.A;

            environment.ExecuteAction(agent, VacuumAction.Suck);

            Assert.AreEqual(VacuumLocation.A, agent.Location);
            Assert.AreEqual(10, agent.Performance);
            Assert.AreEqual(VacuumStatus.Clean, environment.GetStatus(VacuumLocation.A));
        }
示例#5
0
        public void GetOneHundredActions()
        {
            RandomVacuumAgent agent      = new RandomVacuumAgent();
            VacuumPerception  perception = new VacuumPerception(VacuumLocation.A, VacuumStatus.Clean);

            IList <VacuumAction> actions = new List <VacuumAction>();

            for (int k = 0; k < 100; k++)
            {
                actions.Add(agent.GetAction(perception));
            }

            Assert.IsTrue(actions.Any(action => action == VacuumAction.NoOp));
            Assert.IsTrue(actions.Any(action => action == VacuumAction.Suck));
            Assert.IsTrue(actions.Any(action => action == VacuumAction.Left));
            Assert.IsTrue(actions.Any(action => action == VacuumAction.Right));
        }