CQLi provides facilities to explore positions that do not appear in the PGN file. These imaginary positions may be the result of making hypothetical moves (via the speculative move filter) or by arbitrarily adding or removing pieces from a position using the imagine filter. Imaginary positions are transient by default but the saveposition filter allows imaginary positions to be saved and revisited later in the same game. The currentmutation filter provides a string representation of the current changes in effect for an imaginary position. Imaginary positions may be queried like any other position and support a variety of applications, especially as related to the creation of chess puzzles.
The Speculative move Filter
The move filter as previously described does not actually make moves or change the state of the board, it simply reports on the moves that were made or available in a position. The speculative form of the move filter allows exploration of positions that result from making legal or pseudolegal moves on a temporary copy of the current position. A move filter becomes a speculative move filter by appending a : to the filter followed by any target filter. A speculative move filter iterates over each of the moves matching the criteria of the move filter, performs the move at the current position resulting in an imaginary position, and evaluates the target filter at that position.
The result of the speculative move filter has the same type as the normal move filter but represents the moves for which the target filter matched the resulting imaginary position(s). The speculative version of the move filter also accepts an optional all parameter. If the all parameter is specified, the speculative move filter instead yields a Boolean value that is true if the target filter matched for every move considered and false otherwise. If count and all are combined, the result is the number of considered moves if the target filter matched every one of them and None otherwise.
For example, the query:
move legal count : matewill yield the number of legal moves that deliver checkmate at the current position. The query:
not mate
parent : move legal : matewill find positions where a player missed a mate in one while the following query will find positions where the player who missed the mate in one went on to lose the game:
not mate
parent : {move legal : {mate flipcolor {wtm 1-0}}}The move filter mode may be ordinary, legal, pseudolegal, or reverse. A move with a mode of previous may not be a speculative move filter, to achieve a similar effect (for non-imaginary positions), use:
parent :target-filter
An ordinary speculative move filter considers no moves when evaluated in imaginary positions.
The imagine Filter
The imagine filter can be used to add, remove, or swap pieces in a position as well as change the side to move. The changes take place in an imaginary position for which the provided target filter is executed. The imaginary position is then discarded. The syntax of the imagine filter is:
imagineimagine-specifier[...]:filter
An imagine-specifier is one of:
piecepiece-designator-->set
swapsquare1square2
sidetomove{black|white|reverse}
The piece placement specifier uses the piece keyword followed by a single piece designator (which may not contain a square designator), the --> symbol and an arbitrary Set filter. The specified piece type is placed onto each square in set, pieces previously occupying the squares are removed. New piece IDs are assigned to pieces placed in this manner. Pieces may be removed by using _ as the piece-designator. If set is empty, no pieces are placed by this specifier before the target filter is evaluated.
The swap placement specifier consists of the swap keyword followed by two Set filters. If each of the set filters contain exactly one square, the pieces at these two squares are swapped, and the piece IDs of the affected pieces are maintained through the swap. If exactly one of the squares is empty, the piece at the other square is moved to the empty square. If either square1 or square2 does not consist of exactly one square, or both squares are empty, no swap is performed by this specifier prior to the target filter being evaluated.
The side to move specifier consists of the sidetomove keyword followed by exactly one of black, white, or reverse and sets the side to move to black, white, or the opposite side, respectively.
Multiple imagine-specifiers may be specified in a single imagine filter. For example, the below query will remove all queens and swap the black and white kings:
imagine piece _ --> [Qq] swap K k : ...The imagine filter has many applications but is particularly well-suited to solving, creating, and verifying various types of chess puzzles.
Imaginary Positions
Imaginary positions modify the board state of the current position (the changes are undone after the target filter is evaluated) but do not create new game tree nodes and are instead associated with the original position’s game tree node. As such, the value returned by game tree filters (including depth, distance, variation, mainline, ancestor, descendant, lca, child, parent, terminal, virtualmainline, and comparison operators applied to Position operands) on a imaginary position is the same as if the filter were evaluated with the original position from which the imaginary position was created. The value of filters that operate on the state of the board (including ply, movenumber, btm, wtm, attackedby, attacks, check, connectedpawns, fen, isolatedpawns, piece designators, mate, move, passedpawns, piece, square, pin, power, ray, and zobristkey) are affected by imaginary positions.
Use of the comment filter in an imaginary position will add a comment to the original position, even if the imaginary position occurs in the game. Similarly, the originalcomment filter will yield the comment associated with the original position when evaluated with an imaginary position. Since imaginary positions do not have a corresponding game tree node, they never appear in the PGN output produced by CQLi.
The saveposition Filter
Imaginary positions created by a speculative move or imagine filter are typically discarded after evaluating the target filter. The saveposition filter can be used to save an imaginary position until the end of the game. The saveposition filter yields the saved position which may subsequently be revisited using the with-position filter (:). Each saved position has its own position ID but saved positions are never implicitly accessed by CQLi. In particular, saved imaginary positions are not visited during the main game loop or during evaluation of the find, echo, move, or consecutivemoves filters. When the current position is not an imaginary position, saveposition simply yields the current position.
The currentmutation Filter
A position that appears in the PGN game text (including variations) is referred to as an original position. The result of the saveposition filter applied to an imaginary position is a hypostatized position. A real position is any original or hypostatized position. An imaginary position consists of one or more mutations applied to an underlying real position. For example, if a position contains 3 white pawns, the position formed by the filter:
imagine piece R --> P : ...will consist of 3 mutations, one for each pawn replacement.
The currentmutation filter is a String filter that yields an ordered, textual articulation of the current mutations in an imaginary position. Each mutation is either a move, piece placement, piece swap, or sidetomove change. Move mutations occur only as a result of the speculative move filter and may be normal moves or reverse moves, other mutations occur exclusively via the imagine filter. Each type of mutation is articulated as shown in the below table.
| Mutation Type | Articulation Description | Example |
|---|---|---|
| Normal Move | Typical SAN move depiction. | 1.Bf4 |
| Reverse Move | ~ followed by piece that moved, the starting square and the destination square. If this is a capture, the captured piece appears in parentheses after the capture indicator. |
1.~Bg5x(Q)c1 |
| Piece Placement | The placed piece character followed by @ and the destination square. If the square was already occupied, this is followed by x and the piece that was replaced. The entire mutation is enclosed by angle brackets. |
<R@d8><q@c7xp> |
| Piece Swap | The piece character and square of each piece involved in the swap, separated by ^. The entire mutation is enclosed by angle brackets. |
<Nb1^rh8> |
| STM Change | <&wtm> if the new side to move is white, otherwise <&btm>. |
<&btm> |
Note that within piece placement and piece swap mutations, an uppercase piece character indicates a white piece while a lowercase piece character indicates a black piece so e.g. <Nb1^rh8> indicates a swap between a white knight residing on b1 and a black rook residing on h8. In normal and reverse moves, pieces are always presented in uppercase, the color of the involved pieces may be deduced from the move number indicator. For example, in 1...Rd1 the piece that moved must be a black rook since the move was made by Black, as indicated by the ... in the move indicator.
If the current position does not involve any mutations, the result of the currentmutation filter is an empty string. Note that a position returned by saveposition is a real position and does not contain any mutations. To capture the textual mutations of a position, the currentmutation filter must be used with the imaginary position, not the saved position.
The legalposition and reachableposition Filters
The legalposition and reachableposition filters perform an analysis of the current board state in order to determine whether the position is legal or reachable, respectively. This analysis is static, i.e. previous and future positions occurring in the game are not considered. Positional legality is a simple analysis that checks for too many pieces, too many/few kings, etc. Positional reachability is a complex topic that involves often-subtle details of the position and forms the basis of many retrograde puzzles. The reachableposition filter uses a variety of heuristic analysis algorithms in order to both determine reachability and explain why a particular unreachable position could not have occurred in an actual game. Both filters are useful when performing board state transformations using the imagine filter which can transform a legal position to an illegal or unreachable position. The reachableposition filter is also useful when solving or constructing chess puzzles and studies as well as detecting existing puzzles and studies that are unsound due to unreachable starting positions (which violates the WFCC Codex of Chess Composition).
The legalposition Filter
A position is said to be illegal if the placement of the pieces in the current position violates the rules of chess. In particular, all of the following must be true in any legal position:
- There is exactly one white king and one black king on the board.
- There are no more than 8 pawns of each color on the board.
- There are no pawns on the first or last rank.
- There are no more than 16 white pieces or 16 black pieces on the board.
- The opposing king is not in check.
- If the position is the starting position, it must be White to move.
- The current side-to-move’s king is not attacked more than twice.
The legalposition filter evaluates to false if any of the above constraints are violated in the current position, otherwise the filter yields true.
When the legalposition filter appears as a top-level unparenthesized argument to the str, message or comment filters, the result is a textual portrayal of the analysis. If legalposition would evaluate to true, the result is portrayed as “<Legal position>”. Otherwise the result is portrayed as "<Illegal position:explanation> where explanation is a semicolon separated list of reasons articulating the illegality of the position. The reasons are provided below where Color is one of White or Black, Count is an integer, and Set is a set of squares. A short explanation follows each of the reasons, this explanation is not included in the analysis portrayal.
ColorKing not present on board
The board is missing a king of the specified color. Every legal chess position must include exactly one white king and one black king. The game ends upon imminent capture of one of the kings but such a capture does not ever actually take place. If a king is under attack, no move that leaves the king attacked is legal.
MultipleColorKings on board (Set)
The board has more than one king of the specified color. Exactly one king of each color must be on the board at all times. Pawns cannot promote to kings and there is no mechanism by which two or more kings of the same color can be present on the board.
Both sides are in check
The white king and black king are both in check. It is not legal to make a move that places the player’s own king in check. Additionally, if your king is put into check by the opposing player, no move that leaves the king in check is a legal response. For this reason, two kings may never be adjacent to each other (such a condition will be diagnosed by this message).
Opposite side (Color) is in check
The opposing side is in check. Since it is not legal to place or leave an attacked king in check, it is not possible for the opposing king to be in check when it is the other player’s turn (the game ends immediately if the king cannot be removed from check).
Pawn(s) present on Rank 1 (Set)Pawn(s) present on Rank 8 (Set)
One or more pawns of the specified color was found on the first or last rank. The starting position of all pawns is the second rank. Since pawns cannot move backwards, there is no legal way for a pawn to reach the first rank. Pawns that reach the last rank undergo immediate pawn promotion in which they are exchanged for a knight, bishop, rook, or queen; it may not remain a pawn. While playing over the board, the pawn may advance to the 8th rank temporarily until it is replaced by the promoted piece, the move does not end until after the replacement is made so a board position that has a pawn on the last rank is not valid.
Too manyColorPawns (Count) on board (Set)
The side of the specified color has more than 8 pawns. Each side starts with 8 pawns and since there is no way to acquire additional pawns during the game, it is not legal to have more than this many pawns.
Too manyColorpieces (Count) on board
The total number of pieces for the specified side, excluding the king, exceeds 15. Each side starts with 15 pieces plus a king. While a pawn may be exchanged for a different piece during pawn promotion, the number of pieces never increases during play.
Black to move in starting position
The position is the starting position but it is Black to move. In the starting position, only the pawns and knights have legal moves available to them. Since pawns cannot move backwards, it is not possible that a pawn has been moved. Knights can move in the starting position and then back again but since the square color of the knight changes with each move, doing so would require an even number of moves made by both sides to return to the starting position in which it would still be White to move instead of Black. There is no sequence of legal moves that can reach the starting position with Black to move.
ColorKing on squareSquareis attacked byCountpieces (Set)
The specified king is attacked by more than two opposing pieces. The only situation by which a king may be checked by two attackers is in a discovered check where both the discovered attacker and the revealing piece check the king. This can happen as a result of en passant or pawn promotion but it never results in more than two separate pieces checking the king. The only way a triple check would be possible is if the king was already in check when a move added additional attackers. Since no move that leaves a king in check is legal, this is not possible. The squares of all of the attackers are provided in
Set.
For example, if the white rook on a1 is replaced with a white pawn in the starting position, the textual portrayal of legalposition would be:
<Illegal position: Pawn present on Rank 1 (square a1); Too many White
Pawns (9) on board (squares a1, a2, b2, c2, d2, e2, f2, g2, h2)>
Position Legality with Variants
Position legality is only applicable to variants that follow the relevant standard chess rules. In particular, legalposition can be used to determine the legality of positions in Standard chess as well as Chess960, Three-check, and King of the Hill variants but will not yield expected results for other variants. For example, the Horde variant places white pawns on the first rank in the starting position but such positions will be considered illegal by the legalposition filter.
The reachableposition Filter
A position is said to be reachable if it is possible for the position to be obtained by some sequence of legal moves from the traditional starting position of Standard chess. This filter performs the same checks as legalposition (and will evaluate to false in the same situations that legalposition will) as well as more sophisticated analysis techniques in order to determine reachability. The filter yields false if the analysis determines the position is unreachable and true otherwise.
The reachableposition filter will never produce false positives, i.e. it will never evaluate to false for a position that can be reached as the filter yields false only when it can deductively prove a position is not reachable. It is possible, however, for the reachableposition filter to produce false negatives, i.e. evaluate an unreachable position as reachable. In practice, the overwhelming majority of unreachable positions are detected by the reachableposition filter but there are a small number of specific situational themes that the current implementation of this filter will not yet detect as unreachable. If you encounter such a situation, the author would be happy to know about it.
When the reachableposition filter appears as a top-level unparenthesized argument to the str, message or comment filters, the result is a textual portrayal of the reachability analysis. If reachableposition would evaluate to true, the result is portrayed as “<Reachable position>”. Otherwise the result is portrayed as "<Unreachable position:explanation> where explanation is a semicolon separated list of reasons articulating the analysis result. The reasons may include any of those described above for the legalposition filter as well as the reachable-position-specific reasons provided below where Color is one of White or Black, Count is an integer, Squarecolor is one of light or dark and Set is a set of squares. Some articulations are accompanied by bracketed supplemental information that explain how correlated sub-conditions were used in the ultimate unreachable determination. A short explanation follows each of the reasons, this explanation is not included in the analysis portrayal.
ImpossibleColorPawn structure (Set)
The pawn structure of the specified color is not feasible as no sequence of pawn moves or captures could have produced the current pawn structure. The pawns participating in the unfeasible portion of the pawn structure are reported bySet.
The above position (composed by Alexey Troitzky, 1896) will be reported as:
Impossible White Pawn structure (squares g2, h2, d3, h3)
as it is not possible to achieve the formation of pawns occupied by the specified squares.
ColorPawn structure impliesCountcapture(s) butColoris only missingCountpieces
The pawn structure of the specified side is only achievable through the capture of at leastnpieces but the opponent is missing fewer than this number of pieces making the pawn structure impossible.
The above position (composed by Siegfried Hornecker, 2007) will be reported as:
White Pawn structure implies 5 captures but Black is only missing 4 pieces
as the fewest number of captures by White pawns needed to reach the pawn structure is five but no more than 4 captures could have been made as Black still has 12 pieces on the board.
All ofColor's missing pieces were captured byColorPawns currently on the board but missing trappedSquarePiececould not have been captured by one of these Pawns
One side has a pawn structure that implies a specific number of pawn captures and the opponent is missing exactly this many pieces meaning that all of the opponents missing pieces had to have been captured by pawns. However, the opponent is a missing queen, rook, or bishop (specified byPiece) that could not possibly have been captured by a pawn as the starting square of this piece is blockaded by friendly pawns preventing the piece’s escape or its capture by an enemy pawn.
The above position (composed by Filip Bondarenko, 1962) will be reported by as:
All of Black's missing pieces were captured by White Pawns currently on the board but missing trapped f8 Bishop could not have been captured by one of these Pawns
The white pawn structure implies 5 captures and there are 5 missing black pieces, all of which therefore must have been captured by pawns. One of these missing black pieces is the dark-square bishop which could not have escaped from its starting square of
f8to be captured by one of White’s pawns.
ColorKing and Queen are swapped
The king and queen of the specified color are swapped respective to the starting position but no sequence of legal moves could have lead to this position as the necessary clearance is not present. Namely, thec-file andf-file bishops are on their starting squares as are theb-g-file pawns.Impossible position forColorKing onSquarewho has no legal path to this square
A king of the specified color was found on a square for which it could not possibly have reached by any series of legal moves owing to unmoved opposing pawns which attack squares that the king would have had to traverse to reach its current position. Specifically, a white king on ranks 7 or 8 or a black king on ranks 1 or 2 was detected while there are opposing pawns attacking every square on their own third rank.Position impliesCountColorPawn promotion(s) but onlyCountpromotion(s) are possible
At least the specified number of promotions for the specified color must have occurred to achieve the current position but this many promotions are not possible due to insufficient missing pawns of the promoting side.
Supplemental information detailing why the position implies a certain number of promotions along with an explanation of why the requisite number of promotions is impossible is included.
The above position (composed by Vladimir Neishtadt, 1988) will be reported as:
Position implies 1 White Pawn promotion but no promotions are possible [Presence of 1 dark-square White Bishop (square h6) implies at least 1 promotion] [Missing dark-square White Bishop could not have escaped starting square (c1)] [White is not missing any Pawns]
The dark-square white bishop on
h6cannot be the one that started onc1as the pawns onb2andd2would have prevented its escape, therefore the bishop must be the result of a pawn promotion. White, however, is not missing any pawns so it could not have promoted any of them. This logical contradiction can only mean the position is unreachable.
The above position (composed by Ottó Bláthy, 1890) will be reported as:
Position implies 1 Black Pawn promotion but no promotions are possible [Presence of 2 Black Rooks (squares c8, d8) implies at least 1 promotion] [Missing Kingside Black Rook could not have escaped confined area (squares h7, g8, h8)] [Black is not missing any Pawns]
Black has two rooks in this position. The black rook that started on square
h8could not have escaped the area highlighted in blue which is blockaded by the black bishop (trapped by its own pawns one7andg7) and the pawns ong7andh6. At least one of the two black rooks must therefore have been promoted but since Black is not missing any pawns no promotions could have actually occurred.
The above position (composed by Anatoly Matsukevic, 1989) will be reported as:
Position implies 9 Black Pawn promotions but only 8 promotions are possible [Presence of 6 Black Knights (squares g3, g5, h6, c7, e7, f8) implies at least 4 promotions] [Presence of 6 light-square Black Bishops (squares g2, g4, g6, b7, d7, f7 ) implies at least 5 promotions] [Black is only missing 8 Pawns]
Since Black (presumably) only started with two knights, the presence of 6 of them in this position would have required at least four promotions. There are six bishops but since they are all light-square bishops, at least five of them must have been the result of pawn promotions. Since each side starts with only eight pawns, the requisite number of nine promotions to reach this possible is not possible.
Position impliesCountColorpromotion(s) but promoting this many pawns would require too many captures
At least the specified number of promotions for the specified color must have occurred to achieve the current position but this many promotions are not possible because the smallest number of captures needed to promote this many pawns exceeds the number of missing opposing pieces that could have been captured by such pawns. Supplemental information detailing why the position implies a certain number of promotions along with an explanation of why the requisite number of promotions is impossible is included.
The above position will be reported as:
Position implies 1 White promotion but promoting this many pawns would require too many captures [Presence of 1 dark-square White Bishop (square e7) implies at least 1 promotion] [Missing dark-square White Bishop could not have escaped starting square (c1)] [Existing White pawn structure already implies 1 capture] [Promotion of 1 White pawn requires at least 3 additional captures] [Black is only missing 3 pieces] [Promotion cost calculated using pawn start squares a2, c2, e2, f2, g2, h2 and promotion files a, b, c, d, e]
The dark-square white bishop that started on
c1could not have escaped as it was trapped by its own pawns onb2andd2, therefore the white bishop one7must be a promoted pawn. Black is missing 3 pieces, one of which was captured by the pawn onb3which only leaves two captures unaccounted for. Pathing analysis can determine that amongst any of the potentially-promoted pawns, at least 3 captures would be necessary to reach the promotion rank. For example, the pawn that started onh2would have to make at least 3 captures to get around the black pawn blockade on rank 7. In the case of theh2pawn an additional capture would be required to promote on a dark square. The combination of this information is used to determine the position is unreachable.
Impossible check ofColorKing
The specified king is in check but there is no way the current position could have been reached as all previous position candidates that could lead to this position are non-viable. Examples of impossible checks include double check via two bishops, two knights, two pawns, or pawn plus bishop/knight and checks by one or two pieces that give check but have no reverse moves which lead to a position where the same king would not have already been in check, possibly by a different piece.
In the above position, there is no move that the black rook could have made to check the white king for which it would not already have been attacking the king. The last move by Black could not have been
O-Osince the black king would have had to pass through check by the white bishop ond6. If the white bishop was instead onb6, the position would not be reported as unreachable as Black could have just playedO-Oas the bishop would no longer attack the squares that would need to be traversed during castling.
Coloris missingSquarecolor-square Bishop but allColorcaptures occurred onSquarecolorsquares (Set)
The specified color is missing a bishop but it can be determined that all captures made so far were by pawns on squares of the opposite color of the missing bishop so there is no accounting for the missing bishop.
The above position will be reported as:
Black is missing light-square Bishop but all White captures occurred on dark squares (squares c3, g3)
Black is missing two pieces (a pawn and a light-square bishop) which means that White has performed two captures. From the doubled white pawns on the
candgfiles it can be deduced that both captures occurred on dark squares. Black’s missing pawn could have been captured on a dark square but Black’s missing light-square bishop could not.
Inconsistent color symmetry forColorto move
If all pawns are present on both sides, and theb-gpawns are all in their starting positions, and thea&hpawns are either in their starting positions or advanced one square, then the only other pieces that could have moved are the knights and rooks. The knights always change color when they move and in the above pawn configuration, a rook can only move one square at a time in which case the square it occupies also changes color for every move. This means that the color symmetry of occupied squares must be preserved when White has the move (the number of occupied light squares equals the number of occupied dark squares) and must be broken when Black has the move. If this is not the case, then the position was not reached via any series of legal moves where White moved first.
The above position satisfies the criteria needed to make a color symmetry assessment as described above. It is Black to move (Black is in check) but the number of occupied light squares equals the number of occupied dark squares which should only be true when it is White to move meaning that this position is not reachable.
Impossibly trappedColorBishop on squareSquare
Bishops on their own first rank, except forc-file andf-file bishops, cannot have pawns of their own color on the second rank in adjacent files blocking them as there would be no way for the bishop to arrive at the square. Similarly, a bishop cannot be at the last rank if there are enemy pawns that prevent it from escaping unless it could have been a promotion in which case there must be a hole in the enemy pawns on the seventh rank that would have allowed such a promotion to occur.Impossibly trappedColorRook on squareSquare
A Rook was found on the second (seventh) rank with a White (Black) Pawn in front of it on the third rank, a Bishop behind it on the first rank, and White (Black) Pawns on the second (seventh) rank diagonally adjacent to the Bishop, trapping it. Regardless of the colors of the Rook and Bishop, there is no way for the Rook to have become trapped in this way.Impossible escaped/entrenchedColorRook(s) (Set)
If all of White’s pawns are on ranks 2-3 (or all of Black’s pawns are on ranks 6-7), with a pawn in every file, that same side’s rooks must all either be on ranks 1-2 (7-8 for Black) or captured. Since no pawns are missing in this scenario, promotion is not a possibility. Additionally, any promoted opposing rooks must reside behind the pawn blockade as they could not have escaped the pawn structure after promoting.
Similarly, if all of White’s pawns are on ranks 2-3 (or all of Black’s pawns are on ranks 6-7), with a pawn in every file, there can be no enemy rooks on Ranks 1-2 (7-8 for Black) without promotion which requires a missing pawn plus the capture of at least one piece (so that the pawn could have made it past the pawn block).
Position Reachability with Variants
Position reachability is applicable only to variants that both follow the standard rules of chess and utilize the traditional starting position. In particular, reachableposition will not correctly determine positional reachability for Chess 960 games that do not utilize the traditional starting position. In addition to Standard chess, reachableposition may be successfully used with the Three-check, and King of the Hill variants.
Filter Semantics in Illegal Positions
CQLi does not impose any artificial positional constraints and supports query evaluation (including move generation provided by the move filter) with well-defined behavior for positions that violate basic chess principles, i.e. those for which the legalposition filter will return false. Such illegal positions may be obtained through use of the imagine filter or may be specified via the FEN tag of PGN files. CQLi aims to consistently exhibit sensible and practical semantics for filters in such situations. Most filters are not affected by the legality of a position, the remainder of this section enumerates those that are.
The following situations will affect the result of the legalposition filter (as well as the reachableposition filter) but do not impact the behavior of other filters:
- The presence of more than 8 pawns of the same color.
- The presence of more than 16 pieces of the same color.
- Black to move in the starting position.
Unreachable positions detected by the reachableposition filter that are not deemed illegal by the legalposition filter do not affect the behavior of other filters.
Kings
Missing Kings
One or both kings may be missing from the board. The effects of missing kings are:
Null moves and castling moves are both king moves, as such they are not available if there is no king of the current color on the board. Such moves will not be generated by the
movefilter and the presence of such moves in a PGN file for such a position will be rejected in the same way that any other illegal move is.A side with no king may not be subject to check or checkmate, consequently the
checkandmatefilters will always returnfalsewhen evaluated in a position where the side to move has no king. The lack of a king on the opposing side has no effect on the operation of these filters.In the Atomic variant, if the current side is missing a king it is assumed that the king exploded during the previous move and that the game is over, being a loss for the current side to move. As such, the
variantlossfilter will return true and move generation will not produce any moves for either side in such a position.
Extra Kings
One or both sides may have multiple kings on the board. The effects of extra kings are:
Castling moves are not available to a side that has multiple kings and the
movefilter will not produce castling moves in such a position. Reverse move generation will currently produce reverse castling moves for positions with multiple kings although this behavior may change in a future version of CQLi.When multiple kings of the same color are present on the board, none of the kings of that color are subject to check or mate, regardless of variant. This means that move generation may produce moves that place the current side’s king(s) under attack and the
checkandmatefilters will always returnfalsewhen evaluated for a side that has multiple kings. Duplicate kings may also be captured.
Opposite King in Check
If the opposite side’s king is in check it may be captured on the current move, and such capturing moves will be generated by the move filter.
Pawns
Pawns on the First Rank
Pawns on their own first rank may move one or two spaces forward or capture diagonally, just as a pawn on the second rank may. A pawn that moves two spaces forward from the first rank does not set the en passant square and may not be subsequently captured en passant. A pawn that starts on the first rank and subsequently moves forward to the second rank is not distinguished from a pawn that began on the second rank, e.g. it may then move forward two spaces from the second rank and be subject to en passant capture. Note that the behavior of pawns on the first rank matches that of the Horde variant where White starts with pawns on ranks 1-5.
Pawns on the Last Rank
Pawns on their last rank may not move or promote on a later move. They may be captured by an opposing piece. The move filter will never produce a move that causes a pawn to move to its last rank without being promoted to another piece.