Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat add total visits #905

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cpp/command/gtp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,12 @@ struct GTPEngine {
}

const Board board = search->getRootBoard();

int totalVisits = 0;
for(int i = 0; i<buf.size(); i++) {
totalVisits += buf[i].numVisits;
}

for(int i = 0; i<buf.size(); i++) {
if(i > 0)
out << " ";
Expand All @@ -849,6 +855,7 @@ struct GTPEngine {
out << "info";
out << " move " << Location::toString(data.move,board);
out << " visits " << data.numVisits;
out << " totalVisits " << totalVisits;
out << " utility " << utility;
out << " winrate " << winrate;
// We report lead for scoreMean here so that a bunch of legacy tools that use KataGo use lead instead, which
Expand Down
3 changes: 2 additions & 1 deletion docs/GTP_Extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ In addition to a basic set of [GTP commands](https://www.lysator.liu.se/~gunnar/
* `pvVisits true` - Output the number of visits spent in the position after each move in each principal variation.
* `pvEdgeVisits true` - Output the number of visits spent following each move in each principal variation.
* Output format:
* Outputted lines look like `info move E4 visits 487 utility -0.0408357 winrate 0.480018 scoreMean -0.611848 scoreStdev 24.7058 scoreLead -0.611848 scoreSelfplay -0.515178 prior 0.221121 lcb 0.477221 utilityLcb -0.0486664 order 0 pv E4 E3 F3 D3 F4 P4 P3 O3 Q3 O4 K3 Q6 S6 E16 E17 info move P16 visits 470 utility -0.0414945 winrate 0.479712 scoreMean -0.63075 scoreStdev 24.7179 scoreLead -0.63075 scoreSelfplay -0.5221 prior 0.220566 lcb 0.47657 utilityLcb -0.0502929 order 1 pv P16 P17 O17 Q17 O16 E17 H17 D15 C15 D14 C13 D13 C12 D12 info move E16 visits 143 utility -0.0534071 winrate 0.474509 scoreMean -0.729858 scoreStdev 24.7991 scoreLead -0.729858 scoreSelfplay -0.735747 prior 0.104652 lcb 0.470674 utilityLcb -0.0641425 order 2 pv E16 P4 P3 O3 Q3 O4 E3 H3 D5 C5`
* Outputted lines look like `info move E4 visits 487 totalVisits 1024 utility -0.0408357 winrate 0.480018 scoreMean -0.611848 scoreStdev 24.7058 scoreLead -0.611848 scoreSelfplay -0.515178 prior 0.221121 lcb 0.477221 utilityLcb -0.0486664 order 0 pv E4 E3 F3 D3 F4 P4 P3 O3 Q3 O4 K3 Q6 S6 E16 E17 info move P16 visits 470 utility -0.0414945 winrate 0.479712 scoreMean -0.63075 scoreStdev 24.7179 scoreLead -0.63075 scoreSelfplay -0.5221 prior 0.220566 lcb 0.47657 utilityLcb -0.0502929 order 1 pv P16 P17 O17 Q17 O16 E17 H17 D15 C15 D14 C13 D13 C12 D12 info move E16 visits 143 utility -0.0534071 winrate 0.474509 scoreMean -0.729858 scoreStdev 24.7991 scoreLead -0.729858 scoreSelfplay -0.735747 prior 0.104652 lcb 0.470674 utilityLcb -0.0641425 order 2 pv E16 P4 P3 O3 Q3 O4 E3 H3 D5 C5`
* `info` - Indicates the start of information for a new possible move, followed by key-value pairs. Current key-value pairs:
* **NOTE: Consumers of this data should attempt to be robust to the order of these fields, as well as to possible addition of new fields in the future.**
* `move` - The move being analyzed.
* `visits` - The number of visits invested into the move so far.
* `totalVisits` - The number of total visits of all the moves so far. The `totalVisits` sums up all the `visits` value of all the moves in the current output.
* `winrate` - The winrate of the move so far, as a float in [0,1].
* `scoreMean` - Same as scoreLead. "Mean" is a slight misnomer, but this field exists to preserve compatibility with existing tools.
* `scoreStdev` - The predicted standard deviation of the final score of the game after this move, in points. (NOTE: due to the mechanics of MCTS, this value will be **significantly biased high** currently, although it can still be informative as a *relative* indicator).
Expand Down