Skip to content

Commit aa0c53c

Browse files
committed
Option to report mcts triple ko prob in gtp and analysis
1 parent 76eba50 commit aa0c53c

21 files changed

+185
-16
lines changed

cpp/command/analysis.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct AnalyzeRequest {
3535
bool includeMovesOwnershipStdev;
3636
bool includePolicy;
3737
bool includePVVisits;
38+
bool includeNoResultValue;
3839

3940
bool reportDuringSearch;
4041
double reportDuringSearchEvery;
@@ -238,6 +239,7 @@ int MainCmds::analysis(const vector<string>& args) {
238239
"includeOwnershipStdev",
239240
"includePolicy",
240241
"includePVVisits",
242+
"includeNoResultValue",
241243
"reportDuringSearchEvery",
242244
"firstReportDuringSearchAfter",
243245
"priority",
@@ -323,6 +325,7 @@ int MainCmds::analysis(const vector<string>& args) {
323325
request->includeOwnership,request->includeOwnershipStdev,
324326
request->includeMovesOwnership,request->includeMovesOwnershipStdev,
325327
request->includePVVisits,
328+
request->includeNoResultValue,
326329
ret
327330
);
328331

@@ -618,6 +621,7 @@ int MainCmds::analysis(const vector<string>& args) {
618621
rbase.includeMovesOwnershipStdev = false;
619622
rbase.includePolicy = false;
620623
rbase.includePVVisits = false;
624+
rbase.includeNoResultValue = false;
621625
rbase.reportDuringSearch = false;
622626
rbase.reportDuringSearchEvery = 1e30;
623627
rbase.firstReportDuringSearchAfter = 1e30;
@@ -1027,6 +1031,11 @@ int MainCmds::analysis(const vector<string>& args) {
10271031
if(!suc)
10281032
continue;
10291033
}
1034+
if(input.find("includeNoResultValue") != input.end()) {
1035+
bool suc = parseBoolean(input, "includeNoResultValue", rbase.includeNoResultValue, "Must be a boolean");
1036+
if(!suc)
1037+
continue;
1038+
}
10301039
if(input.find("reportDuringSearchEvery") != input.end()) {
10311040
bool suc = parseDouble(input, "reportDuringSearchEvery", rbase.reportDuringSearchEvery, 0.001, 1000000.0, "Must be number of seconds from 0.001 to 1000000.0");
10321041
if(!suc)
@@ -1171,6 +1180,7 @@ int MainCmds::analysis(const vector<string>& args) {
11711180
newRequest->includeMovesOwnershipStdev = rbase.includeMovesOwnershipStdev;
11721181
newRequest->includePolicy = rbase.includePolicy;
11731182
newRequest->includePVVisits = rbase.includePVVisits;
1183+
newRequest->includeNoResultValue = rbase.includeNoResultValue;
11741184
newRequest->reportDuringSearch = rbase.reportDuringSearch;
11751185
newRequest->reportDuringSearchEvery = rbase.reportDuringSearchEvery;
11761186
newRequest->firstReportDuringSearchAfter = rbase.firstReportDuringSearchAfter;

cpp/command/contribute.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static void runAndUploadSingleGame(
273273

274274
// Usual analysis response fields
275275
ret["turnNumber"] = hist.moveHistory.size();
276-
search->getAnalysisJson(perspective,analysisPVLen,preventEncore,true,alwaysIncludeOwnership,false,false,false,false,ret);
276+
search->getAnalysisJson(perspective,analysisPVLen,preventEncore,true,alwaysIncludeOwnership,false,false,false,false,false,ret);
277277
std::cout << ret.dump() + "\n" << std::flush; // no endl due to race conditions
278278
}
279279

cpp/command/evalsgf.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ int MainCmds::evalsgf(const vector<string>& args) {
642642
bool includeMovesOwnershipStdev = false;
643643
bool includePVVisits = true;
644644
nlohmann::json ret;
645+
bool includeNoResultValue = false;
645646
bool suc = search->getAnalysisJson(
646647
perspective,
647648
analysisPVLen,
@@ -652,6 +653,7 @@ int MainCmds::evalsgf(const vector<string>& args) {
652653
includeMovesOwnership,
653654
includeMovesOwnershipStdev,
654655
includePVVisits,
656+
includeNoResultValue,
655657
ret
656658
);
657659
if(suc) {

cpp/command/gtp.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@ struct GTPEngine {
734734
bool showMovesOwnershipStdev = false;
735735
bool showPVVisits = false;
736736
bool showPVEdgeVisits = false;
737+
bool showNoResultValue = false;
737738
double secondsPerReport = TimeControls::UNLIMITED_TIME_DEFAULT;
738739
vector<int> avoidMoveUntilByLocBlack;
739740
vector<int> avoidMoveUntilByLocWhite;
@@ -875,6 +876,8 @@ struct GTPEngine {
875876
out << " scoreStdev " << data.scoreStdev;
876877
out << " scoreLead " << lead;
877878
out << " scoreSelfplay " << scoreMean;
879+
if(args.showNoResultValue)
880+
out << " noResultValue " << data.noResultValue;
878881
out << " prior " << data.policyPrior;
879882
out << " lcb " << lcb;
880883
out << " utilityLcb " << utilityLcb;
@@ -1712,6 +1715,7 @@ static GTPEngine::AnalyzeArgs parseAnalyzeCommand(
17121715
bool showMovesOwnershipStdev = false;
17131716
bool showPVVisits = false;
17141717
bool showPVEdgeVisits = false;
1718+
bool showNoResultValue = false;
17151719
vector<int> avoidMoveUntilByLocBlack;
17161720
vector<int> avoidMoveUntilByLocWhite;
17171721
bool gotAvoidMovesBlack = false;
@@ -1852,6 +1856,9 @@ static GTPEngine::AnalyzeArgs parseAnalyzeCommand(
18521856
else if(isKata && key == "pvEdgeVisits" && Global::tryStringToBool(value,showPVEdgeVisits)) {
18531857
continue;
18541858
}
1859+
else if(isKata && key == "noResultValue" && Global::tryStringToBool(value,showNoResultValue)) {
1860+
continue;
1861+
}
18551862

18561863
parseFailed = true;
18571864
break;
@@ -1872,6 +1879,7 @@ static GTPEngine::AnalyzeArgs parseAnalyzeCommand(
18721879
args.showMovesOwnershipStdev = showMovesOwnershipStdev;
18731880
args.showPVVisits = showPVVisits;
18741881
args.showPVEdgeVisits = showPVEdgeVisits;
1882+
args.showNoResultValue = showNoResultValue;
18751883
args.avoidMoveUntilByLocBlack = avoidMoveUntilByLocBlack;
18761884
args.avoidMoveUntilByLocWhite = avoidMoveUntilByLocWhite;
18771885
return args;

cpp/runcmdtests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ echo -e 'genmove_debug b\ngenmove_debug w\ngenmove_debug b' | ./katago gtp -conf
2424
echo tests/results/gtp/nologconfig
2525
echo -e 'genmove_debug b\ngenmove_debug w\ngenmove_debug b' | ./katago gtp -config configs/gtp_example.cfg -model tests/models/g170-b6c96-s175395328-d26788732.bin.gz -override-config "logFile=tests/results/gtp/nologconfig.log, logConfigContents=false, logDir=, logTimeStamp=false, maxVisits=100, maxPlayouts=10000, numSearchThreads=1, nnRandomize=false, nnRandSeed=forTesting, searchRandSeed=forTesting, forDeterministicTesting=true, cudaUseFP16 = false, trtUseFP16 = false, openclUseFP16 = false, cudaUseNHWC = false" 1> tests/results/gtp/nologconfig.stdout 2> tests/results/gtp/nologconfig.stderr
2626
echo tests/results/gtp/genmoveanalyze
27-
echo -e 'kata-genmove_analyze b\nkomi 5\nkata-genmove_analyze w rootInfo true\nkata-genmove_analyze b rootInfo true' | ./katago gtp -config configs/gtp_example.cfg -model models/b18c384nbt-uec.bin.gz -override-config "logFile=tests/results/gtp/genmoveanalyze.log, logConfigContents=false, logDir=, logTimeStamp=false, maxVisits=30, maxPlayouts=10000, numSearchThreads=1, nnRandomize=false, nnRandSeed=forTesting, searchRandSeed=forTesting, forDeterministicTesting=true, cudaUseFP16 = false, trtUseFP16 = false, openclUseFP16 = false, cudaUseNHWC = false, defaultBoardSize = 9" 1> tests/results/gtp/genmoveanalyze.stdout 2> tests/results/gtp/genmoveanalyze.stderr
27+
echo -e 'kata-genmove_analyze b\nkomi 5\nkata-genmove_analyze w rootInfo true\nkata-genmove_analyze b rootInfo true noResultValue true' | ./katago gtp -config configs/gtp_example.cfg -model models/b18c384nbt-uec.bin.gz -override-config "logFile=tests/results/gtp/genmoveanalyze.log, logConfigContents=false, logDir=, logTimeStamp=false, maxVisits=30, maxPlayouts=10000, numSearchThreads=1, nnRandomize=false, nnRandSeed=forTesting, searchRandSeed=forTesting, forDeterministicTesting=true, cudaUseFP16 = false, trtUseFP16 = false, openclUseFP16 = false, cudaUseNHWC = false, defaultBoardSize = 9" 1> tests/results/gtp/genmoveanalyze.stdout 2> tests/results/gtp/genmoveanalyze.stderr
2828
echo tests/results/gtp/searchcancellable
2929
echo -e 'kata-search_analyze b\nkata-genmove_analyze b\nkomi 5\nkata-search_analyze_cancellable w rootInfo true\nkata-search_cancellable w' | ./katago gtp -config configs/gtp_example.cfg -model models/b18c384nbt-uec.bin.gz -override-config "logFile=tests/results/gtp/searchcancellable.log, logConfigContents=false, logDir=, logTimeStamp=false, maxVisits=500, maxPlayouts=10000, numSearchThreads=1, nnRandomize=false, nnRandSeed=forTesting, searchRandSeed=forTesting, forDeterministicTesting=true, cudaUseFP16 = false, trtUseFP16 = false, openclUseFP16 = false, cudaUseNHWC = false, defaultBoardSize = 9" 1> tests/results/gtp/searchcancellable.stdout 2> tests/results/gtp/searchcancellable.stderr
3030
echo tests/results/gtp/humansl

cpp/search/analysisdata.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ AnalysisData::AnalysisData()
1010
resultUtility(0.0),
1111
scoreUtility(0.0),
1212
winLossValue(0.0),
13+
noResultValue(0.0),
1314
policyPrior(0.0),
1415
scoreMean(0.0),
1516
scoreStdev(0.0),
@@ -41,6 +42,7 @@ AnalysisData::AnalysisData(const AnalysisData& other)
4142
resultUtility(other.resultUtility),
4243
scoreUtility(other.scoreUtility),
4344
winLossValue(other.winLossValue),
45+
noResultValue(other.noResultValue),
4446
policyPrior(other.policyPrior),
4547
scoreMean(other.scoreMean),
4648
scoreStdev(other.scoreStdev),
@@ -72,6 +74,7 @@ AnalysisData::AnalysisData(AnalysisData&& other) noexcept
7274
resultUtility(other.resultUtility),
7375
scoreUtility(other.scoreUtility),
7476
winLossValue(other.winLossValue),
77+
noResultValue(other.noResultValue),
7578
policyPrior(other.policyPrior),
7679
scoreMean(other.scoreMean),
7780
scoreStdev(other.scoreStdev),
@@ -108,6 +111,7 @@ AnalysisData& AnalysisData::operator=(const AnalysisData& other) {
108111
resultUtility = other.resultUtility;
109112
scoreUtility = other.scoreUtility;
110113
winLossValue = other.winLossValue;
114+
noResultValue = other.noResultValue;
111115
policyPrior = other.policyPrior;
112116
scoreMean = other.scoreMean;
113117
scoreStdev = other.scoreStdev;
@@ -142,6 +146,7 @@ AnalysisData& AnalysisData::operator=(AnalysisData&& other) noexcept {
142146
resultUtility = other.resultUtility;
143147
scoreUtility = other.scoreUtility;
144148
winLossValue = other.winLossValue;
149+
noResultValue = other.noResultValue;
145150
policyPrior = other.policyPrior;
146151
scoreMean = other.scoreMean;
147152
scoreStdev = other.scoreStdev;

cpp/search/analysisdata.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ struct AnalysisData {
1717
double resultUtility; //Utility from winloss result
1818
double scoreUtility; //Utility from score. Summing with resultUtility gives utility.
1919
double winLossValue; //From -1 to 1
20+
double noResultValue; //From 0 to 1
2021
double policyPrior; //From 0 to 1
2122
double scoreMean; //In units of points
2223
double scoreStdev; //In units of points

cpp/search/search.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ struct Search {
407407
const Player perspective,
408408
int analysisPVLen, bool preventEncore, bool includePolicy,
409409
bool includeOwnership, bool includeOwnershipStdev, bool includeMovesOwnership, bool includeMovesOwnershipStdev, bool includePVVisits,
410+
bool includeNoResultValue,
410411
nlohmann::json& ret
411412
) const;
412413

cpp/search/searchresults.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,7 @@ AnalysisData Search::getAnalysisDataOfSingleChild(
919919
data.scoreUtility = getScoreUtility(parentScoreMean,parentScoreMean*parentScoreMean+parentScoreStdev*parentScoreStdev);
920920
data.resultUtility = fpuValue - data.scoreUtility;
921921
data.winLossValue = searchParams.winLossUtilityFactor == 1.0 ? parentWinLossValue + (fpuValue - parentUtility) : 0.0;
922+
data.noResultValue = 0.0;
922923
// Make sure winloss values due to FPU don't go out of bounds for purposes of reporting to UI
923924
if(data.winLossValue < -1.0)
924925
data.winLossValue = -1.0;
@@ -940,6 +941,7 @@ AnalysisData Search::getAnalysisDataOfSingleChild(
940941
data.resultUtility = getResultUtility(winLossValueAvg, noResultValueAvg);
941942
data.scoreUtility = getScoreUtility(scoreMeanAvg, scoreMeanSqAvg);
942943
data.winLossValue = winLossValueAvg;
944+
data.noResultValue = noResultValueAvg;
943945
data.scoreMean = scoreMeanAvg;
944946
data.scoreStdev = ScoreValue::getScoreStdev(scoreMeanAvg,scoreMeanSqAvg);
945947
data.lead = leadAvg;
@@ -1998,6 +2000,7 @@ bool Search::getAnalysisJson(
19982000
bool includeMovesOwnership,
19992001
bool includeMovesOwnershipStdev,
20002002
bool includePVVisits,
2003+
bool includeNoResultValue,
20012004
json& ret
20022005
) const {
20032006
vector<AnalysisData> buf;
@@ -2047,6 +2050,8 @@ bool Search::getAnalysisJson(
20472050
moveInfo["scoreSelfplay"] = Global::roundDynamic(scoreMean,OUTPUT_PRECISION);
20482051
moveInfo["scoreLead"] = Global::roundDynamic(lead,OUTPUT_PRECISION);
20492052
moveInfo["scoreStdev"] = Global::roundDynamic(data.scoreStdev,OUTPUT_PRECISION);
2053+
if(includeNoResultValue)
2054+
moveInfo["noResultValue"] = Global::roundDynamic(data.noResultValue,OUTPUT_PRECISION);
20502055
moveInfo["prior"] = Global::roundDynamic(data.policyPrior,OUTPUT_PRECISION);
20512056
if(humanOutput != NULL)
20522057
moveInfo["humanPrior"] = Global::roundDynamic(std::max(0.0,(double)humanOutput->policyProbs[getPos(data.move)]),OUTPUT_PRECISION);

cpp/tests/analysis/basic.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
{"id":"foo","initialStones":[],"moves":[["W","C5"],["B","C6"]],"rules":"tromp-taylor","komi":4,"boardXSize":7,"boardYSize":7,"overrideSettings":{"maxVisits":10},"includeOwnership":true,"includePolicy":true}
33
{"id":"foo","initialStones":[],"moves":[["W","C5"],["B","C6"],["W","C7"]],"rules":"tromp-taylor","komi":4,"boardXSize":7,"boardYSize":7,"overrideSettings":{"maxVisits":10},"includeOwnership":true,"includePolicy":true}
44
{"id":"foo","initialStones":[],"moves":[["W","C5"],["B","C6"],["W","C7"]],"rules":"tromp-taylor","komi":4,"boardXSize":7,"boardYSize":7,"overrideSettings":{"maxVisits":20},"includeOwnership":true,"includeOwnershipStdev":true,"includePolicy":true}
5+
{"id":"foo","initialStones":[],"moves":[["B","E5"],["W","E3"],["B","F7"],["W","C6"],["B","D4"],["W","G4"],["B","D3"],["W","D7"],["B","H5"],["W","D2"],["B","B5"],["W","F6"],["B","F5"],["W","E6"],["B","G6"],["W","G7"],["B","C2"],["W","E2"],["B","G8"],["W","H7"],["B","E8"],["W","E7"],["B","F8"],["W","H8"],["B","G5"],["W","H3"],["B","D8"],["W","C8"],["B","H9"],["W","D9"],["B","J7"],["W","G9"],["B","F9"],["W","J6"],["B","H6"],["W","J8"],["B","J5"],["W","C9"],["B","J7"],["W","C5"],["B","B4"],["W","J6"],["B","H2"],["W","J2"],["B","G2"],["W","G3"],["B","J7"],["W","B6"],["B","H1"],["W","B2"],["B","C3"],["W","C1"],["B","B1"],["W","A1"],["B","B3"],["W","F4"],["B","J3"],["W","J4"],["B","F2"],["W","F1"],["B","E4"],["W","F3"],["B","H4"],["W","J3"],["B","D1"],["W","G1"],["B","E1"],["W","F1"],["B","D1"],["W","G1"],["B","E1"],["W","F1"]],"rules":"japanese","komi":6,"boardXSize":9,"boardYSize":9,"overrideSettings":{"maxVisits":5},"includeNoResultValue":true}
56

0 commit comments

Comments
 (0)