Exemplo n.º 1
0
 @Override
 public int getWeightFromXYToXY(Area area, Point2D start, Point2D end) {
   int dstlength = ((int) start.distance(end)) / MoveConstants.DIVISION_UNIT;
   if (area instanceof Building || !area.isBlockadesDefined()) return dstlength;
   ReachablityState rs = Reachablity.isReachable((Road) area, start, end);
   switch (rs) {
     case Close:
       return MoveConstants.UNREACHABLE_COST_FOR_GRAPH_WEIGTHING;
     case FoggyClose:
       return dstlength * 5;
     case FoggyOpen:
       return dstlength * 2;
     default:
       return dstlength;
   }
 }
Exemplo n.º 2
0
 @Override
 public int getWeightToXY(Area area, Edge edge, Point2D dst) {
   int dstlength = ((int) edge.getMidPoint().distance(dst)) / MoveConstants.DIVISION_UNIT;
   if (area instanceof Building || !area.isBlockadesDefined()) return dstlength;
   ReachablityState rs = Reachablity.isReachable((Road) area, edge, dst);
   switch (rs) {
     case Close:
       return MoveConstants.UNREACHABLE_COST_FOR_GRAPH_WEIGTHING;
     case FoggyClose:
       //			return dstlength * 2;
     case FoggyOpen:
     case Open:
     default:
       return dstlength;
   }
 }
Exemplo n.º 3
0
  private void sendStockMessage(Path path) {
    if (me instanceof PoliceForceAgent) return;

    if (!(me.me() instanceof Human)) return;

    if (me.time() < 50) return;

    Human meEntity = (Human) me.me();

    if (meEntity.isBuriednessDefined() && meEntity.getBuriedness() > 0) return;

    if (meEntity.getImReachableToEdges().isEmpty()) return;

    if (me.isTimeToActFinished()) return;

    if (me.lastException != null) return;

    try {
      //			if (me.getMyClusterData().isCoverer())
      //				return;

      if (me.me().getAreaPosition().isBlockadesDefined()
          && me.me().getAreaPosition().getBlockadesID().isEmpty()) {
        boolean haveBlock = false;
        for (Area neighbour : me.me().getAreaPosition().getNeighbours()) {
          if (neighbour.isBlockadesDefined() && !neighbour.getBlockadesID().isEmpty())
            haveBlock = true;
        }
        if (!haveBlock) return;
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    log().debug("Sending Stock Message");
    me.messageBlock = new MessageBlock(MessageXmlConstant.HEADER_AGENT_STOCK);
    me.messageBlock.addData(
        MessageXmlConstant.DATA_AREA_INDEX, me.me().getAreaPosition().getAreaIndex());
    me.messages.add(me.messageBlock);
    me.lowCommunicationMessages.add(me.messageBlock);
  }