mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Simplify generate<EVASIONS>
Use the newly introduced LineBB[] to simplify this super hot-path function. Verified with perft we don't have any speed regression, although the number of squares removed is less than before in case of contact check. Insipred by DiscoCheck implementation. Perft numbers are the same, but we have an harmless functional change due to reorder of moves, because now some illegal moves are no more detected at generation time, but in the search. bench: 8331357
This commit is contained in:
parent
555d9a8711
commit
9763c69fa5
1 changed files with 2 additions and 19 deletions
|
@ -364,26 +364,9 @@ ExtMove* generate<EVASIONS>(const Position& pos, ExtMove* mlist) {
|
||||||
|
|
||||||
assert(color_of(pos.piece_on(checksq)) == ~us);
|
assert(color_of(pos.piece_on(checksq)) == ~us);
|
||||||
|
|
||||||
switch (type_of(pos.piece_on(checksq)))
|
if (type_of(pos.piece_on(checksq)) > KNIGHT) // A slider
|
||||||
{
|
sliderAttacks |= LineBB[checksq][ksq] ^ checksq;
|
||||||
case BISHOP: sliderAttacks |= PseudoAttacks[BISHOP][checksq]; break;
|
|
||||||
case ROOK: sliderAttacks |= PseudoAttacks[ROOK][checksq]; break;
|
|
||||||
case QUEEN:
|
|
||||||
// If queen and king are far or not on a diagonal line we can safely
|
|
||||||
// remove all the squares attacked in the other direction becuase are
|
|
||||||
// not reachable by the king anyway.
|
|
||||||
if (between_bb(ksq, checksq) || !(PseudoAttacks[BISHOP][checksq] & ksq))
|
|
||||||
sliderAttacks |= PseudoAttacks[QUEEN][checksq];
|
|
||||||
|
|
||||||
// Otherwise we need to use real rook attacks to check if king is safe
|
|
||||||
// to move in the other direction. For example: king in B2, queen in A1
|
|
||||||
// a knight in B1, and we can safely move to C1.
|
|
||||||
else
|
|
||||||
sliderAttacks |= PseudoAttacks[BISHOP][checksq] | pos.attacks_from<ROOK>(checksq);
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while (b);
|
} while (b);
|
||||||
|
|
||||||
// Generate evasions for king, capture and non capture moves
|
// Generate evasions for king, capture and non capture moves
|
||||||
|
|
Loading…
Add table
Reference in a new issue