group3.c
int g3_bestMove(g3_proportion *scores, int *possibleMoves, const struct connect4 *game) {
    double greatest = -1;
    int bestMove = -1;

    int i;
    for(i = 0; i < NUM_COLS; i++) {
        double weight = (double) scores[i].w_i / g3_max(scores[i].n_i, 1);
        int validRow = get_row(game, i);
        int safe = g3_isSafe(game, validRow, i, game->whoseTurn);
        //printf("Column %d has a weight of %g\n", i, weight);
        if (possibleMoves[i] == 1 && weight > greatest &&
                (safe || bestMove == -1)) {
            if (safe) greatest = weight; // Only save the weight if it was a safe move
            bestMove = i;
        }
    }

    return bestMove;
}
// Determine the best move, given the scores, the number of simulations
Determine the best move, given the scores, the number of simulations
Determine the best move given the scores the number of simulations
int g3_bestMove(g3_proportion *scores, int *possibleMoves, const struct connect4 *game) {
    double greatest = -1;
    int bestMove = -1;
    int i;
    for(i = 0; i < NUM_COLS; i++) {
        double weight = (double) scores[i].w_i / g3_max(scores[i].n_i, 1);
        int validRow = get_row(game, i);
        int safe = g3_isSafe(game, validRow, i, game->whoseTurn);
        if (possibleMoves[i] == 1 && weight > greatest &&
                (safe || bestMove == -1)) {
            if (safe) greatest = weight; 
            bestMove = i;
        }
    }
    return bestMove;
}
int g3_bestMove ( g3_proportion * scores , int * possibleMoves , const struct connect4 * game ) { double greatest = -1 ; int bestMove = -1 ; int i ; for ( i = 0 ; i < NUM_COLS ; i ++ ) { double weight = ( double ) scores [ i ] . w_i / g3_max ( scores [ i ] . n_i , 1 ) ; int validRow = get_row ( game , i ) ; int safe = g3_isSafe ( game , validRow , i , game -> whoseTurn ) ; if ( possibleMoves [ i ] == 1 && weight > greatest && ( safe || bestMove == -1 ) ) { if ( safe ) greatest = weight ; bestMove = i ; } } return bestMove ; }
Determine the best move, given the scores, the number of simulations
Determine the best move given the scores the number of simulations
//printf("Column %d has a weight of %g\n", i, weight); // Only save the weight if it was a safe move