update move generation for pinned pieces
This commit is contained in:
parent
2426a0cdb3
commit
d500f525f7
2 changed files with 33 additions and 12 deletions
|
|
@ -995,13 +995,10 @@ impl Position {
|
|||
}
|
||||
|
||||
let blockers_x_ray = blockers & !(x | y);
|
||||
let pinned_diagonally = (lookup::bishop(king_square, blockers_x_ray) & theirs.bishop())
|
||||
.map(|sq| lookup::segment(king_square, sq))
|
||||
.reduce_or();
|
||||
let pinned_horizontally = (lookup::rook(king_square, blockers_x_ray) & theirs.rook())
|
||||
.map(|sq| lookup::segment(king_square, sq))
|
||||
.reduce_or();
|
||||
let pinned = pinned_diagonally | pinned_horizontally;
|
||||
let pinned = ((lookup::bishop(king_square, blockers_x_ray) & theirs.bishop())
|
||||
| (lookup::rook(king_square, blockers_x_ray) & theirs.rook()))
|
||||
.map(|sq| lookup::segment(king_square, sq))
|
||||
.reduce_or();
|
||||
|
||||
let checker = checkers.first();
|
||||
let block_check = checker
|
||||
|
|
@ -1173,8 +1170,8 @@ impl Position {
|
|||
|
||||
// pinned pieces
|
||||
{
|
||||
let aux = |moves: &mut T, role, mask| {
|
||||
for from in global_mask_from & *ours.get(role) & mask {
|
||||
let aux = |moves: &mut T, role, role_mask| {
|
||||
for from in global_mask_from & pinned & role_mask & *ours.get(role) {
|
||||
moves.extend(
|
||||
(global_mask_to & !us & pinned & lookup::line(king_square, from)).map(
|
||||
|to| RawMove {
|
||||
|
|
@ -1188,13 +1185,13 @@ impl Position {
|
|||
}
|
||||
};
|
||||
if moves.roles(Role::Bishop) {
|
||||
aux(moves, Role::Bishop, pinned_diagonally);
|
||||
aux(moves, Role::Bishop, lookup::bishop_lines(king_square));
|
||||
}
|
||||
if moves.roles(Role::Rook) {
|
||||
aux(moves, Role::Rook, pinned_horizontally);
|
||||
aux(moves, Role::Rook, lookup::rook_lines(king_square));
|
||||
}
|
||||
if moves.roles(Role::Queen) {
|
||||
aux(moves, Role::Queen, pinned);
|
||||
aux(moves, Role::Queen, !Bitboard::new());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue