本文整理汇总了C++中GoBoard::GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C++ GoBoard::GetHashCode方法的具体用法?C++ GoBoard::GetHashCode怎么用?C++ GoBoard::GetHashCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GoBoard
的用法示例。
在下文中一共展示了GoBoard::GetHashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LadderStatus
GoLadderStatus GoLadderUtil::LadderStatus(const GoBoard& bd, SgPoint prey,
bool twoLibIsEscape,
SgPoint* toCapture,
SgPoint* toEscape)
{
SG_ASSERT(bd.IsValidPoint(prey));
SG_ASSERT(bd.Occupied(prey));
#ifndef NDEBUG
SgHashCode oldHash = bd.GetHashCode();
#endif
// Unsettled only if can capture when hunter plays first, and can escape
// if prey plays first.
GoLadder ladder;
SgBlackWhite preyColor = bd.GetStone(prey);
SgVector<SgPoint> captureSequence;
GoLadderStatus status = GO_LADDER_ESCAPED;
if (ladder.Ladder(bd, prey, SgOppBW(preyColor), &captureSequence,
twoLibIsEscape) < 0)
{
SgVector<SgPoint> escapeSequence;
if (ladder.Ladder(bd, prey, preyColor, &escapeSequence,
twoLibIsEscape) < 0)
status = GO_LADDER_CAPTURED;
else
{
status = GO_LADDER_UNSETTLED;
// Unsettled = ladder depends on who plays first, so there must
// be a move that can be played.
SG_ASSERT(captureSequence.NonEmpty());
// escapeSequence can be empty in 2 libs, prey to play case
SG_ASSERT(twoLibIsEscape || escapeSequence.NonEmpty());
if (toCapture)
*toCapture = captureSequence.Front();
if (toEscape)
*toEscape = escapeSequence.IsEmpty() ? SG_PASS :
escapeSequence.Front();
}
}
#ifndef NDEBUG
// Make sure Ladder didn't change the board position.
SG_ASSERT(oldHash == bd.GetHashCode());
#endif
return status;
}
示例2: Ladder
bool GoLadderUtil::Ladder(const GoBoard& bd, SgPoint prey,
SgBlackWhite toPlay, bool twoLibIsEscape,
SgVector<SgPoint>* sequence)
{
SG_ASSERT(bd.IsValidPoint(prey));
SG_ASSERT(bd.Occupied(prey));
// @todo for an unsettled block with 2 liberties, it
// immediately says it can escape, but does not return a move.
// Sequence is empty. Have to special case this and look for
// moves that escape from ladder myself.
#ifndef NDEBUG
SgHashCode oldHash = bd.GetHashCode();
#endif
GoLadder ladder;
int result = ladder.Ladder(bd, prey, toPlay, sequence, twoLibIsEscape);
#ifndef NDEBUG
// Make sure Ladder didn't change the board position.
SG_ASSERT(oldHash == bd.GetHashCode());
#endif
SG_ASSERT(result != 0);
return (result < 0);
}