Go to the documentation of this file.00001
00002
00003
00004
00005 #include "SgSystem.h"
00006 #include "SpMaxEyePlayer.h"
00007
00008 #include "GoEyeUtil.h"
00009
00010
00011
00012 using namespace std;
00013
00014
00015
00016 float SpMaxEyeMoveGenerator::Heuristic(SgPoint p, SgBlackWhite colour)
00017 {
00018
00019 int nummoves;
00020 bool eyepossible =
00021 GoEyeUtil::NumberOfMoveToEye2(m_board, colour, p, nummoves);
00022
00023
00024 if (! eyepossible)
00025 return 0.0f;
00026
00027
00028 if (colour == m_board.Opponent())
00029 return 1.0f / (static_cast<float>(nummoves) + 1.0f);
00030
00031
00032 else
00033 return 1.0f / (static_cast<float>(nummoves) + 0.5f);
00034 }
00035
00036 int SpMaxEyeMoveGenerator::Evaluate()
00037 {
00038
00039 SgBlackWhite player = m_board.Opponent();
00040 SgBlackWhite opponent = m_board.ToPlay();
00041
00042 float sign = 0;
00043 float maxeyescore = -1;
00044 float totaleyescore = 0;
00045
00046 for (GoBoard::Iterator iBoard(m_board); iBoard; ++iBoard)
00047 {
00048 float playerscore = Heuristic(*iBoard, player);
00049 float oppscore = Heuristic(*iBoard, opponent);
00050
00051 totaleyescore += playerscore - oppscore;
00052
00053 if (playerscore > maxeyescore)
00054 {
00055 maxeyescore = playerscore;
00056 sign = 1;
00057 }
00058
00059 if (oppscore > maxeyescore)
00060 {
00061 maxeyescore = oppscore;
00062 sign = -1;
00063 }
00064 }
00065
00066
00067
00068 if (m_eyeGo)
00069 return static_cast<int>(
00070 maxeyescore * sign * 10000.0f + totaleyescore * 100.0f);
00071
00072
00073 else
00074 return static_cast<int>(
00075 totaleyescore * 100.0f);
00076 }
00077
00078
00079