diff --git a/gouct/GoUctCommands.cpp b/gouct/GoUctCommands.cpp index 49a59b43..0a4c4fb8 100644 --- a/gouct/GoUctCommands.cpp +++ b/gouct/GoUctCommands.cpp @@ -324,6 +324,7 @@ void GoUctCommands::AddGoGuiAnalyzeCommands(GtpCommand& cmd) "plist/Uct Patterns/uct_patterns\n" "pstring/Uct Policy Corrected Moves/uct_policy_corrected_moves\n" "pstring/Uct Policy Moves/uct_policy_moves\n" + "pstring/Uct Policy Moves Simple List/uct_policy_moves_simple\n" "gfx/Uct Prior Knowledge/uct_prior_knowledge\n" "sboard/Uct Rave Values/uct_rave_values\n" "plist/Uct Root Filter/uct_root_filter\n" @@ -1093,7 +1094,7 @@ void GoUctCommands::CmdPolicyCorrectedMoves(GtpCommand& cmd) See GoUctPlayoutPolicy::GetEquivalentBestMoves()
Arguments: none
Returns: Move type string followed by move list on a single line. */ -void GoUctCommands::CmdPolicyMoves(GtpCommand& cmd) +void GoUctCommands::WritePolicyMoves(GtpCommand& cmd, bool writeGammas) { cmd.CheckArgNone(); GoUctPlayoutPolicy policy(m_bd, Player().m_playoutPolicyParam); @@ -1111,10 +1112,30 @@ void GoUctCommands::CmdPolicyMoves(GtpCommand& cmd) if (policy.MoveType() == GOUCT_GAMMA_PATTERN) { cmd << ' '; - policy.GammaGenerator().WriteMovesAndGammas(cmd); + policy.GammaGenerator().WriteMovesAndGammas(cmd, writeGammas); } } +/** Return equivalent best moves in playout policy. + See GoUctPlayoutPolicy::GetEquivalentBestMoves()
+ Arguments: none
+ Returns: Move type string followed by move list on a single line. + For non-uniform generators, also write selection weights (gammas) +*/ +void GoUctCommands::CmdPolicyMoves(GtpCommand& cmd) +{ + WritePolicyMoves(cmd, true); // do write move weights (gammas) +} + +/** Return equivalent best moves in playout policy. + See GoUctPlayoutPolicy::GetEquivalentBestMoves()
+ Arguments: none
+ Returns: Move type string followed by move list on a single line. */ +void GoUctCommands::CmdPolicyMovesSimple(GtpCommand& cmd) +{ + WritePolicyMoves(cmd, false); // don't write move weights (gammas) +} + /** Show total prior knowledge */ void GoUctCommands::CmdPriorKnowledge(GtpCommand& cmd) { @@ -1652,6 +1673,8 @@ void GoUctCommands::Register(GtpEngine& e) Register(e, "uct_policy_corrected_moves", &GoUctCommands::CmdPolicyCorrectedMoves); Register(e, "uct_policy_moves", &GoUctCommands::CmdPolicyMoves); + Register(e, "uct_policy_moves_simple", + &GoUctCommands::CmdPolicyMovesSimple); Register(e, "uct_prior_knowledge", &GoUctCommands::CmdPriorKnowledge); Register(e, "uct_rave_values", &GoUctCommands::CmdRaveValues); Register(e, "uct_root_filter", &GoUctCommands::CmdRootFilter); diff --git a/gouct/GoUctCommands.h b/gouct/GoUctCommands.h index 4e77797b..fa7b5aad 100644 --- a/gouct/GoUctCommands.h +++ b/gouct/GoUctCommands.h @@ -75,6 +75,7 @@ class GoUctCommands - @link CmdPolicyCorrectedMoves() @c uct_policy_corrected_moves @endlink - @link CmdPolicyMoves() @c uct_policy_moves @endlink + - @link CmdPolicyMovesSimple() @c uct_policy_moves_simple @endlink - @link CmdPriorKnowledge() @c uct_prior_knowledge @endlink - @link CmdRaveValues() @c uct_rave_values @endlink - @link CmdRootFilter() @c uct_root_filter @endlink @@ -118,6 +119,7 @@ class GoUctCommands void CmdPatterns(GtpCommand& cmd); void CmdPolicyCorrectedMoves(GtpCommand& cmd); void CmdPolicyMoves(GtpCommand& cmd); + void CmdPolicyMovesSimple(GtpCommand& cmd); void CmdPriorKnowledge(GtpCommand& cmd); void CmdRaveValues(GtpCommand& cmd); void CmdRootFilter(GtpCommand& cmd); @@ -187,6 +189,8 @@ class GoUctCommands GoUctGlobalSearchState >& ThreadState(unsigned int threadId); + + void WritePolicyMoves(GtpCommand& cmd, bool writeGammas); }; //---------------------------------------------------------------------------- diff --git a/gouct/GoUctGammaMoveGenerator.h b/gouct/GoUctGammaMoveGenerator.h index 2d63cb2c..d6b126f9 100644 --- a/gouct/GoUctGammaMoveGenerator.h +++ b/gouct/GoUctGammaMoveGenerator.h @@ -29,7 +29,7 @@ class GoUctGammaMoveGenerator int NuMoves() const; - void WriteMovesAndGammas(std::ostream& stream) const; + void WriteMovesAndGammas(std::ostream& stream, bool writeGammas) const; private: /** Generate pattern moves with gamma values */ @@ -222,12 +222,15 @@ std::ostream& operator<<(std::ostream& stream, template void GoUctGammaMoveGenerator:: - WriteMovesAndGammas(std::ostream& stream) const + WriteMovesAndGammas(std::ostream& stream, bool writeGammas) const { for (int i = 0; i < NuMoves(); ++i) { - stream << SgWritePoint(GetGammaMoveAt(i)) << ":" - << GetGammaValueForMoveAt(i) << " "; + stream << SgWritePoint(GetGammaMoveAt(i)); + if (writeGammas) + stream << ":" + << GetGammaValueForMoveAt(i); + stream << ' '; } stream << std::endl; } diff --git a/regression/Makefile.am b/regression/Makefile.am index 3db1001f..14a2bc5a 100644 --- a/regression/Makefile.am +++ b/regression/Makefile.am @@ -397,7 +397,11 @@ sgf/playout/playout_atari_defense_1.sgf \ sgf/playout/playout_atari_defense_2.sgf \ sgf/playout/playout_atari_defense_3.sgf \ sgf/playout/playout_capture_1.sgf \ +sgf/playout/playout_capture_no_selfatari.1.sgf \ +sgf/playout/playout_capture_no_selfatari.2.sgf \ sgf/playout/playout_nakade.1.sgf \ +sgf/playout/playout_nakade.2.sgf \ +sgf/playout/playout_nakade.3.sgf \ sgf/playout/playout_nakade_approach.sgf \ sgf/playout/playout_two_liberties_semeai.1.sgf \ sgf/playout/playout_two_liberties_semeai.2.sgf \ diff --git a/regression/playout_atari_capture.tst b/regression/playout_atari_capture.tst index 63281ea9..15329a3a 100644 --- a/regression/playout_atari_capture.tst +++ b/regression/playout_atari_capture.tst @@ -47,3 +47,23 @@ loadsgf sgf/playout/playout_two_liberties_semeai.3.sgf 4 201 uct_policy_moves #? [AtariCapture J7]* # current policy captures F4... + +#----------------------------------------------------------------------------- +# Good capture vs. Selfatari capture + +loadsgf sgf/playout/playout_capture_no_selfatari.1.sgf +210 reg_genmove w +#? [H2] + +211 uct_policy_moves +#? [AtariCapture H2]* +# current policy captures J8, selfatari + +loadsgf sgf/playout/playout_capture_no_selfatari.2.sgf +220 reg_genmove w +#? [H2]* + +221 uct_policy_moves +#? [AtariCapture H2]* +# current policy captures J8, selfatari + diff --git a/regression/playout_nakade.tst b/regression/playout_nakade.tst index 3d3d8936..b364a11a 100644 --- a/regression/playout_nakade.tst +++ b/regression/playout_nakade.tst @@ -29,6 +29,14 @@ loadsgf sgf/playout/playout_nakade.1.sgf 7 #? [J8] # must kill on vital point. -31 uct_policy_moves -#? [Pattern J8] -# Should be different move reason in future ??? \ No newline at end of file +31 uct_policy_moves_simple +#? [GammaPattern J8] +# Should be different move reason in future ??? + +loadsgf sgf/playout/playout_nakade.2.sgf +40 uct_policy_moves +#? [GammaPattern E1:1 F1:550.309] +# F1 is much more likely, but E1 would be fatal... + +41 uct_policy_moves_simple +#? [GammaPattern F1]* \ No newline at end of file diff --git a/regression/sgf/playout/playout_capture_no_selfatari.1.sgf b/regression/sgf/playout/playout_capture_no_selfatari.1.sgf new file mode 100644 index 00000000..0e0a0501 --- /dev/null +++ b/regression/sgf/playout/playout_capture_no_selfatari.1.sgf @@ -0,0 +1,5 @@ +(;FF[4]CA[UTF-8]AP[GoGui:1.4.9]SZ[9] +KM[0.5]DT[2014-12-16] +AB[ae][bf][be][ce][cd][cc][df][de][ee][ed][ec][eb][ff][fd][fb][fa][gi][gh][gf][gd][hi][hg][hf][hb][ii][ih] +AW[ag][af][bg][ch][cg][cf][dg][eg][ef][fi][fh][fg][fe][fc][gg][ge][gc][gb][ga][he][hd][hc][ha][ig][if][ie][id][ic][ia] +PL[W]) diff --git a/regression/sgf/playout/playout_capture_no_selfatari.2.sgf b/regression/sgf/playout/playout_capture_no_selfatari.2.sgf new file mode 100644 index 00000000..3ff1c91c --- /dev/null +++ b/regression/sgf/playout/playout_capture_no_selfatari.2.sgf @@ -0,0 +1,5 @@ +(;FF[4]CA[UTF-8]AP[GoGui:1.4.9]SZ[9] +KM[0.5]DT[2014-12-16] +AB[ae][bf][be][ce][cd][cc][df][de][ee][ed][ec][eb][ff][fd][fb][fa][gi][gh][gf][gd][hi][hg][hf][ii][ih] +AW[ag][af][bg][ch][cg][cf][dg][eg][ef][fi][fh][fg][fe][fc][gg][ge][gc][gb][ga][he][hd][hc][ha][ig][if][ie][id][ic][ia] +PL[B];B[hb]) diff --git a/regression/sgf/playout/playout_nakade.2.sgf b/regression/sgf/playout/playout_nakade.2.sgf new file mode 100644 index 00000000..ec34a943 --- /dev/null +++ b/regression/sgf/playout/playout_nakade.2.sgf @@ -0,0 +1,3 @@ +(;FF[4]CA[UTF-8]AP[GoGui:1.4.9]SZ[9] +KM[7.5]DT[2014-12-16] +AB[di][dh][eh][eg][ef][ff][gf][gg][gh][gi]PL[W];W[fh]) diff --git a/regression/sgf/playout/playout_nakade.3.sgf b/regression/sgf/playout/playout_nakade.3.sgf new file mode 100644 index 00000000..6a503f39 --- /dev/null +++ b/regression/sgf/playout/playout_nakade.3.sgf @@ -0,0 +1,3 @@ +(;FF[4]CA[UTF-8]AP[GoGui:1.4.9]SZ[9] +KM[7.5]DT[2014-12-16] +AB[di][dh][eh][eg][ef][ff][gf][gg][gh][gi]PL[W];W[fi])