Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GoTimeControl.cpp

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


Sun Mar 13 2011 Doxygen 1.7.1