Beispiel #1
0
void GoInfluence::FindInfluence(const GoBoard& board,
                    int nuExpand,
                    int nuShrink,
                    SgBWSet* influence)
{   
    SgBWSet result = SgBWSet(board.All(SG_BLACK), board.All(SG_WHITE));
    SgBWSet next;
    const int size = board.Size();
    for (int i = 1; i <= nuExpand; ++i)
    {
        for (SgBlackWhite c = SG_BLACK; c <= SG_WHITE; ++c)
        {
            SgBlackWhite opp = SgOppBW(c);
            next[c] = result[c].Border(size) - result[opp];
        }
        result[SG_BLACK] |= (next[SG_BLACK] - next[SG_WHITE]);
        result[SG_WHITE] |= (next[SG_WHITE] - next[SG_BLACK]);
    }

    for (int i = 1; i <= nuShrink; ++i)
    {
        result[SG_BLACK] = result[SG_BLACK].Kernel(size);
        result[SG_WHITE] = result[SG_WHITE].Kernel(size);
    }
    
    *influence = result;
}
int LibertyAveragex10(const GoBoard& board, SgBlackWhite color)
{
    int nuLibs = 0, nuBlocks = 0;
    const int size = board.Size();
    for (SgConnCompIterator it(board.All(color), board.Size()); it; ++it)
    {
        ++nuBlocks;
        nuLibs += ((*it).Border(size) & board.AllEmpty()).Size();
    }
    return (nuBlocks == 0) ? 0 : 10 * nuLibs / nuBlocks;
}