Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GoUctPlayoutPolicy.cpp

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file GoUctPlayoutPolicy.cpp */
00003 //----------------------------------------------------------------------------
00004 
00005 #include "SgSystem.h"
00006 #include "GoUctPlayoutPolicy.h"
00007 
00008 #include <algorithm>
00009 #include <boost/io/ios_state.hpp>
00010 
00011 using namespace std;
00012 using boost::io::ios_all_saver;
00013 
00014 //----------------------------------------------------------------------------
00015 
00016 GoUctPlayoutPolicyParam::GoUctPlayoutPolicyParam()
00017     : m_statisticsEnabled(false),
00018       m_useNakadeHeuristic(false),
00019       m_fillboardTries(0)
00020 {
00021 }
00022 
00023 //----------------------------------------------------------------------------
00024 
00025 const char* GoUctPlayoutPolicyTypeStr(GoUctPlayoutPolicyType type)
00026 {
00027     BOOST_STATIC_ASSERT(_GOUCT_NU_DEFAULT_PLAYOUT_TYPE == 11);
00028     switch (type)
00029     {
00030     case GOUCT_FILLBOARD:
00031         return "Fillboard";
00032     case GOUCT_NAKADE:
00033         return "Nakade";
00034     case GOUCT_ATARI_CAPTURE:
00035         return "AtariCapture";
00036     case GOUCT_ATARI_DEFEND:
00037         return "AtariDefend";
00038     case GOUCT_LOWLIB:
00039         return "LowLib";
00040     case GOUCT_PATTERN:
00041         return "Pattern";
00042     case GOUCT_CAPTURE:
00043         return "Capture";
00044     case GOUCT_RANDOM:
00045         return "Random";
00046     case GOUCT_SELFATARI_CORRECTION:
00047         return "SelfAtariCorr";
00048     case GOUCT_CLUMP_CORRECTION:
00049         return "ClumpCorr";
00050     case GOUCT_PASS:
00051         return "Pass";
00052     default:
00053         return "?";
00054     }
00055 }
00056 
00057 //----------------------------------------------------------------------------
00058 
00059 void GoUctPlayoutPolicyStat::Clear()
00060 {
00061     m_nuMoves = 0;
00062     m_nonRandLen.Clear();
00063     m_moveListLen.Clear();
00064     fill(m_nuMoveType.begin(), m_nuMoveType.end(), 0);
00065 }
00066 
00067 void GoUctPlayoutPolicyStat::Write(std::ostream& out) const
00068 {
00069     ios_all_saver saver(out);
00070     out << fixed << setprecision(2)
00071         << SgWriteLabel("NuMoves") << m_nuMoves << '\n';
00072     for (int i = 0; i < _GOUCT_NU_DEFAULT_PLAYOUT_TYPE; ++i)
00073     {
00074         GoUctPlayoutPolicyType type = static_cast<GoUctPlayoutPolicyType>(i);
00075         size_t n = m_nuMoveType[type];
00076         out << SgWriteLabel(GoUctPlayoutPolicyTypeStr(type))
00077             << (m_nuMoves > 0 ? n * 100 / m_nuMoves : 0) << "%\n";
00078     }
00079     out << SgWriteLabel("NonRandLen");
00080     m_nonRandLen.Write(out);
00081     out << '\n'
00082         << SgWriteLabel("MoveListLen");
00083     m_moveListLen.Write(out);
00084     out << '\n';
00085 }
00086 
00087 //----------------------------------------------------------------------------


Sun Mar 13 2011 Doxygen 1.7.1