Search in sources :

Example 11 with VacuumEnvironment

use of aima.core.environment.vacuum.VacuumEnvironment in project aima-java by aimacode.

the class ModelBasedReflexVacuumAgentTest method testAgentActionNumber7.

@Test
public void testAgentActionNumber7() {
    VacuumEnvironment tve = new VacuumEnvironment(VacuumEnvironment.LocationState.Dirty, VacuumEnvironment.LocationState.Clean);
    tve.addAgent(agent, VacuumEnvironment.LOCATION_A);
    Assert.assertEquals(VacuumEnvironment.LOCATION_A, tve.getAgentLocation(agent));
    Assert.assertEquals(1, tve.getAgents().size());
    // cleans A
    tve.step();
    Assert.assertEquals(VacuumEnvironment.LOCATION_A, tve.getAgentLocation(agent));
    Assert.assertEquals(VacuumEnvironment.LocationState.Clean, tve.getLocationState(VacuumEnvironment.LOCATION_A));
    // moves to 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);
}
Also used : VacuumEnvironment(aima.core.environment.vacuum.VacuumEnvironment) Test(org.junit.Test)

Example 12 with VacuumEnvironment

use of aima.core.environment.vacuum.VacuumEnvironment in project aima-java by aimacode.

the class ModelBasedReflexVacuumAgentTest 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.stepUntilDone();
    Assert.assertEquals("Action[name==Suck]Action[name==Right]Action[name==NoOp]", envChanges.toString());
}
Also used : VacuumEnvironmentViewActionTracker(aima.core.environment.vacuum.VacuumEnvironmentViewActionTracker) VacuumEnvironment(aima.core.environment.vacuum.VacuumEnvironment) Test(org.junit.Test)

Example 13 with VacuumEnvironment

use of aima.core.environment.vacuum.VacuumEnvironment in project aima-java by aimacode.

the class ModelBasedReflexVacuumAgentTest method testDirtyDirty.

@Test
public void testDirtyDirty() {
    VacuumEnvironment tve = new VacuumEnvironment(VacuumEnvironment.LocationState.Dirty, VacuumEnvironment.LocationState.Dirty);
    tve.addAgent(agent, VacuumEnvironment.LOCATION_A);
    tve.addEnvironmentView(new VacuumEnvironmentViewActionTracker(envChanges));
    tve.stepUntilDone();
    Assert.assertEquals("Action[name==Suck]Action[name==Right]Action[name==Suck]Action[name==NoOp]", envChanges.toString());
}
Also used : VacuumEnvironmentViewActionTracker(aima.core.environment.vacuum.VacuumEnvironmentViewActionTracker) VacuumEnvironment(aima.core.environment.vacuum.VacuumEnvironment) Test(org.junit.Test)

Example 14 with VacuumEnvironment

use of aima.core.environment.vacuum.VacuumEnvironment in project aima-java by aimacode.

the class ModelBasedReflexVacuumAgentTest method testAgentActionNumber2.

@Test
public void testAgentActionNumber2() {
    VacuumEnvironment tve = new VacuumEnvironment(VacuumEnvironment.LocationState.Dirty, VacuumEnvironment.LocationState.Dirty);
    tve.addAgent(agent, VacuumEnvironment.LOCATION_B);
    Assert.assertEquals(VacuumEnvironment.LOCATION_B, tve.getAgentLocation(agent));
    Assert.assertEquals(1, tve.getAgents().size());
    // cleans location B
    tve.step();
    Assert.assertEquals(VacuumEnvironment.LOCATION_B, tve.getAgentLocation(agent));
    Assert.assertEquals(VacuumEnvironment.LocationState.Clean, tve.getLocationState(VacuumEnvironment.LOCATION_B));
    // moves to lcation A
    tve.step();
    Assert.assertEquals(VacuumEnvironment.LOCATION_A, tve.getAgentLocation(agent));
    Assert.assertEquals(VacuumEnvironment.LocationState.Dirty, tve.getLocationState(VacuumEnvironment.LOCATION_A));
    // cleans location 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(19, tve.getPerformanceMeasure(agent), 0.001);
}
Also used : VacuumEnvironment(aima.core.environment.vacuum.VacuumEnvironment) Test(org.junit.Test)

Example 15 with VacuumEnvironment

use of aima.core.environment.vacuum.VacuumEnvironment in project aima-java by aimacode.

the class ModelBasedReflexVacuumAgentTest method testAgentActionNumber8.

@Test
public void testAgentActionNumber8() {
    VacuumEnvironment tve = new VacuumEnvironment(VacuumEnvironment.LocationState.Dirty, VacuumEnvironment.LocationState.Clean);
    tve.addAgent(agent, VacuumEnvironment.LOCATION_B);
    Assert.assertEquals(VacuumEnvironment.LOCATION_B, tve.getAgentLocation(agent));
    Assert.assertEquals(1, tve.getAgents().size());
    // moves to A
    tve.step();
    Assert.assertEquals(VacuumEnvironment.LOCATION_A, tve.getAgentLocation(agent));
    Assert.assertEquals(VacuumEnvironment.LocationState.Dirty, tve.getLocationState(VacuumEnvironment.LOCATION_A));
    // cleans 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);
}
Also used : VacuumEnvironment(aima.core.environment.vacuum.VacuumEnvironment) Test(org.junit.Test)

Aggregations

VacuumEnvironment (aima.core.environment.vacuum.VacuumEnvironment)28 Test (org.junit.Test)24 VacuumEnvironmentViewActionTracker (aima.core.environment.vacuum.VacuumEnvironmentViewActionTracker)16 Agent (aima.core.agent.Agent)2 ModelBasedReflexVacuumAgent (aima.core.environment.vacuum.ModelBasedReflexVacuumAgent)2 BorderPane (javafx.scene.layout.BorderPane)2 Environment (aima.core.agent.Environment)1 EnvironmentView (aima.core.agent.EnvironmentView)1 SimpleEnvironmentView (aima.core.agent.impl.SimpleEnvironmentView)1 Label (javafx.scene.control.Label)1 ColumnConstraints (javafx.scene.layout.ColumnConstraints)1 Before (org.junit.Before)1