Search in sources :

Example 1 with VacuumEnvironment

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

the class VacuumEnvironmentViewCtrl method updateEnvStateView.

@Override
protected void updateEnvStateView(Environment env) {
    if (env instanceof VacuumEnvironment) {
        VacuumEnvironment vEnv = (VacuumEnvironment) env;
        for (String loc : locations) {
            BorderPane pane = getLocPane(loc);
            if (vEnv.getLocationState(loc).equals(LocationState.Dirty))
                pane.setStyle("-fx-background-color: lightgrey");
            else
                pane.setStyle("-fx-background-color: white");
            pane.setCenter(null);
        }
        for (Agent agent : vEnv.getAgents()) {
            BorderPane pane = getLocPane(vEnv.getAgentLocation(agent));
            pane.setCenter(createAgentRep(agent == agentInAction));
        }
    }
}
Also used : Agent(aima.core.agent.Agent) BorderPane(javafx.scene.layout.BorderPane) VacuumEnvironment(aima.core.environment.vacuum.VacuumEnvironment)

Example 2 with VacuumEnvironment

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

the class TrivialVacuumDemo method main.

public static void main(String[] args) {
    // create environment with random state of cleaning.
    Environment env = new VacuumEnvironment();
    EnvironmentView view = new SimpleEnvironmentView();
    env.addEnvironmentView(view);
    Agent a = null;
    a = new ModelBasedReflexVacuumAgent();
    // a = new ReflexVacuumAgent();
    // a = new SimpleReflexVacuumAgent();
    // a = new TableDrivenVacuumAgent();
    env.addAgent(a);
    env.step(16);
    env.notifyViews("Performance=" + env.getPerformanceMeasure(a));
}
Also used : ModelBasedReflexVacuumAgent(aima.core.environment.vacuum.ModelBasedReflexVacuumAgent) Agent(aima.core.agent.Agent) VacuumEnvironment(aima.core.environment.vacuum.VacuumEnvironment) ModelBasedReflexVacuumAgent(aima.core.environment.vacuum.ModelBasedReflexVacuumAgent) EnvironmentView(aima.core.agent.EnvironmentView) SimpleEnvironmentView(aima.core.agent.impl.SimpleEnvironmentView) VacuumEnvironment(aima.core.environment.vacuum.VacuumEnvironment) Environment(aima.core.agent.Environment) SimpleEnvironmentView(aima.core.agent.impl.SimpleEnvironmentView)

Example 3 with VacuumEnvironment

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

the class TableDrivenVacuumAgentTest 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 4 with VacuumEnvironment

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

the class VacuumEnvironmentTest method setUp.

@Before
public void setUp() {
    tve = new VacuumEnvironment(VacuumEnvironment.LocationState.Dirty, VacuumEnvironment.LocationState.Dirty);
    tve2 = new VacuumEnvironment(VacuumEnvironment.LocationState.Clean, VacuumEnvironment.LocationState.Clean);
    tve3 = new VacuumEnvironment(VacuumEnvironment.LocationState.Clean, VacuumEnvironment.LocationState.Dirty);
    tve4 = new VacuumEnvironment(VacuumEnvironment.LocationState.Dirty, VacuumEnvironment.LocationState.Clean);
    a = new ModelBasedReflexVacuumAgent();
}
Also used : VacuumEnvironment(aima.core.environment.vacuum.VacuumEnvironment) ModelBasedReflexVacuumAgent(aima.core.environment.vacuum.ModelBasedReflexVacuumAgent) Before(org.junit.Before)

Example 5 with VacuumEnvironment

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

the class ReflexVacuumAgentTest method testCleanDirty.

@Test
public void testCleanDirty() {
    VacuumEnvironment tve = new VacuumEnvironment(VacuumEnvironment.LocationState.Clean, VacuumEnvironment.LocationState.Dirty);
    tve.addAgent(agent, VacuumEnvironment.LOCATION_A);
    tve.addEnvironmentView(new VacuumEnvironmentViewActionTracker(envChanges));
    tve.step(8);
    Assert.assertEquals("Action[name==Right]Action[name==Suck]Action[name==Left]Action[name==Right]Action[name==Left]Action[name==Right]Action[name==Left]Action[name==Right]", envChanges.toString());
}
Also used : VacuumEnvironmentViewActionTracker(aima.core.environment.vacuum.VacuumEnvironmentViewActionTracker) 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