group3.c
int g3_chooseMove(double *probabilities) {
    // Choose a number from 0 through 1
    double roll = (double) rand() / RAND_MAX;
    double cumulativeProb = 0;

    int i;
    for (i = 0; i < NUM_COLS; i++) {
        cumulativeProb += probabilities[i];
        if (cumulativeProb >= roll) {
            return i;
        }
    }

    // This should never happen.
    return rand()%NUM_COLS;
}
// Randomly choose a move based on probabilities
Randomly choose a move based on probabilities
Randomly choose a move based on probabilities
int g3_chooseMove(double *probabilities) {
    double roll = (double) rand() / RAND_MAX;
    double cumulativeProb = 0;
    int i;
    for (i = 0; i < NUM_COLS; i++) {
        cumulativeProb += probabilities[i];
        if (cumulativeProb >= roll) {
            return i;
        }
    }
    return rand()%NUM_COLS;
}
int g3_chooseMove ( double * probabilities ) { double roll = ( double ) rand ( ) / RAND_MAX ; double cumulativeProb = 0 ; int i ; for ( i = 0 ; i < NUM_COLS ; i ++ ) { cumulativeProb += probabilities [ i ] ; if ( cumulativeProb >= roll ) { return i ; } } return rand ( ) % NUM_COLS ; }
Randomly choose a move based on probabilities
Randomly choose a move based on probabilities
// Choose a number from 0 through 1 // This should never happen.