本文整理汇总了C++中GoBoard::NumDiagonals方法的典型用法代码示例。如果您正苦于以下问题:C++ GoBoard::NumDiagonals方法的具体用法?C++ GoBoard::NumDiagonals怎么用?C++ GoBoard::NumDiagonals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GoBoard
的用法示例。
在下文中一共展示了GoBoard::NumDiagonals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsSinglePointEye
bool GoEyeUtil::IsSinglePointEye(const GoBoard& bd, SgPoint p,
SgBlackWhite color)
{
SG_ASSERT(bd.IsEmpty(p));
const SgBlackWhite opp = SgOppBW(color);
if (bd.HasEmptyNeighbors(p) || bd.HasNeighbors(p, opp))
return false;
if (bd.Line(p) == 1)
return ! (bd.HasDiagonals(p, SG_EMPTY) || bd.HasDiagonals(p, opp));
return (bd.NumDiagonals(p, SG_EMPTY) + bd.NumDiagonals(p, opp)) <= 1;
}
示例2: 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;
}