From: snicolet Date: Wed, 26 Apr 2017 00:57:30 +0000 (-0700) Subject: Avoid misuse of StepAttacksBB for pawns X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=49a9d4cf99e56d071af3060b3f306b9daa0a62a6 Avoid misuse of StepAttacksBB for pawns Make it explicit that first index of StepAttacksBB is a piece, not a piece type. No functional change Closes #1083 --- diff --git a/src/bitbase.cpp b/src/bitbase.cpp index 1a6e8076..0e4521c1 100644 --- a/src/bitbase.cpp +++ b/src/bitbase.cpp @@ -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; diff --git a/src/position.h b/src/position.h index e571048a..5a07193b 100644 --- a/src/position.h +++ b/src/position.h @@ -273,6 +273,7 @@ inline Square Position::castling_rook_square(CastlingRight cr) const { template inline Bitboard Position::attacks_from(Square s) const { + assert(Pt != PAWN); return Pt == BISHOP || Pt == ROOK ? attacks_bb(s, byTypeBB[ALL_PIECES]) : Pt == QUEEN ? attacks_from(s) | attacks_from(s) : StepAttacksBB[Pt][s];