Beispiel #1
0
  private void addProbScore(ArrayList<Building> region, Building center) {
    for (Building neigh : center.realNeighbors_Building()) {
      neigh.setSpecialForFire(neigh.getValuSpecialForFire() - 100000, " -100  " + center);
      //////////////////////////////////////
      if (neigh.updatedtime() >= center.updatedtime()) {
        log.info("\t\t\t Neigh is update " + neigh);
        continue;
      }
      if (neigh.updatedtime() >= center.getTemperatureIncreasedTime()) {
        log.info(
            "\t\t\t Neigh is update after sensed temp "
                + neigh
                + "    NeighUpdTime="
                + neigh.updatedtime()
                + "\t increaseTime="
                + center.getTemperatureIncreasedTime());
        continue;
      }
      /////////////////////////////////
      if (agent.model().time() - neigh.updatedtime() < Math.min(8, agent.model().time() / 2))
        continue;

      if (center.updatedtime() < neigh.updatedtime() + 3) continue;

      if (!region.contains(neigh)) continue;

      neigh.setSpecialForFire(neigh.getValuSpecialForFire() + 100000, "Add 100 score ");

      double t = temperatureScore(center);

      t *=
          (center.getRealNeighValue(neigh) + 0.001)
              * 100d
              / ((Math.max(1, distance(center, neigh) / 1000)));
      if (center.getTemperature() < 3)
        t += center.getNeighValue(neigh) * 200 * temperatureScore(center);

      double c = 1;
      for (Building n2 : neigh.realNeighbors_Building()) {
        if (n2.getTemperature() > 0) c -= neigh.getNeighValue(n2);
        else c += neigh.getRealNeighValue(n2);
      }

      neigh.setSpecialForFire(
          neigh.getValuSpecialForFire() + (int) (Math.ceil(t * c)),
          " temp = "
              + temperatureScore(center)
              + " distance and neigh = "
              + t
              + "  c "
              + c
              + " "
              + center);

      //			if (!res.contains(neigh))
      //				res.add(neigh);

    }
  }
Beispiel #2
0
 @Override
 protected void paint(Building entity, Graphics2D g, ScreenTransform transform) {
   Shape shape;
   g.setColor(Color.yellow);
   for (Building b : entity.neighbors_Building()) {
     shape = NamayangarUtils.transformShape(b, transform);
     g.draw(shape);
     NamayangarUtils.drawString(entity.getNeighValue(b) + "", g, transform, b);
   }
   g.setColor(Color.GREEN);
   shape = NamayangarUtils.transformShape(entity, transform);
   g.fill(shape);
 }