private int pickFruit()
    {
        // generate a prefix sum
        int[] prefixsum = new int[FRUIT_NAMES.length];
        prefixsum[0] = currentFruits[0];
        for (int i = 1; i != FRUIT_NAMES.length; ++i)
            prefixsum[i] = prefixsum[i-1] + currentFruits[i];

        int currentFruitCount = prefixsum[FRUIT_NAMES.length-1];
        // roll a dice [0, currentFruitCount)
        int rnd = random.nextInt(currentFruitCount);
        
        for (int i = 0; i != FRUIT_NAMES.length; ++i)
            if (rnd < prefixsum[i])
                return i;

        assert false;

        return -1;
    }