Ejemplo n.º 1
0
  @Override
  public void execute() {
    myLoc = locationService.getAgentLocation(getID());

    logger.info("My location is: " + this.myLoc);
    // get current simulation time
    int time = SimTime.get().intValue();
    // check db is available
    if (this.persist != null) {
      // save our location for this timestep
      this.persist.getState(time).setProperty("location", this.myLoc.toString());
    }

    // Create a random Move.
    int dx = Random.randomInt(2) - 1;
    int dy = Random.randomInt(2) - 1;
    Move move = new Move(dx, dy);

    // submit move action to the environment.
    try {
      environment.act(move, getID(), authkey);
    } catch (ActionHandlingException e) {
      logger.warn("Error trying to move", e);
    }
  }
 @Test
 public void test() {
   int speed = Random.randomInt();
   int dest = Random.randomInt();
   int spacing = Random.randomInt();
   RoadAgentGoals test = new RoadAgentGoals(speed, dest, spacing);
   assertTrue(test instanceof RoadAgentGoals);
   assertEquals(test.getSpeed(), speed);
   assertEquals(test.getDest(), dest);
   assertEquals(test.getSpacing(), spacing);
 }