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));
}
}
}
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));
}
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());
}
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();
}
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());
}
Aggregations