use of aima.core.environment.vacuum.VacuumEnvironment in project aima-java by aimacode.
the class ReflexVacuumAgentTest method testCleanClean.
@Test
public void testCleanClean() {
VacuumEnvironment tve = new VacuumEnvironment(VacuumEnvironment.LocationState.Clean, VacuumEnvironment.LocationState.Clean);
tve.addAgent(agent, VacuumEnvironment.LOCATION_A);
tve.addEnvironmentView(new VacuumEnvironmentViewActionTracker(envChanges));
tve.step(8);
Assert.assertEquals("Action[name==Right]Action[name==Left]Action[name==Right]Action[name==Left]Action[name==Right]Action[name==Left]Action[name==Right]Action[name==Left]", envChanges.toString());
}
use of aima.core.environment.vacuum.VacuumEnvironment in project aima-java by aimacode.
the class ReflexVacuumAgentTest method testDirtyClean.
@Test
public void testDirtyClean() {
VacuumEnvironment tve = new VacuumEnvironment(VacuumEnvironment.LocationState.Dirty, VacuumEnvironment.LocationState.Clean);
tve.addAgent(agent, VacuumEnvironment.LOCATION_A);
tve.addEnvironmentView(new VacuumEnvironmentViewActionTracker(envChanges));
tve.step(8);
Assert.assertEquals("Action[name==Suck]Action[name==Right]Action[name==Left]Action[name==Right]Action[name==Left]Action[name==Right]Action[name==Left]Action[name==Right]", envChanges.toString());
}
use of aima.core.environment.vacuum.VacuumEnvironment in project aima-java by aimacode.
the class ModelBasedReflexVacuumAgentTest method testAgentActionNumber6.
@Test
public void testAgentActionNumber6() {
VacuumEnvironment tve = new VacuumEnvironment(VacuumEnvironment.LocationState.Clean, VacuumEnvironment.LocationState.Dirty);
tve.addAgent(agent, VacuumEnvironment.LOCATION_B);
Assert.assertEquals(VacuumEnvironment.LOCATION_B, tve.getAgentLocation(agent));
Assert.assertEquals(1, tve.getAgents().size());
// cleans B
tve.step();
Assert.assertEquals(VacuumEnvironment.LOCATION_B, tve.getAgentLocation(agent));
Assert.assertEquals(VacuumEnvironment.LocationState.Clean, tve.getLocationState(VacuumEnvironment.LOCATION_B));
// moves to A
tve.step();
Assert.assertEquals(VacuumEnvironment.LOCATION_A, tve.getAgentLocation(agent));
Assert.assertEquals(VacuumEnvironment.LocationState.Clean, tve.getLocationState(VacuumEnvironment.LOCATION_A));
// NOOP
tve.step();
Assert.assertEquals(VacuumEnvironment.LOCATION_A, tve.getAgentLocation(agent));
Assert.assertEquals(VacuumEnvironment.LocationState.Clean, tve.getLocationState(VacuumEnvironment.LOCATION_A));
Assert.assertEquals(VacuumEnvironment.LocationState.Clean, tve.getLocationState(VacuumEnvironment.LOCATION_B));
Assert.assertEquals(9, tve.getPerformanceMeasure(agent), 0.001);
}
use of aima.core.environment.vacuum.VacuumEnvironment in project aima-java by aimacode.
the class ModelBasedReflexVacuumAgentTest method testAgentActionNumber3.
@Test
public void testAgentActionNumber3() {
VacuumEnvironment tve = new VacuumEnvironment(VacuumEnvironment.LocationState.Clean, VacuumEnvironment.LocationState.Clean);
tve.addAgent(agent, VacuumEnvironment.LOCATION_A);
Assert.assertEquals(VacuumEnvironment.LOCATION_A, tve.getAgentLocation(agent));
Assert.assertEquals(1, tve.getAgents().size());
// moves to location B
tve.step();
Assert.assertEquals(VacuumEnvironment.LOCATION_B, tve.getAgentLocation(agent));
Assert.assertEquals(VacuumEnvironment.LocationState.Clean, tve.getLocationState(VacuumEnvironment.LOCATION_B));
// NOOP
tve.step();
Assert.assertEquals(VacuumEnvironment.LOCATION_B, tve.getAgentLocation(agent));
Assert.assertEquals(VacuumEnvironment.LocationState.Clean, tve.getLocationState(VacuumEnvironment.LOCATION_A));
Assert.assertEquals(VacuumEnvironment.LocationState.Clean, tve.getLocationState(VacuumEnvironment.LOCATION_B));
Assert.assertEquals(-1, tve.getPerformanceMeasure(agent), 0.001);
}
use of aima.core.environment.vacuum.VacuumEnvironment in project aima-java by aimacode.
the class ModelBasedReflexVacuumAgentTest method testAgentActionNumber5.
@Test
public void testAgentActionNumber5() {
VacuumEnvironment tve = new VacuumEnvironment(VacuumEnvironment.LocationState.Clean, VacuumEnvironment.LocationState.Dirty);
tve.addAgent(agent, VacuumEnvironment.LOCATION_A);
Assert.assertEquals(VacuumEnvironment.LOCATION_A, tve.getAgentLocation(agent));
Assert.assertEquals(1, tve.getAgents().size());
// moves to B
tve.step();
Assert.assertEquals(VacuumEnvironment.LOCATION_B, tve.getAgentLocation(agent));
Assert.assertEquals(VacuumEnvironment.LocationState.Dirty, tve.getLocationState(VacuumEnvironment.LOCATION_B));
// cleans location B
tve.step();
Assert.assertEquals(VacuumEnvironment.LOCATION_B, tve.getAgentLocation(agent));
Assert.assertEquals(VacuumEnvironment.LocationState.Clean, tve.getLocationState(VacuumEnvironment.LOCATION_B));
// NOOP
tve.step();
Assert.assertEquals(VacuumEnvironment.LOCATION_B, tve.getAgentLocation(agent));
Assert.assertEquals(VacuumEnvironment.LocationState.Clean, tve.getLocationState(VacuumEnvironment.LOCATION_A));
Assert.assertEquals(VacuumEnvironment.LocationState.Clean, tve.getLocationState(VacuumEnvironment.LOCATION_B));
Assert.assertEquals(9, tve.getPerformanceMeasure(agent), 0.001);
}
Aggregations