int escogeRuleta(double probs[]) 
    {
        double acum = 0;
        int res = 0;
        double tope = rnd.nextDouble();
        while(res<probs.length && acum < tope) {
            acum += probs[res];
            res++;
        }
        if(res==probs.length) {
            res--;
        }
        //System.out.println("tope="+tope +", suma=" +acum +", idx=" +res);
        //System.out.println(res +",");
        return res;
    }