Chess-Plisco
view release on metacpan or search on metacpan
lib/Chess/Plisco.pod view on Meta::CPAN
Either the king must move, the piece giving check must be captured, or another
piece must be moved between the king and the attacking piece.
=back
=item B<evasionSquares>
If a check can be evaded by moving a piece between the king and the attacking
piece of the opponent, this bitboard gives all squares where the check can be
blocked. These are all squares between the king and the attacking piece,
including the square where the attacker is standing.
=item B<enPassantShift>
If en-passant is possible, returns the shift of the square where the capturing
pawn has to move. If en-passant is not possible, 0 is returned. 0 happens to
be the shift of "a1" but "a1" is not a valid en-passant square. It is
therefore safe to use this method in boolean context.
=item B<material>
lib/Chess/Plisco.pod view on Meta::CPAN
=item B<POS-E<gt>[CP_POS_IRREVERSIBLE_CLOCK]>
The current value of the irreversible clock. See also L</irreversibleClock>.
=item B<POS-E<gt>[CP_POS_IN_CHECK]>
Bitmask of pieces giving check. See also L</inCheck>.
=item B<POS-E<gt>[CP_POS_EVASION_SQUARES]>
Bitboard of squares where a check can be blocked. See also L</evasionSquares>.
=item B<POS-E<gt>[CP_POS_SIGNATURE]>
Same as L</signature>.
=item B<POS-E<gt>[CP_POS_INFO]>
Additional properties of the position. See also L</info>.
=back
lib/Chess/Plisco/Tutorial.pod view on Meta::CPAN
=back
This information is always stored in a L<Chess::Plisco> object:
$evasion_strategy = cp_pos_evasion $pos;
if (CP_EVASION_KING_MOVE == $evasion_strategy) {
say "king must move";
} elsif (CP_EVASION_CAPTURE == $evasion_strategy) {
say "king can move or piece giving check can be captured";
} elsif (CP_EVASION_ALL == $evasion_strategy) {
say "king can move, piece can be captured, or check can be blocked:",
$pos->dumpBitboard(cp_pos_evasion_squares($pos));
}
Remember that the item at C<CP_POS_IN_CHECK> gives you a bitboard with all
pieces giving check. Alternatively, you can use the macro C<cp_pos_in_check>.
The bitboard at C<CP_POS_EVASION_SQUARES> has bits set for all pieces giving
check.
=head2 Various Tricks
t/04legal-moves.t view on Meta::CPAN
fen => '8/8/8/K7/1R3p1k/8/6P1/8 w - - 0 1',
premoves => [qw(g2g4)],
moves => [qw(h4g5 h4g4 h4g3 h4h3 f4f3)],
},
{
name => 'discovered bishop check through en passant simplified',
fen => '8/8/7k/K7/4pP2/8/8/2B5 b - g3 0 1',
moves => [qw(h6h7 h6g7 h6g6 h6h5 e4e3)],
},
{
name => 'queen check must be blocked',
fen => 'r3k2Q/p1ppqp2/bn2p1pb/3PN3/1p2P3/2N4p/PPPBBPPP/R3K2R b KQq - 0 2',
moves => [qw(h6f8 e7f8)],
},
{
name => 'capture queen giving check',
fen => 'r4rk1/p1ppqpbQ/bn2pnp1/3PN3/1p2P3/2N5/PPPBBPPP/R3K2R b KQ - 1 2',
moves => [qw(g8h7 f6h7)],
},
{
name => 'kiwipete perft bug',
t/04move-generator.t view on Meta::CPAN
moves => [qw(e1g1 e1d1 e1d2 e1e2 e1f2 e1f1
a3a4 h3h4 a1b1 a1c1 a1d1 h1g1 h1f1)],
},
{
name => 'lost black queen-side castling',
fen => 'r3k2r/p6p/p6p/8/8/P6P/P6P/R3K2R b KQk - 0 1',
moves => [qw(e8g8 e8d8 e8d7 e8e7 e8f7 e8f8
a6a5 h6h5 a8b8 a8c8 a8d8 h8g8 h8f8)],
},
{
name => 'white king blocked for king-side castling',
fen => 'r3kn1r/p6p/p6p/8/8/P6P/P6P/R3KN1R w KQkq - 0 1',
moves => [qw(e1c1 e1d1 e1d2 e1e2 e1f2
a3a4 h3h4 a1b1 a1c1 a1d1 h1g1
f1d2 f1e3 f1g3)],
},
{
name => 'black king blocked for king-side castling',
fen => 'r3kn1r/p6p/p6p/8/8/P6P/P6P/R3KN1R b KQkq - 0 1',
moves => [qw(e8c8 e8d8 e8d7 e8e7 e8f7
a6a5 h6h5 a8b8 a8c8 a8d8 h8g8
f8d7 f8e6 f8g6)],
},
{
name => 'white king blocked for queen-side castling',
fen => 'r2nk2r/p6p/p6p/8/8/P6P/P6P/R2NK2R w KQkq - 0 1',
moves => [qw(e1g1 e1d2 e1e2 e1f2 e1f1
a3a4 h3h4 a1b1 a1c1 h1g1 h1f1
d1b2 d1c3 d1e3 d1f2)],
},
{
name => 'black king blocked for queen-side castling',
fen => 'r2nk2r/p6p/p6p/8/8/P6P/P6P/R2NK2R b KQkq - 0 1',
moves => [qw(e8g8 e8d7 e8e7 e8f7 e8f8
a6a5 h6h5 a8b8 a8c8 h8g8 h8f8
d8b7 d8c6 d8e6 d8f7)],
},
{
name => 'white king target blocked for king-side castling',
fen => 'r3k1nr/p6p/p6p/8/8/P6P/P6P/R3K1NR w KQkq - 0 1',
moves => [qw(e1c1 e1d1 e1d2 e1e2 e1f2 e1f1
a3a4 h3h4 a1b1 a1c1 a1d1
g1e2 g1f3)],
},
{
name => 'black king target blocked for king-side castling',
fen => 'r3k1nr/p6p/p6p/8/8/P6P/P6P/R3K1NR b KQkq - 0 1',
moves => [qw(e8c8 e8d8 e8d7 e8e7 e8f7 e8f8
a6a5 h6h5 a8b8 a8c8 a8d8
g8e7 g8f6)],
},
{
name => 'white king target blocked for queen-side castling',
fen => 'r1b1k2r/p6p/p6p/8/8/P6P/P6P/R1B1K2R w KQkq - 0 1',
moves => [qw(e1d1 e1d2 e1e2 e1f2 e1f1 e1g1
a3a4 h3h4 a1b1 h1g1 h1f1
c1b2 c1d2 c1e3 c1f4 c1g5 c1h6)],
},
{
name => 'black king target blocked for queen-side castling',
fen => 'r1b1k2r/p6p/p6p/8/8/P6P/P6P/R1B1K2R b KQkq - 0 1',
moves => [qw(e8d8 e8d7 e8e7 e8f7 e8f8 e8g8
a6a5 h6h5 a8b8 h8g8 h8f8
c8b7 c8d7 c8e6 c8f5 c8g4 c8h3)],
},
{
name => 'white rook blocked for queen-side castling',
fen => 'rn2k2r/p6p/p6p/8/8/P6P/P6P/RN2K2R w KQkq - 0 1',
moves => [qw(e1g1 e1d1 e1d2 e1e2 e1f2 e1f1
a3a4 h3h4 h1g1 h1f1
b1c3 b1d2)],
},
{
name => 'black rook blocked for queen-side castling',
fen => 'rn2k2r/p6p/p6p/8/8/P6P/P6P/RN2K2R b KQkq - 0 1',
moves => [qw(e8g8 e8d8 e8d7 e8e7 e8f7 e8f8
a6a5 h6h5 h8g8 h8f8
b8c6 b8d7)],
},
# King moves.
{
name => 'lone white king on e2',
fen => '8/3k4/8/8/8/8/4K3/8 w - - 0 1',
moves => [qw(e2f2 e2f1 e2e1 e2d1 e2d2 e2d3 e2e3 e2f3)],
( run in 0.546 second using v1.01-cache-2.11-cpan-49f99fa48dc )