Skip to content
This repository
Browse code

Fix a performance bug in generate_move_if_legal

Use the pinned argument in pos.move_is_legal()

No functional change, simply use pos.move_is_legal() as
was meant to be.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
  • Loading branch information...
commit 2aebf8eb559a2a8129e6246b75f282fe5d1bc45a 1 parent 1ac2f50
Marco Costalba authored

Showing 1 changed file with 3 additions and 3 deletions. Show diff stats Hide diff stats

  1. +3 3 src/movegen.cpp
6 src/movegen.cpp
@@ -429,7 +429,7 @@ Move generate_move_if_legal(const Position& pos, Move m, Bitboard pinned) {
429 429 assert(pos.piece_on(to - pawn_push(us)) == pawn_of_color(them));
430 430
431 431 // The move is pseudo-legal. If it is legal, return it.
432   - return (pos.move_is_legal(m) ? m : MOVE_NONE);
  432 + return (pos.move_is_legal(m, pinned) ? m : MOVE_NONE);
433 433 }
434 434
435 435 // Castling moves
@@ -561,12 +561,12 @@ Move generate_move_if_legal(const Position& pos, Move m, Bitboard pinned) {
561 561 return MOVE_NONE;
562 562 }
563 563 // The move is pseudo-legal. Return it if it is legal.
564   - return (pos.move_is_legal(m) ? m : MOVE_NONE);
  564 + return (pos.move_is_legal(m, pinned) ? m : MOVE_NONE);
565 565 }
566 566
567 567 // Luckly we can handle all the other pieces in one go
568 568 return ( pos.piece_attacks_square(from, to)
569   - && pos.move_is_legal(m)
  569 + && pos.move_is_legal(m, pinned)
570 570 && !move_promotion(m) ? m : MOVE_NONE);
571 571 }
572 572

0 comments on commit 2aebf8e

Please sign in to comment.
Something went wrong with that request. Please try again.