- return false;
- }
-
-
- // connected_moves() tests whether two moves are 'connected' in the sense
- // that the first move somehow made the second move possible (for instance
- // if the moving piece is the same in both moves). The first move is assumed
- // to be the move that was made to reach the current position, while the
- // second move is assumed to be a move from the current position.
-
- bool connected_moves(const Position& pos, Move m1, Move m2) {
-
- Square f1, t1, f2, t2;
- Piece p1, p2;
- Square ksq;
-
- assert(is_ok(m1));
- assert(is_ok(m2));
-
- // Case 1: The moving piece is the same in both moves
- f2 = from_sq(m2);
- t1 = to_sq(m1);
- if (f2 == t1)
- return true;
-
- // Case 2: The destination square for m2 was vacated by m1
- t2 = to_sq(m2);
- f1 = from_sq(m1);
- if (t2 == f1)
- return true;
-
- // Case 3: Moving through the vacated square
- p2 = pos.piece_on(f2);
- if (piece_is_slider(p2) && (between_bb(f2, t2) & f1))
- return true;
-
- // Case 4: The destination square for m2 is defended by the moving piece in m1
- p1 = pos.piece_on(t1);
- if (pos.attacks_from(p1, t1, pos.pieces() ^ f2) & t2)
- return true;
-
- // Case 5: Discovered check, checking piece is the piece moved in m1
- ksq = pos.king_square(pos.side_to_move());
- if ( piece_is_slider(p1)
- && (between_bb(t1, ksq) & f2)
- && (pos.attacks_from(p1, t1, pos.pieces() ^ f2) & ksq))
- return true;
-
- return false;
- }
-
-
- // connected_threat() tests whether it is safe to forward prune a move or if
- // is somehow connected to the threat move returned by null search.
-
- bool connected_threat(const Position& pos, Move m, Move threat) {
-
- assert(is_ok(m));
- assert(is_ok(threat));
- assert(!pos.is_capture_or_promotion(m));
- assert(!pos.is_passed_pawn_push(m));
-
- Square mfrom = from_sq(m);
- Square mto = to_sq(m);
- Square tfrom = from_sq(threat);
- Square tto = to_sq(threat);
-
- // Case 1: Don't prune moves which move the threatened piece
- if (mfrom == tto)
- return true;
-
- // Case 2: If the threatened piece has value less than or equal to the
- // value of the threatening piece, don't prune moves which defend it.
- if ( pos.is_capture(threat)
- && ( PieceValue[MG][pos.piece_on(tfrom)] >= PieceValue[MG][pos.piece_on(tto)]
- || type_of(pos.piece_on(tfrom)) == KING))