本文整理汇总了C++中GoBoard::SetToPlay方法的典型用法代码示例。如果您正苦于以下问题:C++ GoBoard::SetToPlay方法的具体用法?C++ GoBoard::SetToPlay怎么用?C++ GoBoard::SetToPlay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GoBoard
的用法示例。
在下文中一共展示了GoBoard::SetToPlay方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void GoBoardUpdater::Update(const SgNode* node, GoBoard& bd)
{
////SG_ASSERT(node != 0);
m_nodes.clear();
while (node != 0)
{
m_nodes.push_back(node);
node = node->Father();
}
const SgNode* root = m_nodes[m_nodes.size() - 1];
int size = GO_DEFAULT_SIZE;
SgPropInt* boardSize = static_cast<SgPropInt*>(root->Get(SG_PROP_SIZE));
if (boardSize)
{
size = boardSize->Value();
////SG_ASSERT(SgUtil::InRange(size, SG_MIN_SIZE, SG_MAX_SIZE));
}
bd.Init(size);
for (vector<const SgNode*>::reverse_iterator it = m_nodes.rbegin();
it != m_nodes.rend(); ++it)
{
const SgNode* node = *it;
SgEmptyBlackWhite player = GetPlayer(node);
if (node->HasProp(SG_PROP_ADD_EMPTY)
|| node->HasProp(SG_PROP_ADD_BLACK)
|| node->HasProp(SG_PROP_ADD_WHITE))
{
// Compute the new initial setup position to re-initialize the
// board with
GoSetup setup = GoSetupUtil::CurrentPosSetup(bd);
if (player != SG_EMPTY)
setup.m_player = player;
if (node->HasProp(SG_PROP_ADD_BLACK))
{
SgPropAddStone* prop =
dynamic_cast<SgPropAddStone*>(node->Get(SG_PROP_ADD_BLACK));
const SgVector<SgPoint>& addBlack = prop->Value();
for (SgVectorIterator<SgPoint> it2(addBlack); it2; ++it2)
{
SgPoint p = *it2;
setup.m_stones[SG_WHITE].Exclude(p);
if (! setup.m_stones[SG_BLACK].Contains(p))
setup.AddBlack(p);
}
}
if (node->HasProp(SG_PROP_ADD_WHITE))
{
SgPropAddStone* prop =
dynamic_cast<SgPropAddStone*>(node->Get(SG_PROP_ADD_WHITE));
const SgVector<SgPoint>& addWhite = prop->Value();
for (SgVectorIterator<SgPoint> it2(addWhite); it2; ++it2)
{
SgPoint p = *it2;
setup.m_stones[SG_BLACK].Exclude(p);
if (! setup.m_stones[SG_WHITE].Contains(p))
setup.AddWhite(p);
}
}
if (node->HasProp(SG_PROP_ADD_EMPTY))
{
SgPropAddStone* prop =
dynamic_cast<SgPropAddStone*>(node->Get(SG_PROP_ADD_EMPTY));
const SgVector<SgPoint>& addEmpty = prop->Value();
for (SgVectorIterator<SgPoint> it2(addEmpty); it2; ++it2)
{
SgPoint p = *it2;
setup.m_stones[SG_BLACK].Exclude(p);
setup.m_stones[SG_WHITE].Exclude(p);
}
}
bd.Init(bd.Size(), setup);
}
else if (player != SG_EMPTY)
bd.SetToPlay(player);
if (node->HasProp(SG_PROP_MOVE))
{
SgPropMove* prop =
dynamic_cast<SgPropMove*>(node->Get(SG_PROP_MOVE));
SgPoint p = prop->Value();
if (p == SG_PASS || ! bd.Occupied(p))
bd.Play(p, prop->Player());
}
}
}