本文整理汇总了C++中Square::dir方法的典型用法代码示例。如果您正苦于以下问题:C++ Square::dir方法的具体用法?C++ Square::dir怎么用?C++ Square::dir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Square
的用法示例。
在下文中一共展示了Square::dir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extractShadowAttacker
Bitboard SEE::extractShadowAttacker(const Position& position,
Bitboard bb,
Square from,
Square to) {
Direction dir = from.dir(to);
if (dir >= Direction::EndS) {
return bb;
}
Bitboard occ = nosseOr(position.getBOccupiedBitboard(),
position.getWOccupiedBitboard());
RotatedBitboard occ90 = position.get90RotatedBitboard();
RotatedBitboard occR45 = position.getRight45RotatedBitboard();
RotatedBitboard occL45 = position.getLeft45RotatedBitboard();
Bitboard masked;
switch (dir) {
case Direction::Up:
case Direction::Down:
masked = MoveTables::ver(occ, from);
break;
case Direction::Left:
case Direction::Right:
masked = MoveTables::hor(occ90, from);
break;
case Direction::RightUp:
case Direction::LeftDown:
masked = MoveTables::diagR45(occR45, to);
break;
case Direction::LeftUp:
case Direction::RightDown:
masked = MoveTables::diagL45(occL45, to);
break;
default:
ASSERT(false);
}
BB_EACH(square, masked) {
Piece piece = position.getPieceOnBoard(square);
if (square.dir(from) == dir && MoveTables::isMovableInLongStep(piece, dir)) {
bb.set(square);
break;
}
}
示例2: generateEvasions
void TardyMoveGenerator::generateEvasions(const Position& position, CheckState cs, Moves& moves) {
Turn turn = position.getTurn();
Square king = turn == Turn::Black ? position.getBlackKingSquare() : position.getWhiteKingSquare();
if (!isDoubleCheck(cs)) {
::generateMoves(position, moves, [king, cs](PieceType pieceType, Square to) {
if (pieceType == PieceType::king()) {
return false;
}
auto dir = king.dir(cs.from1);
for (auto s = king.move(dir); ; s = s.move(dir)) {
if (s == to) { return true; }
if (s == cs.from1) { break; }
}
return false;
});
}
auto& list = MovableMap.find(PieceNumber::King)->second;
for (auto& info : list) {
Square to = king.safetyMove(info.dir);
if (!to.isValid()) {
continue;
}
Piece pieceTo = position.getPieceOnBoard(to);
if ((turn == Turn::Black && pieceTo.isBlack()) ||
(turn == Turn::White && pieceTo.isWhite())) {
continue;
}
moves.add(Move(king, to, false));
}
}