From de6ee73d5582f90f9de458d0bc9eb9efb265f57d Mon Sep 17 00:00:00 2001 From: Calcitem Date: Mon, 21 Dec 2020 01:10:21 +0800 Subject: [PATCH] bb: Refactor in_how_many_mills() --- src/position.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index dc5d7271..2c8d73b0 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1597,18 +1597,23 @@ int Position::in_how_many_mills(Square s, Color c, Square squareSelected) #endif } - for (int l = 0; l < LD_NB; l++) { -#ifdef DISABLE_BITBOARD - bool b = make_piece(c) & - board[millTable[s][l][0]] & - board[millTable[s][l][1]]; -#else - bool b = ((byColorBB[c] & millTableBB[s][l]) == millTableBB[s][l]); +#ifndef DISABLE_BITBOARD + Bitboard bc = byColorBB[c]; + Bitboard *mt = millTableBB[s]; #endif - if (b) { + for (int l = 0; l < LD_NB; l++) { +#ifdef DISABLE_BITBOARD + if (make_piece(c) & + board[millTable[s][l][0]] & + board[millTable[s][l][1]]) { n++; } +#else + if ((bc & mt[l]) == mt[l]) { + n++; + } +#endif } if (squareSelected != SQ_0) { @@ -1629,10 +1634,10 @@ int Position::add_mills(Square s) #ifdef DISABLE_BITBOARD int idx[3], min, temp; -#endif - +#else Bitboard bc = byColorBB[color_on(s)]; Bitboard *mt = millTableBB[s]; +#endif for (int i = 0; i < 3; i++) {