Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SpMoveGenerator.cpp

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


17 Jun 2010 Doxygen 1.4.7