Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgUctTreeUtil.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file SgUctTreeUtil.h
00003     Utility functions for users of SgUctSearch.h
00004 */
00005 //----------------------------------------------------------------------------
00006 
00007 #ifndef SG_UCTTREEUTIL_H
00008 #define SG_UCTTREEUTIL_H
00009 
00010 #include <cstddef>
00011 #include <iosfwd>
00012 #include "SgStatistics.h"
00013 
00014 class SgUctNode;
00015 class SgUctTree;
00016 
00017 //----------------------------------------------------------------------------
00018 
00019 /** Statistical properties of a SgUctTree.
00020     @ingroup sguctgroup
00021 */
00022 class SgUctTreeStatistics
00023 {
00024 public:
00025     /** See m_posCounts */
00026     static const std::size_t MAX_MOVECOUNT = 5;
00027 
00028     std::size_t m_nuNodes;
00029 
00030     /** Number of nodes that have a certain move count. */
00031     std::size_t m_moveCounts[MAX_MOVECOUNT];
00032 
00033     /** Difference between move value and RAVE value. */
00034     SgStatisticsExt<float,std::size_t> m_biasRave;
00035 
00036     SgUctTreeStatistics();
00037 
00038     void Clear();
00039 
00040     /** Clear statistics and traverse tree to compute statistics. */
00041     void Compute(const SgUctTree& tree);
00042 
00043     void Write(std::ostream& out) const;
00044 };
00045 
00046 /** Write a SgUctTreeStatistics.
00047     @relatesalso SgUctTreeStatistics
00048 */
00049 std::ostream& operator<<(std::ostream& out, const SgUctTreeStatistics& stat);
00050 
00051 //----------------------------------------------------------------------------
00052 
00053 /** Utility functions for users of SgUctTree.
00054     @ingroup sguctgroup
00055 */
00056 namespace SgUctTreeUtil
00057 {
00058     /** Extract the subtree from the node after a sequence of moves.
00059         The result is an empty tree, if the sequence of moves does
00060         not correspond to a sequence of nodes from the root node in the
00061         given tree.
00062         @param tree The source tree.
00063         @param[out] target The target tree (will be cleared before using it).
00064         @param sequence The sequence of moves.
00065         @param warnTruncate See SgUctTree::ExtractSubtree
00066         @param maxTime See SgUctTree::ExtractSubtree
00067     */
00068     void ExtractSubtree(const SgUctTree& tree, SgUctTree& target,
00069                         const std::vector<SgMove>& sequence,
00070                         bool warnTruncate,
00071                         double maxTime = std::numeric_limits<double>::max());
00072 
00073     /** Find move node with a given move.
00074         @return The child node or 0, if the position node has no such child.
00075     */
00076     const SgUctNode* FindChildWithMove(const SgUctTree& tree,
00077                                        const SgUctNode& node, SgMove move);
00078 
00079 } // namespace SgUctTreeUtil
00080 
00081 //----------------------------------------------------------------------------
00082 
00083 #endif // SG_UCTTREEUTIL_H


17 Jun 2010 Doxygen 1.4.7