Example #1
0
        public void GetNoOpActionWhenEmptyTable()
        {
            IDictionary <VacuumPerceptionList, VacuumAction> table = new Dictionary <VacuumPerceptionList, VacuumAction>();

            TableDrivenVacuumAgent agent = new TableDrivenVacuumAgent(table);

            Assert.AreEqual(VacuumAction.NoOp, agent.GetAction(new VacuumPerception(VacuumLocation.A, VacuumStatus.Clean)));
            Assert.AreEqual(VacuumAction.NoOp, agent.GetAction(new VacuumPerception(VacuumLocation.B, VacuumStatus.Dirty)));
        }
Example #2
0
        public void GetActionFromSimplePerception()
        {
            VacuumPerceptionList list = new VacuumPerceptionList(new VacuumPerception(VacuumLocation.A, VacuumStatus.Clean));
            IDictionary <VacuumPerceptionList, VacuumAction> table = new Dictionary <VacuumPerceptionList, VacuumAction>();

            table[list] = VacuumAction.Left;

            TableDrivenVacuumAgent agent = new TableDrivenVacuumAgent(table);

            Assert.AreEqual(VacuumAction.Left, agent.GetAction(new VacuumPerception(VacuumLocation.A, VacuumStatus.Clean)));
        }
Example #3
0
        public void GetActionFromTwoPerceptions()
        {
            VacuumPerceptionList list1 = new VacuumPerceptionList(new VacuumPerception(VacuumLocation.A, VacuumStatus.Clean));
            VacuumPerceptionList list2 = new VacuumPerceptionList(new VacuumPerception(VacuumLocation.A, VacuumStatus.Clean), new VacuumPerception(VacuumLocation.B, VacuumStatus.Dirty));
            IDictionary <VacuumPerceptionList, VacuumAction> table = new Dictionary <VacuumPerceptionList, VacuumAction>();

            table[list1] = VacuumAction.Left;
            table[list2] = VacuumAction.Right;

            TableDrivenVacuumAgent agent = new TableDrivenVacuumAgent(table);

            Assert.AreEqual(VacuumAction.Left, agent.GetAction(new VacuumPerception(VacuumLocation.A, VacuumStatus.Clean)));
            Assert.AreEqual(VacuumAction.Right, agent.GetAction(new VacuumPerception(VacuumLocation.B, VacuumStatus.Dirty)));
        }
Example #4
0
        static void Main(params string[] args)
        {
            // create environment with random state of cleaning.
            IEnvironment     env  = new VacuumEnvironment();
            IEnvironmentView view = new SimpleEnvironmentView();

            env.AddEnvironmentView(view);

            IAgent a = new TableDrivenVacuumAgent();

            env.AddAgent(a);
            env.Step(16);
            env.NotifyViews("Performance=" + env.GetPerformanceMeasure(a));
        }
 public void setUp()
 {
     agent      = new TableDrivenVacuumAgent();
     envChanges = TextFactory.CreateStringBuilder();
 }
	public void setUp() {
		agent = new TableDrivenVacuumAgent();
		envChanges = new StringBuilder();
	}