Skip to content

Commit

Permalink
fixed alpha beta
Browse files Browse the repository at this point in the history
  • Loading branch information
mbluemer committed May 2, 2017
1 parent f09370c commit 6b93529
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/MinimaxSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,19 @@ double MinimaxSearch::alphaBeta(bup &board, double alpha, double beta, int depth
//
// black is max player here
double v;
if (board->player() == "black") {
if (board->getIsBlacksTurn()) {
v = std::numeric_limits<double>::lowest();
for (mup &move : board->actions()) {
bup result = board->result(move);
v = std::max(v, alphaBeta(result, alpha, beta, depth + 1));
if (v >= beta) return v;
alpha = std::max(alpha, v);
alpha = std::max(alpha, alphaBeta(result, alpha, beta, depth + 1));
if (beta <= alpha) return beta;
}
} else {
v = std::numeric_limits<double>::max();
for (mup &move : board->actions()) {
bup result = board->result(move);
v = std::min(v, alphaBeta(result, alpha, beta, depth + 1));
if (v <= alpha) return v;
beta = std::min(beta, v);
beta = std::min(beta, alphaBeta(result, alpha, beta, depth + 1));
if (beta <= alpha) return alpha;
}
}

Expand Down

0 comments on commit 6b93529

Please sign in to comment.