Games-Chess-Referee
view release on metacpan or search on metacpan
doc/Rules.pod view on Meta::CPAN
=head2 The King
The king moves like the queen, except that it can only move one space at a time.
a b c d e f g h
+-----------------+
8 | . . . . . . . . | 8
7 | . . . . . . . . | 7
6 | . . . . . . . . | 6
5 | . . # # # . . . | 5
4 | . . # K # . . . | 4
3 | . . # # # . . . | 3
2 | . . . . . . . . | 2
1 | . . . . . . . . | 1
+-----------------+
a b c d e f g h
There are two special moves available to the king, called B<castling>. If the king has not
moved from its home space, and one of the rooks has not moved from its home square, castling
on that side may be possible. Provided that the spaces between the king and the rook in
question are empty, and that none of the spaces, including the king's and the rook's current
locations, are guarded by enemy pieces, th king is permitted to move I<two> spaces in the
direction of the rook, and the rook `simultaneously' (in the same ply) takes up the space
between the king's old and new locations (`hopping' over the king).
The figure below shows the setup before and after B<castling short>, or B<castling kingside>.
a b c d e f g h a b c d e f g h
+-----------------+ +-----------------+
8 | . . . . . . . . | 8 8 | . . . . . . . . | 8
7 | . . . . . . . . | 7 7 | . . . . . . . . | 7
6 | . . . . . . . . | 6 6 | . . . . . . . . | 6
5 | . . . . . . . . | 5 5 | . . . . . . . . | 5
4 | . . . . . . . . | 4 4 | . . . . . . . . | 4
3 | . . . . . . . . | 3 3 | . . . . . . . . | 3
2 | . . . . . . . . | 2 2 | . . . . . . . . | 2
1 | . . . . K . . R | 1 1 | . . . . . R K . | 1
+-----------------+ +-----------------+
a b c d e f g h a b c d e f g h
The figure below shows the setup before and after B<castling long>, or B<castling queenside>.
a b c d e f g h a b c d e f g h
+-----------------+ +-----------------+
8 | . . . . . . . . | 8 8 | . . . . . . . . | 8
7 | . . . . . . . . | 7 7 | . . . . . . . . | 7
6 | . . . . . . . . | 6 6 | . . . . . . . . | 6
5 | . . . . . . . . | 5 5 | . . . . . . . . | 5
4 | . . . . . . . . | 4 4 | . . . . . . . . | 4
3 | . . . . . . . . | 3 3 | . . . . . . . . | 3
2 | . . . . . . . . | 2 2 | . . . . . . . . | 2
1 | R . . . K . . . | 1 1 | . . K R . . . . | 1
+-----------------+ +-----------------+
a b c d e f g h a b c d e f g h
=head2 Global Considerations
Chess is an idealization of a battle. Each of the pieces has distinct capabilities that
must be accounted for in formulating strategies and tactics. When examining a board position
and selecting a move, it is important to pay attention to the guards and threats present before
and resulting from the move. A piece guards a square if the piece could capture an enemy piece
on that square on the next ply, not accounting for the fact that the enemy piece may not be able
to actually execute the capture due to constraints on its own king's disposition.
It is illegal to execute a ply that leaves the king on a guarded square. A player that manages
to execute a legal ply that causes the opposing king to be on a guarded square has put the
other player in `check'.
For example, in this board position:
a b c d e f g h
+-----------------+
8 | k . . Q . . . R | 8
7 | . . . . . . . . | 7
6 | . . . . . . . . | 6
5 | . . . . . . . . | 5
4 | . . . . . . . . | 4
3 | . . . . . . . . | 3
2 | . . . . . . . . | 2
1 | B . . . K . . . | 1
+-----------------+
a b c d e f g h
the move 1. Ke1-d1 is not legal, despite the fact that the response 1. ... Qd8xd1 is not
credible in the sense that the queen is pinned at d8 by the white rook on h8. It is sufficient
that the queen is guarding the square d1 for it to be illegal for the king to move there.
There are three ways to get one's king out of check:
=over 4
=item 1.
Capture the piece that guards the king's space. If it happens that there is more than
one such piece (called double check), this option is not available.
=item 2.
Interpose a piece. If the opponent's piece is on a neighboring square, this option is
not available.
=item 3.
Move the king to an empty unguarded square.
=back
Since it is not permitted to have one's king on a guarded square,
the other player must respond by securing its king on its next ply, regardless of any other
opportunites there may be on the board. If there are no legal plies available that accomplish
this, the player has lost, and the situation is called `checkmate'. If a player is not in check,
but still has no legal plies, then it is `stalemate', which is the Chess term for a tie game.
The king may never be exposed to the gaze of another piece. So, each potential move must
be screened first to make sure that after it is executed, no enemy piece guards the king's
square. Even if it would be illegal for the other piece to move away from its present
location on the next ply (meaning that although the piece guards the square, it does not
threaten it)
( run in 0.471 second using v1.01-cache-2.11-cpan-5837b0d9d2c )