Exemple #1
0
void
calc_difference(const Position &pos, Move last_move, SearchStack *ss)
{
  const Square    from = move_from(last_move);
  const PieceType type = move_piece_type(last_move);

  if (type == kKing)
  {
    if (pos.side_to_move() == kBlack)
      calc_difference_king_move_no_capture<kWhite>(pos, ss);
    else
      calc_difference_king_move_no_capture<kBlack>(pos, ss);
  }
  else
  {
    if (from >= kBoardSquare)
    {
      calc_no_capture_difference(pos, ss);
    }
    else
    {
      const PieceType capture = move_capture(last_move);

      if (capture == kPieceNone)
        calc_no_capture_difference(pos, ss);
      else
        calc_difference_capture(pos, ss);
    }
  }
}
static bool capture_is_dangerous(int move, const board_t * board) {

   int piece, capture;

   ASSERT(move_is_ok(move));
   ASSERT(board!=NULL);

   ASSERT(move_is_tactical(move,board));

   piece = MOVE_PIECE(move,board);

   if (PIECE_IS_PAWN(piece)
    && PAWN_RANK(MOVE_TO(move),board->turn) >= Rank7) {
      return true;
   }

   capture = move_capture(move,board);

   if (PIECE_IS_QUEEN(capture)) return true;

   if (PIECE_IS_PAWN(capture)
    && PAWN_RANK(MOVE_TO(move),board->turn) <= Rank2) {
      return true;
   }

   return false;
}