Phase10/src/com/github/s7uxn37/phase10/Intelligence.java
/**
     * Auxiliary method to handleFrom, should not be called directly
     */
Auxiliary method to handleFrom, should not be called directly
Auxiliary method to handleFrom should not be called directly
static boolean handleRemove(ArrayList<Card> cards, String collLabel, Card c, int startIndex, boolean verbose) {
        int i = cards.indexOf(c);  
        boolean found = !c.isUnknown() && (i != -1); 
        if (!found) {                
            if(verbose) log(
                    "known " + collLabel + " card not found, treating like unknown..."
            );
        } else {
            try {
                cards.remove(i);       
                if(verbose) log(
                        "known " + collLabel + " card removed"
                );
            } catch (IndexOutOfBoundsException e) {
                if(verbose) log(
                        collLabel + " card not found, all cards known"
                );
                return false;
            }
        }
        if (!found) { 
            double sum = 0;
            for (int j = startIndex; j < cards.size(); j++) {
                sum += cards.get(j).prob;
            }
            double multiplier = 1 - 1/sum;
            for (int j = startIndex; j < cards.size(); j++) {
                cards.get(j).prob *= multiplier;
            }
            if(verbose) log(
                    "unknown " + collLabel + " card removed, probabilities decreased"
            );
        }
        return true;
    }
static boolean handleRemove ( ArrayList < Card > cards , String collLabel , Card c , int startIndex , boolean verbose ) { int i = cards . indexOf ( c ) ; boolean found = ! c . isUnknown ( ) && ( i != - 1 ) ; if ( ! found ) { if ( verbose ) log ( "known " + collLabel + " card not found, treating like unknown..." ) ; } else { try { cards . remove ( i ) ; if ( verbose ) log ( "known " + collLabel + " card removed" ) ; } catch ( IndexOutOfBoundsException e ) { if ( verbose ) log ( collLabel + " card not found, all cards known" ) ; return false ; } } if ( ! found ) { double sum = 0 ; for ( int j = startIndex ; j < cards . size ( ) ; j ++ ) { sum += cards . get ( j ) . prob ; } double multiplier = 1 - 1 / sum ; for ( int j = startIndex ; j < cards . size ( ) ; j ++ ) { cards . get ( j ) . prob *= multiplier ; } if ( verbose ) log ( "unknown " + collLabel + " card removed, probabilities decreased" ) ; } return true ; }
Auxiliary method to handleFrom, should not be called directly
Auxiliary method to handleFrom should not be called directly
// try to find card
 // finding an unknown card must always fail
 // if not found, treat like unknown card
 // remove found card
 // card unknown
 // decrease probability of all cards, starting at startIndex
