package fruit.g4;

import java.util.*;

public class Player extends fruit.sim.Player
{
  private int[] prefs;
  private int[] platter;

  public void init(int nplayers, int[] pref) {
    prefs = pref;
    platter = new int[pref.length];
  }

  public boolean pass(int[] bowl, int bowlId, int round,
                      boolean canPick,
                      boolean mustTake) {
    int score = score(bowl);
    int numFruits = 0;
    for (int i = 0 ; i < bowl.length; i++){
      numFruits += bowl[i];
    }
    int[] uniformBowl = new int[bowl.length];

    for (int i = 0 ; i < bowl.length; i++){
      uniformBowl[i] = numFruits / bowl.length;
    }

    int uniformScore = score(uniformBowl);
    System.out.println("uniformScore: " + uniformScore);
    System.out.println("score: " + score);
    return uniformScore < score;
  }

  private int score(int[] bowl){
    int score = 0;
    for (int i = 0 ; i < bowl.length; i++){
      score += bowl[i] * prefs[i];
    }
    return score;
  }

  private Random random = new Random();
}

@@ -373,26 +373,28 @@
 Take) %7B%0A    
-in
+floa
 t score = sc
@@ -509,18 +509,20 @@
   %7D%0A    
-in
+floa
 t%5B%5D unif
@@ -535,18 +535,20 @@
 l = new 
-in
+floa
 t%5Bbowl.l
@@ -622,16 +622,24 @@
 owl%5Bi%5D =
+ (float)
  numFrui
@@ -667,18 +667,20 @@
  %7D%0A%0A    
-in
+floa
 t unifor
@@ -860,20 +860,198 @@
 ate 
-int score(in
+float score(int%5B%5D bowl)%7B%0A    float%5B%5D tmp = new float%5Bbowl.length%5D;%0A    for (int i = 0 ; i %3C bowl.length; i++) tmp%5Bi%5D = (float) bowl%5Bi%5D;%0A    return score(tmp);%0A  %7D%0A%0A  private float score(floa
 t%5B%5D 

Make score a float