@Override
    public double minValue(BackgammonState state, String player, double alpha, double beta, int depth) {
        expandedNodes++;
        maxDepth = Math.max(maxDepth, depth);
        if (depth >= currDepthLimit || state.getUtility() == 1 || state.getUtility() == 0) {
            return eval(state, player); //leaf node, return utility
        }
        else {
            double value = 1, newValue;
            BackgammonState resultState;
            for (Integer action : game.getActions(state)) {
                resultState = ((BackgammonGame)game).getResult(state, action, true);
                
                if (game.getPlayer(resultState).length() == player.length()){ //max is playing next
                    //the next state is a fresh turn, so we must consider all possible dice rolls
                    newValue = 0;
                    for (int i = 1; i < 7; i++){
                        for (int j = i; j < 7; j++){
                            resultState.setDice(i,j);
                            newValue += maxValue(resultState, player, alpha, beta, depth + 1) / (i == j ? 36.0 : 18.0);
                        }
                    }
                }
                else{
                    newValue = minValue(resultState, player, alpha, beta, depth + 1);
                }

                if (newValue <= alpha) return newValue;
                
                value = Math.min(newValue, value);
                beta = Math.min(beta, value);
            }
            return value;
        }
    }