当前位置: 首页>>代码示例>>C++>>正文


C++ GoBoard::NumNeighbors方法代码示例

本文整理汇总了C++中GoBoard::NumNeighbors方法的典型用法代码示例。如果您正苦于以下问题:C++ GoBoard::NumNeighbors方法的具体用法?C++ GoBoard::NumNeighbors怎么用?C++ GoBoard::NumNeighbors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GoBoard的用法示例。


在下文中一共展示了GoBoard::NumNeighbors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: NumberOfMoveToEye

bool GoEyeUtil::NumberOfMoveToEye(const GoBoard& board, SgBlackWhite color,
                                  SgPoint p, int& number)
{
    SG_ASSERT(board.IsEmpty(p));
    SgBlackWhite att = SgOppBW(color);  // attacker

    if ( board.Line(p) == 1) // corner or edge
    {
        if ( board.Num8Neighbors(p, att) > 0 )
            return false;
        else
        {
            number = board.Num8EmptyNeighbors(p);
            return true;
        }
    }
    else // in center
    {
        if ( board.Num8Neighbors(p, att) >= 2 )
            return false;
        else if ( board.NumNeighbors(p, att) > 0 )
            return false;
        else // only 0 or 1 attacker point and not in NB4
        {
            number = board.Num8EmptyNeighbors(p);
            return true;
        }
    }
    
}
开发者ID:Nopik,项目名称:dragongoclient,代码行数:30,代码来源:GoEyeUtil.cpp

示例2: IsVitalPt

bool GoEyeUtil::IsVitalPt(const SgPointSet& points, SgPoint p,
                SgBlackWhite opp,
                const GoBoard& bd)
{
    // in corridors a vital point has 2 nbs, in big ones it may have 3 or 4.
    // but: 2 in following
    // example: unsettled nakade, non-flat points are all occupied by opp.
    // .a       a is vital Point.
    //  o.
    //  .
    int numNb = bd.NumEmptyNeighbors(p) + bd.NumNeighbors(p, opp);
    if (numNb >= 2)
    {
        if (numNb >= 4)
            /* */ return true; /* */
        int nu = IsTreeShape(points) ? 2 : 3;
        if (numNb >= nu)
        {
            if (numNb == 2 && bd.IsEmpty(p))
                return IsSplitPt(p, points);
            else
                return true;
        }
    }
    return false;
}
开发者ID:Nopik,项目名称:dragongoclient,代码行数:26,代码来源:GoEyeUtil.cpp

示例3: IsPossibleEye

bool GoEyeUtil::IsPossibleEye(const GoBoard& board, SgBlackWhite color,
                              SgPoint p)
{
    bool isPossibleEye = false;
    SG_ASSERT(board.GetColor(p) != color);
    const SgBlackWhite opp = SgOppBW(color);
    if (board.Line(p) == 1) // corner or edge
    {
        const int nuOwn = (board.Pos(p) == 1) ? 2 : 4;
        if ( board.Num8Neighbors(p, color) == nuOwn
             && board.Num8EmptyNeighbors(p) == 1
           )
        {     
            isPossibleEye = true;
        }
    }
    else // in center
    {
        // have all neighbors, and 2 diagonals, and can get a third
        if (    board.NumNeighbors(p, color) == 4
             && board.NumDiagonals(p, color) == 2
             && board.NumEmptyDiagonals(p) > 0
           )
        {     
            isPossibleEye = true;
        }
        // have 3 of 4 neighbors, can get the 4th, and have enough diagonals
        else if (   board.NumNeighbors(p, color) == 3
                 && board.NumNeighbors(p, opp) == 0
                 && board.NumDiagonals(p, color) >= 3 
                )
        {
            isPossibleEye = true;
        }
    }
    
    return isPossibleEye;
}
开发者ID:Nopik,项目名称:dragongoclient,代码行数:38,代码来源:GoEyeUtil.cpp


注:本文中的GoBoard::NumNeighbors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。