]> git.sesse.net Git - stockfish/blobdiff - src/bitbase.cpp
Fix a couple of issues in bitbase.cpp
[stockfish] / src / bitbase.cpp
index 0c3230f2aa9c0e9619fbe6f607eae4a77a1df066..3426a3182ee703e0919001447a4ed84a241fa0ba 100644 (file)
@@ -37,9 +37,9 @@ namespace {
     bool is_legal() const;
     bool is_immediate_draw() const;
     bool is_immediate_win() const;
-    Bitboard wk_attacks()   const { return NonSlidingAttacksBB[WK][whiteKingSquare]; }
-    Bitboard bk_attacks()   const { return NonSlidingAttacksBB[BK][blackKingSquare]; }
-    Bitboard pawn_attacks() const { return NonSlidingAttacksBB[WP][pawnSquare]; }
+    Bitboard wk_attacks()   const { return StepAttacksBB[WK][whiteKingSquare]; }
+    Bitboard bk_attacks()   const { return StepAttacksBB[BK][blackKingSquare]; }
+    Bitboard pawn_attacks() const { return StepAttacksBB[WP][pawnSquare]; }
 
     Square whiteKingSquare, blackKingSquare, pawnSquare;
     Color sideToMove;
@@ -162,6 +162,11 @@ namespace {
             && pawnSquare == SQ_A7
             && (blackKingSquare == SQ_C7 || blackKingSquare == SQ_C8))
             return true;
+
+        if (   whiteKingSquare == SQ_H8
+            && pawnSquare == SQ_H7
+            && (blackKingSquare == SQ_F7 || blackKingSquare == SQ_F8))
+            return true;
     }
     return false;
   }
@@ -172,6 +177,7 @@ namespace {
     // white pawn can be promoted without getting captured.
     return   sideToMove == WHITE
           && square_rank(pawnSquare) == RANK_7
+          && whiteKingSquare != pawnSquare + DELTA_N
           && (   square_distance(blackKingSquare, pawnSquare + DELTA_N) > 1
               || bit_is_set(wk_attacks(), pawnSquare + DELTA_N));
   }