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


17 Jun 2010 Doxygen 1.4.7