当前位置: 首页>>代码示例>>C++>>正文


C++ Square::dir方法代码示例

本文整理汇总了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;
    }
  }
开发者ID:sunfish-shogi,项目名称:sunfish4,代码行数:44,代码来源:SEE.cpp

示例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));
  }
}
开发者ID:sunfish-shogi,项目名称:sunfish4,代码行数:37,代码来源:TardyMoveGenerator.cpp


注:本文中的Square::dir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。