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 
00007 #include "SgSystem.h"
00008 #include "SpAveragePlayer.h"
00009 
00010 #include "SgConnCompIterator.h"
00011 
00012 //----------------------------------------------------------------------------
00013 
00014 int LibertyAveragex10(const GoBoard& board, SgBlackWhite color)
00015 {
00016     int nuLibs = 0, nuBlocks = 0;
00017     const int size = board.Size();
00018     for (SgConnCompIterator it(board.All(color), board.Size()); it; ++it)
00019     {
00020         ++nuBlocks;
00021         nuLibs += ((*it).Border(size) & board.AllEmpty()).Size();
00022     }
00023     return (nuBlocks == 0) ? 0 : 10 * nuLibs / nuBlocks;
00024 }
00025 //----------------------------------------------------------------------------
00026 
00027 int SpAverageMoveGenerator::Evaluate()
00028 {
00029     // We are Opponent since this is after executing our move
00030     SgBlackWhite player = m_board.Opponent();
00031     int score = LibertyAveragex10(m_board, player)
00032               - LibertyAveragex10(m_board, SgOppBW(player));
00033         
00034     return score;
00035 }
00036 


17 Jun 2010 Doxygen 1.4.7