public void testAgentActionNumber1() { VacuumEnvironment tve = new VacuumEnvironment( VacuumEnvironment.LocationState.Dirty, VacuumEnvironment.LocationState.Dirty); tve.addAgent(agent, VacuumEnvironment.LOCATION_A); Assert.AreEqual(VacuumEnvironment.LOCATION_A, tve.getAgentLocation(agent)); Assert.AreEqual(1, tve.GetAgents().Size()); tve.Step(); // cleans location A Assert.AreEqual(VacuumEnvironment.LOCATION_A, tve.getAgentLocation(agent)); Assert.AreEqual(VacuumEnvironment.LocationState.Clean, tve.getLocationState(VacuumEnvironment.LOCATION_A)); tve.Step(); // moves to lcation B Assert.AreEqual(VacuumEnvironment.LOCATION_B, tve.getAgentLocation(agent)); Assert.AreEqual(VacuumEnvironment.LocationState.Dirty, tve.getLocationState(VacuumEnvironment.LOCATION_B)); tve.Step(); // cleans location B Assert.AreEqual(VacuumEnvironment.LOCATION_B, tve.getAgentLocation(agent)); Assert.AreEqual(VacuumEnvironment.LocationState.Clean, tve.getLocationState(VacuumEnvironment.LOCATION_B)); tve.Step(); // NOOP Assert.AreEqual(VacuumEnvironment.LOCATION_B, tve.getAgentLocation(agent)); Assert.AreEqual(19, tve.GetPerformanceMeasure(agent), 0.001); }
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 ReflexVacuumAgent(); env.AddAgent(a); env.Step(16); env.NotifyViews("Performance=" + env.GetPerformanceMeasure(a)); }