Skip to content

Commit

Permalink
Fix one more bug with root node with all weightless children causing …
Browse files Browse the repository at this point in the history
…genmove to fail
  • Loading branch information
lightvector committed Aug 5, 2024
1 parent 6a0c33d commit b57dd49
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cpp/configs/gtp_human9d_search_example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ resignMinMovesPerBoardArea = 0.40
# This is due to the strong bias of the human SL network.
# You can reduce this number if you are on weaker hardware. It may reduce strength a bit but will still
# provide a huge strength boost over using the humanSL network alone as in gtp_human5k_example.cfg
# It's NOT recommended to reduce this below about 30-40 visits, since that will result in too few explorations of a variety of moves.
# If you want to adjust strength, see humanSLChosenMovePiklLambda instead.
maxVisits = 400 # 40 in gtp_human5k_example.cfg.

# Having more than one thread speeds up search when visits are larger.
Expand All @@ -67,7 +69,7 @@ humanSLChosenMoveIgnorePass = true
# this may still produce a very strong player.
# To calibrate for some but less strength gain, it will take experimentation - in addition to increasing this value a lot,
# you can also try using old/small KataGo nets (e.g. b6c96, b10c128), reducing visits (though reducing below about 30-40
# is not recommended), or using the humanSLModel itself as the main "-model".
# is NOT recommended), or using the humanSLModel itself as the main "-model".
humanSLChosenMovePiklLambda = 0.06 # was 100000000 in gtp_human5k_example.cfg.

# Spend 80% of visits to explore humanSL moves to ensure they get evaluations to use with humanSLChosenMovePiklLambda
Expand Down
17 changes: 15 additions & 2 deletions cpp/search/searchresults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,21 @@ bool Search::getPlaySelectionValues(
maxValue = playSelectionValues[i];
}

if(maxValue <= 1e-50)
return false;
if(maxValue <= 1e-50) {
//If we reached this point we have nonzero many children but the children are all weightless.
//In that case, at least set each one to be weighted by its policy.
for(int i = 0; i<numChildren; i++) {
playSelectionValues[i] = std::max(0.0,(double)policyProbs[getPos(locs[i])]);
}
//Recompute max
for(int i = 0; i<numChildren; i++) {
if(playSelectionValues[i] > maxValue)
maxValue = playSelectionValues[i];
}
if(maxValue <= 1e-50) {
return false;
}
}

//Sanity check - if somehow we had more than this, something must have overflowed or gone wrong
assert(maxValue < 1e40);
Expand Down

0 comments on commit b57dd49

Please sign in to comment.