Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GoSearch.cpp

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file GoSearch.cpp */
00003 //----------------------------------------------------------------------------
00004 
00005 #include "SgSystem.h"
00006 #include "GoSearch.h"
00007 
00008 #include <sstream>
00009 #include "GoBoard.h"
00010 #include "GoBoardUtil.h"
00011 #include "SgNode.h"
00012 #include "SgPoint.h"
00013 #include "SgWrite.h"
00014 
00015 using namespace std;
00016 
00017 //----------------------------------------------------------------------------
00018 
00019 GoSearch::GoSearch(GoBoard& board, SgSearchHashTable* hash)
00020     : SgSearch(hash),
00021       m_board(board)
00022 {
00023     SetOpponentBest(true);
00024 }
00025 
00026 bool GoSearch::CheckDepthLimitReached() const
00027 {
00028     return false;
00029 }
00030 
00031 bool GoSearch::EndOfGame() const
00032 {
00033     return PrevMove() == SG_PASS && PrevMove2() == SG_PASS;
00034 }
00035 
00036 bool GoSearch::Execute(SgMove move, int* delta, int depth)
00037 {
00038     SG_UNUSED(delta);
00039     SG_UNUSED(depth);
00040     GoBoard& bd = Board();
00041     SgBlackWhite toPlay = bd.ToPlay();
00042     if (! GoBoardUtil::PlayIfLegal(bd, move, toPlay))
00043         return false;
00044     return true;
00045 }
00046 
00047 SgHashCode GoSearch::GetHashCode() const
00048 {
00049     return Board().GetHashCodeInclToPlay();
00050 }
00051 
00052 SgBlackWhite GoSearch::GetToPlay() const
00053 {
00054     return Board().ToPlay();
00055 }
00056 
00057 std::string GoSearch::MoveString(SgMove move) const
00058 {
00059     ostringstream buffer;
00060     buffer << SgWritePoint(move);
00061     return buffer.str();
00062 }
00063 
00064 void GoSearch::SetToPlay(SgBlackWhite toPlay)
00065 {
00066     Board().SetToPlay(toPlay);
00067 }
00068 
00069 void GoSearch::TakeBack()
00070 {
00071     Board().Undo();
00072 }
00073 
00074 //----------------------------------------------------------------------------
00075 


Sun Mar 13 2011 Doxygen 1.7.1