本文整理汇总了C++中boost::optional::color方法的典型用法代码示例。如果您正苦于以下问题:C++ optional::color方法的具体用法?C++ optional::color怎么用?C++ optional::color使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::optional
的用法示例。
在下文中一共展示了optional::color方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_captures
int check_captures(position src, position dst, board const& board,
piece what, OutIter out) {
piece::color_t const player = what.color();
board::mask supporters;
int score = 0;
if (trap(dst)) {
supporters = neighbourhood(dst) & board.player(player);
supporters[src] = false;
// Check for piece stepping into a trap.
if (supporters.empty()) {
*out++ = elementary_step::make_capture(dst, what);
score -= CAPTURE_COEF * cost(what, src);
}
}
// Check for piece abandoning another one standing on a trap.
if (neighbourhood(src) & board::mask::TRAPS && !trap(dst)) {
position const trap =
(neighbourhood(src) & board::mask::TRAPS).first_set();
boost::optional<piece> const trapped = board.get(trap);
if (trapped) {
piece::color_t const trapped_player = trapped->color();
supporters = neighbourhood(trap) & board.player(trapped_player);
supporters[src] = false;
if (supporters.empty()) {
*out++ = elementary_step::make_capture(trap, *trapped);
score +=
(trapped->color() == what.color() ? -1 : +1) *
CAPTURE_COEF * cost(*trapped, trap);
}
}
}
return score;
}