Hey for some reason visual studios is saying variable score is undefined but looking at the code, I can't see why it would not be set. Here is my code below.
How is that possible because the score variable is set no matter which way the if statement goes. Is this an error on visual studios?
I solved this by defining score before the if statement, but shouldn't this work as well?
C++:
int reduction = 1;
if (moveCount == 0) {
Score score = -search(position.makeMove(move), -beta, -alpha, depth - reduction, ply + 1);
} else {
if (moveCount > 3 && !(move.bit & 2)) reduction = 3;
Score score = -search(position.makeMove(move), -alpha - 1, -alpha, depth - reduction, ply + 1);
if (alpha < score < beta) {
score = -search(position.makeMove(move), -beta, -score, depth - reduction, ply + 1);
}
}
if (score >= beta) { // Says score is undefined.
}
How is that possible because the score variable is set no matter which way the if statement goes. Is this an error on visual studios?
Post automatically merged:
I solved this by defining score before the if statement, but shouldn't this work as well?
Last edited: