public void moveToShape(Collection<ShapeInArea> des, Class<? extends MoveType> type) throws SOSActionException { if (!(me.me() instanceof Human)) { log().warn("can't use move in Center Agent " + me + "\n"); return; } try { checkTraffic(); // TODO uncomment MoveType mt = moves.get(type.hashCode()); if (mt != null) { Path path = mt.getPathToShape(des); log().debug("MOVE " + type.getSimpleName() + "\nTO : " + path + "\n"); move(path); } else log().error(new Error("in move can not found type=" + type.getSimpleName())); } catch (SOSActionException e) { throw e; } catch (Exception er) { log().error(er); log().warn("using bfs for finding path"); ArrayList<Area> goals = new ArrayList<Area>(); for (ShapeInArea shapeInArea : des) { goals.add(shapeInArea.getArea(me.model())); } move(bfs.breadthFirstSearch((Area) me.location(), goals)); } log().error("in move can not found type=" + type.getSimpleName()); me.problemRest("in move can not found type=" + type.getSimpleName()); }
public void moveXY( Collection<Pair<? extends Area, Point2D>> destinations, Class<? extends MoveType> type) throws SOSActionException { if (!(me.me() instanceof Human)) { log().warn("can't use move in Center Agent " + me + "\n"); return; } try { checkTraffic(); MoveType mt = moves.get(type.hashCode()); if (mt != null) { Path path = mt.getPathToPoints(destinations); log().debug("MOVE XY" + type.getSimpleName() + "\nTO : " + path + "\n"); move(path); } else log().error(new Error("in move can not found type=" + type.getSimpleName())); } catch (SOSActionException e) { throw e; } catch (Exception er) { log().error(er); log().warn("using bfs for finding path"); move(bfs.breadthFirstSearchXY((Area) me.location(), destinations)); } log().error("in move can not found type=" + type.getSimpleName()); me.problemRest("in move can not found type=" + type.getSimpleName()); }
private void removeTemporaryTrafficBlocks() { while (!traffic.isEmpty() && me.time() > traffic.getFirst().second() + this.trafficRemainTime) { traffic.getFirst().first().setFreeTraffic(); log().info(" traffic removed " + traffic.getFirst().first()); traffic.removeFirst(); } if (me.location() instanceof Road) { // inBuildingStoppedCount = 0; // isBuildingCenterPassed = false; } }