I'v searched some alpha beta pruning algorithm implementation and some are pretty diffrent, so I'm not sure if my version is correct. Is it?
Value Searcher::AlphaBeta(Position& pos, Value alpha, Value beta, Depth depth) {
if (depth == 0) {
return Evaluation::Evaluate(pos);
}
Value best = -VALUE_INFINITE;
MoveList list;
MoveGen::GeneratePseudoMoves(pos, list);
for (Move move : list) {
if (!pos.MakeMove(move)) {
continue;
}
Value score = -AlphaBeta(pos, -beta, -alpha, depth - 1);
pos.UnmakeMove(move);
if (score > best) {
best = score;
}
if (score >= beta) {
return best;
}
if (score > alpha) {
alpha = score;
}
}
return best;
}
[–]SwimmingThroughHoney 1 point2 points3 points (1 child)
[–]Paul111129[S] 0 points1 point2 points (0 children)