本文整理汇总了C++中GoBoard::ToPlay方法的典型用法代码示例。如果您正苦于以下问题:C++ GoBoard::ToPlay方法的具体用法?C++ GoBoard::ToPlay怎么用?C++ GoBoard::ToPlay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GoBoard
的用法示例。
在下文中一共展示了GoBoard::ToPlay方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsProtectedLiberty
bool GoLadderUtil::IsProtectedLiberty(const GoBoard& bd1, SgPoint liberty,
SgBlackWhite col, bool& byLadder,
bool& isKoCut, bool tryLadder)
{
byLadder = false;
isKoCut = false;
GoModBoard mbd(bd1);
GoBoard& bd = mbd.Board();
const SgBlackWhite toPlay = bd1.ToPlay();
bd.SetToPlay(SgOppBW(col));
bool isProtected;
if (! PlayIfLegal(bd, liberty))
isProtected = bd.LastMoveInfo(GO_MOVEFLAG_SUICIDE);
// opponent cannot play there
else
{
if (bd.LastMoveInfo(GO_MOVEFLAG_SUICIDE))
isProtected = true;
else
{
if (bd.InAtari(liberty))
{
if (bd.NumStones(liberty) > 1)
isProtected = true;
else
{
SgPoint p = bd.TheLiberty(liberty);
if (PlayIfLegal(bd, p))
{
isProtected = (bd.NumStones(p) != 1)
|| (bd.NumLiberties(p) != 1);
// yes, can re-capture there
bd.Undo();
}
else
isProtected = false;
if (! isProtected)
isKoCut = true;
}
}
else if (tryLadder)
{
isProtected = Ladder(bd, liberty, bd.ToPlay(), true);
if (isProtected)
byLadder = true;
}
else // don't try ladder
isProtected = false;
}
bd.Undo();
}
bd.SetToPlay(toPlay);
return isProtected;
}
示例2: SetFromBoard
void GoBoardHistory::SetFromBoard(const GoBoard& bd)
{
m_boardSize = bd.Size();
m_rules = bd.Rules();
m_setup = bd.Setup();
m_moves.Clear();
for (int i = 0; i < bd.MoveNumber(); ++i)
m_moves.PushBack(bd.Move(i));
m_toPlay = bd.ToPlay();
}
示例3: CurrentPosSetup
GoSetup GoSetupUtil::CurrentPosSetup(const GoBoard& bd)
{
GoSetup setup;
setup.m_player = bd.ToPlay();
for (GoBoard::Iterator it2(bd); it2; ++it2)
{
SgPoint p = *it2;
if (bd.Occupied(p))
setup.m_stones[bd.GetColor(p)].Include(p);
}
return setup;
}