Code: Select all
NodeControl NodeAb::visit(Move move) {
if (!control.countNode()) { return Abort; }
playMove(move);
if (movesCount == 0) {
//mated or stalemated
score = StaticEval();
}
else if (draft == 0) {
score = StaticEval(); // QS in TODO
}
else {
alpha = -parent.beta;
beta = -parent.alpha;
if (visitChildren() == Abort); { return Abort; }
}
if (parent.score < -score) {
parent.score = -score;
control.setPv(parent.ply, move);
if (parent.alpha < parent.score) {
parent.alpha = parent.score;
if (parent.alpha >= parent.beta) {
return BetaCutoff;
}
}
}
return Continue;
}
NodeControl NodeAb::visitChildren() {
score = Score::Minimum;
//create a new empty node that will be used for all children moves
auto child = NodeAb{*this};
//THE QUESTION OF THE TOPIC, HOW TO USE IT?
auto move = control.pv[0][ply];
if (move) {
if (isLegalMove(move)) {
RETURN_IF_CUTOFF_OR_ABORT (child.visit(move));
}
}
for (auto move : generateMove()) {
RETURN_IF_CUTOFF_OR_ABORT (child.visit(move));
}
return Continue;
}