Package aima.core.environment.vacuum

Examples of aima.core.environment.vacuum.VacuumEnvironment


  /**
   * Checks whether an agent is currently at the specified location and
   * returns one of them if any.
   * */
  protected Agent getAgent(Object location) {
    VacuumEnvironment e = getVacuumEnv();
    for (Agent a : e.getAgents())
      if (location.equals(e.getAgentLocation(a)))
        return a;
    return null;
  }
View Full Code Here


  public void prepare(String changedSelector) {
    AgentAppFrame.SelectionState selState = frame.getSelection();
    env = null;
    switch (selState.getValue(VacuumFrame.ENV_SEL)) {
    case 0:
      env = new VacuumEnvironment();
      break;
    }
    agent = null;
    switch (selState.getValue(VacuumFrame.AGENT_SEL)) {
    case 0:
View Full Code Here

* @author Ruediger Lunde
*/
public class TrivialVacuumDemo {
  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));
  }
View Full Code Here

  ModelBasedReflexVacuumAgent a;

  @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();
  }
View Full Code Here

    envChanges = new StringBuilder();
  }

  @Test
  public void testCleanClean() {
    VacuumEnvironment tve = new VacuumEnvironment(
        VacuumEnvironment.LocationState.Clean,
        VacuumEnvironment.LocationState.Clean);
    tve.addAgent(agent, VacuumEnvironment.LOCATION_A);

    tve.addEnvironmentView(new EnvironmentViewActionTracker(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());
  }
View Full Code Here

        envChanges.toString());
  }

  @Test
  public void testCleanDirty() {
    VacuumEnvironment tve = new VacuumEnvironment(
        VacuumEnvironment.LocationState.Clean,
        VacuumEnvironment.LocationState.Dirty);
    tve.addAgent(agent, VacuumEnvironment.LOCATION_A);

    tve.addEnvironmentView(new EnvironmentViewActionTracker(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());
  }
View Full Code Here

        envChanges.toString());
  }

  @Test
  public void testDirtyClean() {
    VacuumEnvironment tve = new VacuumEnvironment(
        VacuumEnvironment.LocationState.Dirty,
        VacuumEnvironment.LocationState.Clean);
    tve.addAgent(agent, VacuumEnvironment.LOCATION_A);

    tve.addEnvironmentView(new EnvironmentViewActionTracker(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());
  }
View Full Code Here

        envChanges.toString());
  }

  @Test
  public void testDirtyDirty() {
    VacuumEnvironment tve = new VacuumEnvironment(
        VacuumEnvironment.LocationState.Dirty,
        VacuumEnvironment.LocationState.Dirty);
    tve.addAgent(agent, VacuumEnvironment.LOCATION_A);

    tve.addEnvironmentView(new EnvironmentViewActionTracker(envChanges));

    tve.step(8);

    Assert.assertEquals(
        "Action[name==Suck]Action[name==Right]Action[name==Suck]Action[name==Left]Action[name==Right]Action[name==Left]Action[name==Right]Action[name==Left]",
        envChanges.toString());
  }
View Full Code Here

    envChanges = new StringBuilder();
  }

  @Test
  public void testCleanClean() {
    VacuumEnvironment tve = new VacuumEnvironment(
        VacuumEnvironment.LocationState.Clean,
        VacuumEnvironment.LocationState.Clean);
    tve.addAgent(agent, VacuumEnvironment.LOCATION_A);

    tve.addEnvironmentView(new EnvironmentViewActionTracker(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());
  }
View Full Code Here

        envChanges.toString());
  }

  @Test
  public void testCleanDirty() {
    VacuumEnvironment tve = new VacuumEnvironment(
        VacuumEnvironment.LocationState.Clean,
        VacuumEnvironment.LocationState.Dirty);
    tve.addAgent(agent, VacuumEnvironment.LOCATION_A);

    tve.addEnvironmentView(new EnvironmentViewActionTracker(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());
  }
View Full Code Here

TOP

Related Classes of aima.core.environment.vacuum.VacuumEnvironment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.