Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SpAveragePlayer.cpp

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file SpAveragePlayer.cpp
00003     See SpAveragePlayer.h */
00004 //----------------------------------------------------------------------------
00005 
00006 #include "SgSystem.h"
00007 #include "SpAveragePlayer.h"
00008 
00009 #include "SgConnCompIterator.h"
00010 
00011 //----------------------------------------------------------------------------
00012 
00013 int LibertyAveragex10(const GoBoard& board, SgBlackWhite color)
00014 {
00015     int nuLibs = 0, nuBlocks = 0;
00016     const int size = board.Size();
00017     for (SgConnCompIterator it(board.All(color), board.Size()); it; ++it)
00018     {
00019         ++nuBlocks;
00020         nuLibs += ((*it).Border(size) & board.AllEmpty()).Size();
00021     }
00022     return (nuBlocks == 0) ? 0 : 10 * nuLibs / nuBlocks;
00023 }
00024 //----------------------------------------------------------------------------
00025 
00026 int SpAverageMoveGenerator::Evaluate()
00027 {
00028     // We are Opponent since this is after executing our move
00029     SgBlackWhite player = m_board.Opponent();
00030     int score = LibertyAveragex10(m_board, player)
00031               - LibertyAveragex10(m_board, SgOppBW(player));
00032         
00033     return score;
00034 }
00035 


Sun Mar 13 2011 Doxygen 1.7.1