@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); } }
@Override protected Set<ParticipantSharedState> getSharedState() { Set<ParticipantSharedState> ss = super.getSharedState(); ss.add(ParticipantLocationService.createSharedState(getID(), myLoc)); return ss; }