コード例 #1
0
ファイル: Player.java プロジェクト: rymo4/fruitsalad
  public boolean pass(int[] bowl, int bowlId, int round, boolean canPick, boolean mustTake) {
    float[] currentBowl = Vectors.castToFloatArray(bowl);
    numFruits = Vectors.sum(currentBowl);
    if (!canPick) {
      log("CANT PICK RETURNING EARLY");
      return false;
    }

    log("|||||||||||||||||||||||||||||||||||||||||");
    log("Number of bowls that will pass: "******"Number of bowls remaining: " + bowlsRemaining);

    // Initialize the histogram now that we know how many fruit come in a bowl
    if (mle == null) {
      mle = new MLE((int) numFruits, numPlayers, prefs);
    }
    mle.addObservation(currentBowl);

    // calculate score for the bowl the we get
    float score = score(currentBowl);
    scoreStats.addData(score);

    // get MLE and score it
    float[] uniformBowl = new float[currentBowl.length];
    for (int i = 0; i < bowl.length; i++) {
      uniformBowl[i] = numFruits / bowl.length;
    }
    float uniformScore = score(uniformBowl);

    log("Uniform Score: " + uniformScore);
    log("MLE Score: " + score(mle.bowl(round == 0)));
    log("Score: " + score);
    float[] mleBowl = mle.bowl(round == 0);
    Stats bowlGenerationStats = mle.getBowlGenerationStats();
    float[] mlePlatter = mle.platter();
    float maxScore = maxScore(mlePlatter);
    boolean take =
        shouldTakeBasedOnScore(
            score, score(mleBowl), maxScore, bowlGenerationStats.standardDeviation());
    bowlsRemaining--;
    return take;
  }