예제 #1
0
    public DataPoint2D generateTemperatureAt(int x, int z) {
      /* Rasterize the coordinates */
      x =
          MathHelper.floorDivision(x, DefaultWorldProvider.SAMPLE_RATE_TEMPERATURE)
              * DefaultWorldProvider.SAMPLE_RATE_TEMPERATURE;
      z =
          MathHelper.floorDivision(z, DefaultWorldProvider.SAMPLE_RATE_TEMPERATURE)
              * DefaultWorldProvider.SAMPLE_RATE_TEMPERATURE;

      DataResults dr = gatherDataAround(_temperatures, x, z, 50);

      if (dr.count == 0) {
        DataPoint2D data = new DataPoint2D(x, z, _random.randomInt(25, 32));
        _temperatures.add(data);
        return data;
      } else {
        float diff = _random.exponentialRandom(16.0f, 2);
        diff = _random.randomBoolean() ? diff : -diff;
        DataPoint2D data =
            new DataPoint2D(x, z, (int) MathHelper.clamp(dr.avg + diff, 10.0f, 50.0f));
        _temperatures.add(data);
        if (DEBUG_WOLRD_PROVIDER)
          System.out.println("Temp (" + x + ", " + z + ") = " + data.getData());
        return data;
      }
    }
예제 #2
0
    public DataPoint2D generateHumidityAt(int x, int z) {
      /* Rasterize the coordinates */
      x =
          MathHelper.floor((float) x / DefaultWorldProvider.SAMPLE_RATE_HORIZONTAL)
              * DefaultWorldProvider.SAMPLE_RATE_HORIZONTAL;
      z =
          MathHelper.floor((float) z / DefaultWorldProvider.SAMPLE_RATE_HORIZONTAL)
              * DefaultWorldProvider.SAMPLE_RATE_HORIZONTAL;

      DataResults dr = gatherDataAround(_humidities, x, z, 40);

      if (dr.count == 0) {
        DataPoint2D data = new DataPoint2D(x, z, _random.randomInt(60, 80));
        _humidities.add(data);
        return data;
      } else {
        float diff = _random.exponentialRandom(100.0f, 4);
        diff = _random.randomBoolean() ? diff : -diff;
        DataPoint2D data =
            new DataPoint2D(x, z, (int) MathHelper.clamp(dr.avg + diff, 30.0f, 95.0f));
        _humidities.add(data);
        if (DEBUG_WOLRD_PROVIDER)
          System.out.println("Humidity (" + x + ", " + z + ") = " + data.getData());
        return data;
      }
    }