00001 //---------------------------------------------------------------------------- 00002 /** @file SgSearchStatistics.h 00003 Search statistics 00004 */ 00005 //---------------------------------------------------------------------------- 00006 00007 #ifndef SG_SEARCHSTATISTICS_H 00008 #define SG_SEARCHSTATISTICS_H 00009 00010 #include <iosfwd> 00011 00012 //---------------------------------------------------------------------------- 00013 00014 /** Statistics used in class SgSearch */ 00015 class SgSearchStatistics 00016 { 00017 public: 00018 SgSearchStatistics(); 00019 00020 SgSearchStatistics(const SgSearchStatistics& stat); 00021 00022 virtual ~SgSearchStatistics(); 00023 00024 SgSearchStatistics& operator=(const SgSearchStatistics& rhs); 00025 00026 SgSearchStatistics& operator+=(const SgSearchStatistics& rhs); 00027 00028 /** Set the number of nodes and leafs searched to zero. */ 00029 void Clear(); 00030 00031 int DepthReached() const; 00032 00033 virtual SgSearchStatistics* Duplicate() const; 00034 00035 void IncNumEvals(); 00036 00037 void IncNumMoves(); 00038 00039 void IncNumNodes(); 00040 00041 void IncNumPassMoves(); 00042 00043 int NumEvals() const; 00044 00045 int NumMoves() const; 00046 00047 int NumNodes() const; 00048 00049 double NumEvalsPerSecond() const; 00050 00051 double NumNodesPerSecond() const; 00052 00053 int NumPassMoves() const; 00054 00055 void SetDepthReached(int depthReached); 00056 00057 /** Set the time used to the given value. 00058 Only needed because doesn't keep track of real time used, and some 00059 searches might want to report the real time rather than the thread 00060 time. 00061 */ 00062 void SetTimeUsed(double timeUsed); 00063 00064 double TimeUsed() const; 00065 00066 private: 00067 int m_numNodes; 00068 00069 int m_numEvals; 00070 00071 int m_numMoves; 00072 00073 int m_numPass; 00074 00075 int m_depthReached; 00076 00077 double m_timeUsed; 00078 }; 00079 00080 std::ostream& operator<<(std::ostream& stream, 00081 const SgSearchStatistics &w); 00082 00083 inline int SgSearchStatistics::DepthReached() const 00084 { 00085 return m_depthReached; 00086 } 00087 00088 inline void SgSearchStatistics::IncNumEvals() 00089 { 00090 ++m_numEvals; 00091 } 00092 00093 inline void SgSearchStatistics::IncNumMoves() 00094 { 00095 ++m_numMoves; 00096 } 00097 00098 inline void SgSearchStatistics::IncNumNodes() 00099 { 00100 ++m_numNodes; 00101 } 00102 00103 inline void SgSearchStatistics::IncNumPassMoves() 00104 { 00105 ++m_numPass; 00106 } 00107 00108 inline int SgSearchStatistics::NumEvals() const 00109 { 00110 return m_numEvals; 00111 } 00112 00113 inline int SgSearchStatistics::NumMoves() const 00114 { 00115 return m_numMoves; 00116 } 00117 00118 inline int SgSearchStatistics::NumNodes() const 00119 { 00120 return m_numNodes; 00121 } 00122 00123 inline int SgSearchStatistics::NumPassMoves() const 00124 { 00125 return m_numPass; 00126 } 00127 00128 inline void SgSearchStatistics::SetDepthReached(int depthReached) 00129 { 00130 m_depthReached = depthReached; 00131 } 00132 00133 inline void SgSearchStatistics::SetTimeUsed(double timeUsed) 00134 { 00135 m_timeUsed = timeUsed; 00136 } 00137 00138 inline double SgSearchStatistics::TimeUsed() const 00139 { 00140 return m_timeUsed; 00141 } 00142 00143 //---------------------------------------------------------------------------- 00144 00145 #endif // SG_SEARCHSTATISTICS_H