コード例 #1
0
  @Override
  public void eventOccurred(final AuctionEvent event) {
    super.eventOccurred(event);

    if (event instanceof SimulationStartedEvent) {
      minValueDist =
          new Uniform(
              generator.getMinValueMin(),
              generator.getMinValueMax(),
              Galaxy.getInstance().getDefaultTyped(GlobalPRNG.class).getEngine());
      rangeDist =
          new Uniform(
              generator.getRangeMin(),
              generator.getRangeMax(),
              Galaxy.getInstance().getDefaultTyped(GlobalPRNG.class).getEngine());
    } else if (event instanceof GameStartingEvent) {

      final double minValue = minValueDist.nextDouble();
      final double maxValue = minValue + rangeDist.nextDouble();

      setDistribution(
          new Uniform(
              minValue,
              maxValue,
              Galaxy.getInstance().getDefaultTyped(GlobalPRNG.class).getEngine()));
      drawRandomValue();
    }
  }
コード例 #2
0
  protected AbstractDistribution createDistribution() {

    AbstractDistribution dist = null;
    try {
      // NOTE: cloning the template distribution is not used before it will
      // cause all generated distributions to have a random engine in the same
      // situation and thus generate the same random numbers.

      if (distribution != null) {
        dist = distribution.getClass().newInstance();
        if (dist instanceof StateCopyable) {
          ((StateCopyable) dist).copyStateFrom(distribution);
        } else {
          dist = null;
        }
      }
    } catch (final InstantiationException e) {
      e.printStackTrace();
      dist = null;
    } catch (final IllegalAccessException e) {
      e.printStackTrace();
      dist = null;
    }

    if (dist == null) {
      dist =
          new Uniform(
              minValue,
              maxValue,
              Galaxy.getInstance().getTyped(Game.P_CAT, GlobalPRNG.class).getEngine());
    }

    return dist;
  }
コード例 #3
0
  public void setup(final ParameterDatabase parameters, final Parameter base) {
    final Parameter defBase = new Parameter(RandomValuerGenerator.P_DEF_BASE);

    //// Added code starts here
    //		defBaseNorm = new Parameter(Normal.P_DEF_BASE);
    //// Added code ends here
    //
    minValue =
        parameters.getDouble(
            base.push(RandomValuerGenerator.P_MINVALUE),
            defBase.push(RandomValuerGenerator.P_MINVALUE),
            0);
    maxValue =
        parameters.getDouble(
            base.push(RandomValuerGenerator.P_MAXVALUE),
            defBase.push(RandomValuerGenerator.P_MAXVALUE),
            minValue);

    try {
      distribution =
          parameters.getInstanceForParameterEq(
              base.push(RandomValuerGenerator.P_DISTRIBUTION),
              defBase.push(RandomValuerGenerator.P_DISTRIBUTION),
              AbstractDistribution.class);

      if (distribution instanceof Parameterizable) {
        ((Parameterizable) distribution)
            .setup(parameters, base.push(RandomValuerGenerator.P_DISTRIBUTION));
      }
    } catch (final ParamClassLoadException e) {
      distribution =
          new Uniform(
              minValue,
              maxValue,
              Galaxy.getInstance().getDefaultTyped(GlobalPRNG.class).getEngine());
    }

    checkDistribution(distribution);
  }