update move generation for pinned pieces
This commit is contained in:
parent
c71bbc216f
commit
752150107e
1 changed files with 19 additions and 18 deletions
|
|
@ -1054,10 +1054,13 @@ impl Position {
|
||||||
}
|
}
|
||||||
|
|
||||||
let blockers_x_ray = blockers & !(x | y);
|
let blockers_x_ray = blockers & !(x | y);
|
||||||
let pinned = (d.bishop(king_square, blockers_x_ray) & theirs.bishop()
|
let pinned_diagonally = (d.bishop(king_square, blockers_x_ray) & theirs.bishop())
|
||||||
| d.rook(king_square, blockers_x_ray) & theirs.rook())
|
.map(|sq| d.segment(king_square, sq))
|
||||||
.map(|sq| d.segment(king_square, sq))
|
.reduce_or();
|
||||||
.reduce_or();
|
let pinned_horizontally = (d.rook(king_square, blockers_x_ray) & theirs.rook())
|
||||||
|
.map(|sq| d.segment(king_square, sq))
|
||||||
|
.reduce_or();
|
||||||
|
let pinned = pinned_diagonally | pinned_horizontally;
|
||||||
|
|
||||||
let checker = checkers.first();
|
let checker = checkers.first();
|
||||||
let block_check = checker
|
let block_check = checker
|
||||||
|
|
@ -1223,30 +1226,28 @@ impl Position {
|
||||||
|
|
||||||
// pinned pieces
|
// pinned pieces
|
||||||
{
|
{
|
||||||
let aux = |visitor: &mut T, role| {
|
let aux = |visitor: &mut T, role, mask| {
|
||||||
for from in global_mask_from & *ours.get(role) & pinned {
|
for from in global_mask_from & *ours.get(role) & mask {
|
||||||
visitor.moves(
|
visitor.moves(
|
||||||
(global_mask_to
|
(global_mask_to & !us & pinned & d.line(king_square, from)).map(|to| {
|
||||||
& d.targets(role, from, blockers)
|
RawMove {
|
||||||
& !us
|
kind: MoveType::PieceMove,
|
||||||
& d.line(king_square, from))
|
from,
|
||||||
.map(|to| RawMove {
|
to,
|
||||||
kind: MoveType::PieceMove,
|
role,
|
||||||
from,
|
}
|
||||||
to,
|
|
||||||
role,
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if visitor.roles(Role::Bishop) {
|
if visitor.roles(Role::Bishop) {
|
||||||
aux(visitor, Role::Bishop)
|
aux(visitor, Role::Bishop, pinned_diagonally);
|
||||||
}
|
}
|
||||||
if visitor.roles(Role::Rook) {
|
if visitor.roles(Role::Rook) {
|
||||||
aux(visitor, Role::Rook)
|
aux(visitor, Role::Rook, pinned_horizontally);
|
||||||
}
|
}
|
||||||
if visitor.roles(Role::Queen) {
|
if visitor.roles(Role::Queen) {
|
||||||
aux(visitor, Role::Queen)
|
aux(visitor, Role::Queen, pinned);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue