mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Test with SEE shortcut
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
4397e6c03e
commit
8a85007023
1 changed files with 10 additions and 3 deletions
|
@ -1629,16 +1629,23 @@ int Position::see(Square from, Square to) const {
|
||||||
| (pawn_attacks(WHITE, to) & pawns(BLACK))
|
| (pawn_attacks(WHITE, to) & pawns(BLACK))
|
||||||
| (pawn_attacks(BLACK, to) & pawns(WHITE));
|
| (pawn_attacks(BLACK, to) & pawns(WHITE));
|
||||||
|
|
||||||
attackers &= occ; // Re-add removed piece
|
|
||||||
|
|
||||||
// If the opponent has no attackers, we are finished
|
// If the opponent has no attackers, we are finished
|
||||||
if ((attackers & pieces_of_color(them)) == EmptyBoardBB)
|
if ((attackers & pieces_of_color(them)) == EmptyBoardBB)
|
||||||
return seeValues[capture];
|
return seeValues[capture];
|
||||||
|
|
||||||
|
attackers &= occ; // Remove the moving piece
|
||||||
|
|
||||||
|
// If we don't have any attacker but the moving piece (common case)
|
||||||
|
// then we loose our piece and gain the opponent attacked one.
|
||||||
|
// Note that this is not perfect! It does not detect x-rays of
|
||||||
|
// an our piece behind an opposite one. But is a very rare case.
|
||||||
|
if ((attackers & pieces_of_color(us)) == EmptyBoardBB)
|
||||||
|
return seeValues[capture] - seeValues[piece];
|
||||||
|
|
||||||
// The destination square is defended, which makes things rather more
|
// The destination square is defended, which makes things rather more
|
||||||
// difficult to compute. We proceed by building up a "swap list" containing
|
// difficult to compute. We proceed by building up a "swap list" containing
|
||||||
// the material gain or loss at each stop in a sequence of captures to the
|
// the material gain or loss at each stop in a sequence of captures to the
|
||||||
// destianation square, where the sides alternately capture, and always
|
// destination square, where the sides alternately capture, and always
|
||||||
// capture with the least valuable piece. After each capture, we look for
|
// capture with the least valuable piece. After each capture, we look for
|
||||||
// new X-ray attacks from behind the capturing piece.
|
// new X-ray attacks from behind the capturing piece.
|
||||||
int lastCapturingPieceValue = seeValues[piece];
|
int lastCapturingPieceValue = seeValues[piece];
|
||||||
|
|
Loading…
Add table
Reference in a new issue