Skip to content

Commit

Permalink
Micro-optimize checking local float before calling bool method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mardak committed Mar 29, 2019
1 parent 5f9c77e commit 4e92d4d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mcts/search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -953,13 +953,13 @@ SearchWorker::NodeToProcess SearchWorker::PickNodeToExtend(
const float Q = child.GetQ(fpu);
if (!is_root_node) {
// If at least one move is checkmate, treat this position as loss
if (child.IsTerminal() && Q == 1.0f) {
if (Q == 1.0f && child.IsTerminal()) {
node->MakeTerminal(GameResult::BLACK_WON);
return NodeToProcess::Single(node, depth);
}

// Can only become win if every move is checkmated
should_become_win &= child.IsTerminal() && Q == -1.0f;
should_become_win &= Q == -1.0f && child.IsTerminal();
}

const float score = child.GetU(puct_mult) + Q;
Expand Down

0 comments on commit 4e92d4d

Please sign in to comment.