00001 //---------------------------------------------------------------------------- 00002 /** @file GoTimeControl.cpp 00003 See GoTimeControl.h. 00004 */ 00005 //---------------------------------------------------------------------------- 00006 00007 #include "SgSystem.h" 00008 #include "GoTimeControl.h" 00009 00010 #include "GoBoard.h" 00011 00012 using namespace std; 00013 00014 //---------------------------------------------------------------------------- 00015 00016 GoTimeControl::GoTimeControl(const GoBoard& bd) 00017 : m_bd(bd), 00018 m_finalSpace(0.75f) 00019 { 00020 } 00021 00022 float GoTimeControl::FinalSpace() const 00023 { 00024 return m_finalSpace; 00025 } 00026 00027 void GoTimeControl::GetPositionInfo(SgBlackWhite& toPlay, 00028 int& movesPlayed, 00029 int& estimatedRemainingMoves) 00030 { 00031 toPlay = m_bd.ToPlay(); 00032 movesPlayed = m_bd.Occupied().Size() / 2; 00033 int finalNumEmpty = 00034 static_cast<int>(m_bd.AllPoints().Size() * (1 - m_finalSpace)); 00035 estimatedRemainingMoves = max(m_bd.TotalNumEmpty() - finalNumEmpty, 0); 00036 estimatedRemainingMoves /= 2; 00037 } 00038 00039 void GoTimeControl::SetFinalSpace(float finalspace) 00040 { 00041 // Should be in [0:1] 00042 SG_ASSERT(finalspace > -0.1); 00043 SG_ASSERT(finalspace < 1.1); 00044 m_finalSpace = finalspace; 00045 } 00046 00047 //----------------------------------------------------------------------------