本文整理汇总了C++中GoBoard::IsValidPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ GoBoard::IsValidPoint方法的具体用法?C++ GoBoard::IsValidPoint怎么用?C++ GoBoard::IsValidPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GoBoard
的用法示例。
在下文中一共展示了GoBoard::IsValidPoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PointArg
SgPoint GoGtpCommandUtil::PointArg(const GtpCommand& cmd, std::size_t number,
const GoBoard& board)
{
string arg = cmd.Arg(number);
istringstream in(arg);
SgPoint p;
in >> SgReadPoint(p);
if (! in)
throw GtpFailure() << "invalid point " << arg;
if (p == SG_PASS)
throw GtpFailure("expected point, not pass");
if (SgMoveUtil::IsCouponMove(p))
throw GtpFailure("expected point, not coupon move");
if (! board.IsValidPoint(p))
throw GtpFailure() << "point outside board " << arg;
return p;
}
示例2: 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;
}
示例3: 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);
}