]> git.sesse.net Git - stockfish/commitdiff
Avoid misuse of StepAttacksBB for pawns
authorsnicolet <cassio@free.fr>
Wed, 26 Apr 2017 00:57:30 +0000 (17:57 -0700)
committerJoona Kiiski <joona@zoox.com>
Wed, 26 Apr 2017 00:57:49 +0000 (17:57 -0700)
Make it explicit that first index of StepAttacksBB is a piece, not a piece type.

No functional change

Closes #1083

src/bitbase.cpp
src/position.h

index 1a6e807603a88a6143f403c8314215a0fd4ad527..0e4521c1eb9ac20306de568c7832b11415791c6b 100644 (file)
@@ -117,7 +117,7 @@ namespace {
     if (   distance(ksq[WHITE], ksq[BLACK]) <= 1
         || ksq[WHITE] == psq
         || ksq[BLACK] == psq
-        || (us == WHITE && (StepAttacksBB[PAWN][psq] & ksq[BLACK])))
+        || (us == WHITE && (StepAttacksBB[W_PAWN][psq] & ksq[BLACK])))
         result = INVALID;
 
     // Immediate win if a pawn can be promoted without getting captured
@@ -130,7 +130,7 @@ namespace {
 
     // Immediate draw if it is a stalemate or a king captures undefended pawn
     else if (   us == BLACK
-             && (  !(StepAttacksBB[KING][ksq[us]] & ~(StepAttacksBB[KING][ksq[~us]] | StepAttacksBB[PAWN][psq]))
+             && (  !(StepAttacksBB[KING][ksq[us]] & ~(StepAttacksBB[KING][ksq[~us]] | StepAttacksBB[W_PAWN][psq]))
                  || (StepAttacksBB[KING][ksq[us]] & psq & ~StepAttacksBB[KING][ksq[~us]])))
         result = DRAW;
 
index e571048a2883d9404dcd9c3b7d7ba6dd93c012c9..5a07193b9c5e9226986f789977f9b27e22d519fe 100644 (file)
@@ -273,6 +273,7 @@ inline Square Position::castling_rook_square(CastlingRight cr) const {
 
 template<PieceType Pt>
 inline Bitboard Position::attacks_from(Square s) const {
+  assert(Pt != PAWN);
   return  Pt == BISHOP || Pt == ROOK ? attacks_bb<Pt>(s, byTypeBB[ALL_PIECES])
         : Pt == QUEEN  ? attacks_from<ROOK>(s) | attacks_from<BISHOP>(s)
         : StepAttacksBB[Pt][s];