本文整理汇总了C++中GoBoard::IsColor方法的典型用法代码示例。如果您正苦于以下问题:C++ GoBoard::IsColor方法的具体用法?C++ GoBoard::IsColor怎么用?C++ GoBoard::IsColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GoBoard
的用法示例。
在下文中一共展示了GoBoard::IsColor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SgOppBW
bool GoEyeUtil::IsSinglePointEye2(const GoBoard& board, SgPoint p,
SgBlackWhite color, SgVector<SgPoint>& eyes)
{
// Must be an empty point
if (! board.IsColor(p, SG_EMPTY))
return false;
// All adjacent neighbours must be friendly
SgBoardColor opp = SgOppBW(color);
for (SgNb4Iterator adj(p); adj; ++adj)
{
SgBoardColor adjColor = board.GetColor(*adj);
if (adjColor == opp || adjColor == SG_EMPTY)
return false;
}
// All diagonals (with up to one exception) must be friendly or an eye
int baddiags = 0;
int maxbaddiags = (board.Line(p) == 1 ? 0 : 1);
for (SgNb4DiagIterator it(p); it; ++it)
{
if (board.IsColor(*it, opp))
++baddiags;
if (board.IsColor(*it, SG_EMPTY) && ! eyes.Contains(*it))
{
// Assume this point is an eye and recurse
eyes.PushBack(p);
if (! IsSinglePointEye2(board, *it, color, eyes))
++baddiags;
eyes.PopBack();
}
if (baddiags > maxbaddiags)
return false;
}
return true;
}
示例2: ComputeInfluence
void GoInfluence::ComputeInfluence(const GoBoard& bd,
const SgBWSet& stopPts,
SgBWArray<SgPointArray<int> >* influence)
{
const int MAX_INFLUENCE = 64;
for (SgBWIterator it; it; ++it)
{
SgBlackWhite color = *it;
((*influence)[color]).Fill(0);
for (GoBoard::Iterator it(bd); it; ++it)
{
SgPoint p(*it);
if (bd.IsColor(p, color))
Spread(bd, p, stopPts[color], MAX_INFLUENCE,
(*influence)[color]);
}
}
}
示例3: if
bool GoEyeUtil::NumberOfMoveToEye2(const GoBoard& board, SgBlackWhite color,
SgPoint p, int& nummoves)
{
nummoves = 0;
bool capturing = false;
SgVector<SgPoint> usedpoints;
usedpoints.PushBack(p);
SgPointSet counted;
// Can never turn own stone into an eye
if (board.IsColor(p, color))
return false;
// If opponent stone then it must be captured to make eye
if (board.IsColor(p, SgOppBW(color)))
{
capturing = true;
// If it is obviously safe then it can never be an eye
if (SinglePointSafe2(board, p)) // Quick, naive safety test
return false;
for (GoBoard::LibertyIterator libit(board, p); libit; ++libit)
counted.Include(*libit);
}
// Count immediate adjacencies
for (SgNb4Iterator nb(p); nb; ++nb)
{
SgPoint adj = *nb;
// Empty points must be filled
if (board.IsColor(adj, SG_EMPTY))
{
counted.Include(adj);
}
// If adjacent opponent then can never be an eye
else if (board.IsColor(adj, SgOppBW(color)))
{
if (capturing)
counted.Include(adj); // must capture and then fill
else
return false;
}
}
// Up to one diagonal can be ignored: estimate most costly
SgPoint toignore = SG_NULLPOINT;
int maxcost = 0;
int infcost = 1000;
if (board.Line(p) > 1)
{
for (SgNb4DiagIterator nbd(p); nbd; ++nbd)
{
SgPoint diag = *nbd;
int cost = 0;
if ( board.IsColor(diag, SG_EMPTY)
&& ! IsSinglePointEye2(board, diag, color, usedpoints))
{
cost = 1;
}
else if (board.IsColor(diag, SgOppBW(color)))
{
// quick safety test
if (SinglePointSafe2(board, diag))
cost = infcost;
else
cost = board.NumLiberties(diag);
}
if (cost > maxcost)
{
maxcost = cost;
toignore = diag;
}
}
}
// Now mark points that must be played to secure diagonals
for (SgNb4DiagIterator nbd(p); nbd; ++nbd)
{
SgPoint diag = *nbd;
if (diag == toignore)
continue;
// Empty points must be filled (unless they are eyes)
if ( board.IsColor(diag, SG_EMPTY)
&& ! IsSinglePointEye2(board, diag, color, usedpoints))
{
counted.Include(diag);
}
// Opponent stones on diagonals must be captured and filled
else if (board.IsColor(diag, SgOppBW(color)))
{
if (SinglePointSafe2(board, diag))
return false;
//.........这里部分代码省略.........