From 49a9d4cf99e56d071af3060b3f306b9daa0a62a6 Mon Sep 17 00:00:00 2001 From: snicolet Date: Tue, 25 Apr 2017 17:57:30 -0700 Subject: [PATCH] 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 --- src/bitbase.cpp | 4 ++-- src/position.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) 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]; -- 2.39.2