public static Blockade hasIntersectionWithBlockades(Pair<Integer, Integer> point, Area a) { double size = ReachablityConstants.AGENT_WIDTH * 1 * 6; if (!(a instanceof Road)) return null; Road road = (Road) a; if (!road.isBlockadesDefined()) return null; if (road.getBlockades().size() == 0) return null; Ellipse2D.Double expandHuman = new Ellipse2D.Double(a.getX() - size / 2, a.getY() - size / 2, size, size); java.awt.geom.Area area = new java.awt.geom.Area(expandHuman); for (Blockade b : road.getBlockades()) { area.intersect(new java.awt.geom.Area(b.getShape())); if (!area.isEmpty()) return b; } return null; }
private int computeBlockadeValue(Blockade blockade) { return (int) (1000000 / Math.max(agent.me().getPositionPoint().distance(blockade.getCenteroid()), 1)); // return 100000 / blockade.getRepairCost(); // TODO // moteallegh be kodam sakhteman hastand.(CV) }
public boolean isReachableTo(StandardEntity se) { if (se instanceof Human) { Human hum = (Human) se; if (agent.getVisibleEntities(Human.class).contains(hum) && hum.isPositionDefined() && hum.getAreaPosition().isBlockadesDefined()) { for (Blockade blockade : hum.getAreaPosition().getBlockades()) { if (blockade.getShape().contains(hum.getPositionPoint().toGeomPoint())) return false; } } if (!hum.getImReachableToEdges().isEmpty()) return agent .move .getMoveType(PoliceReachablityMove.class) .isReallyReachableTo(hum.getImReachableToEdges()); } return isReachableTo(se.getPositionPair()); }
private void justMakeReachableWithGoodReachablity(Path path) throws SOSActionException { log.info("making reachable with good reachablity to " + path); ArrayList<Blockade> blocks = reachablityTool.getBlockingBlockadeOfPath(path); log.debug("clearableBlockadeToReachablebyReachablityTool is " + blocks); ArrayList<Blockade> blockadeEdge = reachableWithEdge.getBlockingBlockadeOfPath(path); blocks.addAll(blockadeEdge); log.debug("clearableBlockadeToReachableWithEdge is " + blocks); Blockade clearBlock = chooseBestBlockade(blocks); if (clearBlock != null) clear(clearBlock); else if (clearBlock == null && !blocks.isEmpty()) { log.debug("No blockade is in range but the path is close!!! so move to close area"); ArrayList<Pair<? extends Area, Point2D>> dest = new ArrayList<Pair<? extends Area, Point2D>>(); for (Blockade blockade : blocks) { dest.add(blockade.getPositionPair()); } path = agent.move.getPathToPoints(dest, PoliceMove.class); agent.move(path); } else log.debug("No Blockade found---> we can move"); }