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


17 Jun 2010 Doxygen 1.4.7