]> git.sesse.net Git - stockfish/blobdiff - src/bitbase.cpp
Fix a couple of issues in bitbase.cpp
[stockfish] / src / bitbase.cpp
index ac03120f5f97cb59a6c868fca9698f4ffc38d6a9..3426a3182ee703e0919001447a4ed84a241fa0ba 100644 (file)
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-
-////
-//// Includes
-////
-
 #include <cassert>
 
 #include "bitboard.h"
-#include "square.h"
-
-
-////
-//// Local definitions
-////
+#include "types.h"
 
 namespace {
 
@@ -47,9 +37,9 @@ namespace {
     bool is_legal() const;
     bool is_immediate_draw() const;
     bool is_immediate_win() const;
-    Bitboard wk_attacks()   const { return StepAttackBB[WK][whiteKingSquare]; }
-    Bitboard bk_attacks()   const { return StepAttackBB[BK][blackKingSquare]; }
-    Bitboard pawn_attacks() const { return StepAttackBB[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;
@@ -63,10 +53,6 @@ namespace {
 }
 
 
-////
-//// Functions
-////
-
 void generate_kpk_bitbase(uint8_t bitbase[]) {
 
   bool repeat;
@@ -176,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;
   }
@@ -186,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));
   }