00001 //---------------------------------------------------------------------------- 00002 /** @file SpMoveGenerator.cpp 00003 See SpMoveGenerator.h */ 00004 //---------------------------------------------------------------------------- 00005 00006 #include "SgSystem.h" 00007 #include "SpMoveGenerator.h" 00008 00009 #include <limits> 00010 #include "GoMoveExecutor.h" 00011 #include "GoModBoard.h" 00012 #include "SgEvaluatedMoves.h" 00013 00014 using namespace std; 00015 00016 //---------------------------------------------------------------------------- 00017 00018 void SpMoveGenerator::GenerateMoves(SgEvaluatedMoves& eval, 00019 SgBlackWhite toPlay) 00020 { 00021 GoModBoard modBoard(m_board); 00022 GoBoard& bd = modBoard.Board(); 00023 GoRestoreToPlay restoreToPlay(bd); 00024 bd.SetToPlay(toPlay); 00025 GoRestoreSuicide restoreSuicide(bd, false); 00026 for (SgSetIterator it(eval.Relevant()); it; ++it) 00027 { 00028 SgPoint p(*it); 00029 int score = EvaluateMove(p); 00030 if (score > numeric_limits<int>::min()) 00031 eval.AddMove(p, score); 00032 } 00033 } 00034 00035 int Sp1PlyMoveGenerator::EvaluateMove(SgPoint p) 00036 { 00037 GoModBoard modBoard(m_board); 00038 GoBoard& bd = modBoard.Board(); 00039 GoMoveExecutor execute(bd, p); 00040 if (execute.IsLegal()) 00041 return Evaluate(); 00042 else 00043 return numeric_limits<int>::min(); 00044 } 00045 00046 int SpStaticMoveGenerator::EvaluateMove(SgPoint p) 00047 { 00048 if (m_board.IsLegal(p)) 00049 return Score(p); 00050 else 00051 return numeric_limits<int>::min(); 00052 } 00053 00054 00055 //---------------------------------------------------------------------------- 00056