mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-19 00:26:33 +08:00
generate_evasions() avoid to calculate pinned pieces
Pass as function argument. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -204,7 +204,7 @@ int generate_checks(const Position& pos, MoveStack* mlist, Bitboard dc) {
|
||||
/// only legal moves. It returns the number of generated moves. This
|
||||
/// function is very ugly, and needs cleaning up some time later. FIXME
|
||||
|
||||
int generate_evasions(const Position& pos, MoveStack* mlist) {
|
||||
int generate_evasions(const Position& pos, MoveStack* mlist, Bitboard pinned) {
|
||||
|
||||
assert(pos.is_ok());
|
||||
assert(pos.is_check());
|
||||
@@ -265,12 +265,10 @@ int generate_evasions(const Position& pos, MoveStack* mlist) {
|
||||
if (!(checkers & (checkers - 1))) // Only one bit set?
|
||||
{
|
||||
Square checksq = first_1(checkers);
|
||||
Bitboard not_pinned = ~pinned;
|
||||
|
||||
assert(pos.color_of_piece_on(checksq) == them);
|
||||
|
||||
// Find pinned pieces
|
||||
Bitboard not_pinned = ~pos.pinned_pieces(us);
|
||||
|
||||
// Generate captures of the checking piece
|
||||
|
||||
// Pawn captures
|
||||
@@ -361,15 +359,15 @@ int generate_legal_moves(const Position& pos, MoveStack* mlist) {
|
||||
|
||||
assert(pos.is_ok());
|
||||
|
||||
Bitboard pinned = pos.pinned_pieces(pos.side_to_move());
|
||||
|
||||
if (pos.is_check())
|
||||
return generate_evasions(pos, mlist);
|
||||
return generate_evasions(pos, mlist, pinned);
|
||||
|
||||
// Generate pseudo-legal moves
|
||||
int n = generate_captures(pos, mlist);
|
||||
n += generate_noncaptures(pos, mlist + n);
|
||||
|
||||
Bitboard pinned = pos.pinned_pieces(pos.side_to_move());
|
||||
|
||||
// Remove illegal moves from the list
|
||||
for (int i = 0; i < n; i++)
|
||||
if (!pos.pl_move_is_legal(mlist[i].move, pinned))
|
||||
|
||||
Reference in New Issue
Block a user