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 Path getPathToShapes(Collection<ShapeInArea> des, Class<? extends MoveType> type) { try { MoveType mt = moves.get(type.hashCode()); if (mt != null) { Path path = mt.getPathToShape(des); return path; } else { log().error(new Error("in move can not found type=" + type.getSimpleName())); } } 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())); } return getPathTo(goals, type); } return null; }