Skip to content

Commit

Permalink
Check for is_terminal() directly after creating a new node (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
QueensGambit authored Aug 2, 2023
1 parent 258053d commit 282c671
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions engine/src/searchthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ Node* SearchThread::add_new_node_to_tree(StateObj* newState, Node* parentNode, C
{
bool transposition;
Node* newNode = parentNode->add_new_node_to_tree(mapWithMutex, newState, childIdx, searchSettings, transposition);
if (newNode->is_terminal()) {
nodeBackup = NODE_TERMINAL;
return newNode;
}
if (transposition) {
const float qValue = parentNode->get_child_node(childIdx)->get_value();
transpositionValues->add_element(qValue);
Expand Down Expand Up @@ -294,11 +298,9 @@ void SearchThread::set_nn_results_to_child_nodes()
{
size_t batchIdx = 0;
for (auto node: *newNodes) {
if (!node->is_terminal()) {
fill_nn_results(batchIdx, net->is_policy_map(), valueOutputs, probOutputs, auxiliaryOutputs, node,
tbHits, rootState->mirror_policy(newNodeSideToMove->get_element(batchIdx)),
searchSettings, rootNode->is_tablebase());
}
fill_nn_results(batchIdx, net->is_policy_map(), valueOutputs, probOutputs, auxiliaryOutputs, node,
tbHits, rootState->mirror_policy(newNodeSideToMove->get_element(batchIdx)),
searchSettings, rootNode->is_tablebase());
++batchIdx;
}
}
Expand Down

0 comments on commit 282c671

Please sign in to comment.