mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 17:19:36 +00:00
Microoptimize generate<MV_EVASION>
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
fca0a2dd88
commit
5ff6289afd
1 changed files with 9 additions and 4 deletions
|
@ -272,12 +272,17 @@ MoveStack* generate<MV_EVASION>(const Position& pos, MoveStack* mlist) {
|
||||||
case BISHOP: sliderAttacks |= BishopPseudoAttacks[checksq]; break;
|
case BISHOP: sliderAttacks |= BishopPseudoAttacks[checksq]; break;
|
||||||
case ROOK: sliderAttacks |= RookPseudoAttacks[checksq]; break;
|
case ROOK: sliderAttacks |= RookPseudoAttacks[checksq]; break;
|
||||||
case QUEEN:
|
case QUEEN:
|
||||||
// In case of a queen remove also squares attacked in the other direction to
|
// If queen and king are far we can safely remove all the squares attacked
|
||||||
// avoid possible illegal moves when queen and king are on adjacent squares.
|
// in the other direction becuase are not reachable by the king anyway.
|
||||||
if (RookPseudoAttacks[checksq] & (1ULL << ksq))
|
if (squares_between(ksq, checksq) || (RookPseudoAttacks[checksq] & (1ULL << ksq)))
|
||||||
sliderAttacks |= RookPseudoAttacks[checksq] | pos.attacks_from<BISHOP>(checksq);
|
sliderAttacks |= QueenPseudoAttacks[checksq];
|
||||||
|
|
||||||
|
// Otherwise, if king and queen are adjacent and on a diagonal line, 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
|
else
|
||||||
sliderAttacks |= BishopPseudoAttacks[checksq] | pos.attacks_from<ROOK>(checksq);
|
sliderAttacks |= BishopPseudoAttacks[checksq] | pos.attacks_from<ROOK>(checksq);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue