Additions:
{{image class="right" alt="Quadrupled leads to two tripled pawns" title="Quadrupled leads to two tripled pawns" url="images/CQL-QuadTo2Tripled.jpg"}}It turns out that it is actually possible to construct such a position. The diagram shows an example. There are no tripled pawns on the board. It's white's move and if he plays 1. exd5 then he has tripled pawns on both the d- and the e-file. It is even possible to construct a position without tripled pawns where a single move creates three different instances of tripled pawns!
Deletions:
{{image class="right" alt="Quadrupled leads to two tripled pawns" title="Quadrupled leads to two tripled pawns" url="images/CQL-QuadTo2Tripled.jpg"}} Note that in the last case it is theoretically possible that the capture creates two different tripled pawns. The diagram shows an example. There are no tripled pawns on the board. It's white's move and if he plays 1. exd5 then he has tripled pawns on both the d- and the e-file. It is even possible to construct a position without tripled pawns where a single move creates three different instances of tripled pawns!
Additions:
====A general solution?====
Again, this query can be simplified by using the fact that tripled pawns cannot arise unless the previous position did //not// have tripled pawns of the same color on the file in question:
This is a nice and simple query that looks like a general solution to the problem of finding chessgames with two different tripled pawns. Surprisingly there is one very special situation where it fails.
====The exception====
The key to understanding why the "almost general" CQL query can fail is the following line from the query:
:matchcount 2 1000
%%
It dictates that in order for a game to match the query the two tripled pawns must arise in different positions (i.e. at different time) in the game. The query fails if it is possible that two different tripled pawns of the same color can arise //at the same time// in the game. So the question is if //a single move// can create two different tripled pawns.
Deletions:
====The general solution====
Again, this query can be simplified by using the fact that tripled pawns cannot arise unless the previous position did //not// have tripled pawns on the file in question:
Additions:
{{image class="right" alt="Quadrupled leads to two tripled pawns" title="Quadrupled leads to two tripled pawns" url="images/CQL-QuadTo2Tripled.jpg"}} Note that in the last case it is theoretically possible that the capture creates two different tripled pawns. The diagram shows an example. There are no tripled pawns on the board. It's white's move and if he plays 1. exd5 then he has tripled pawns on both the d- and the e-file. It is even possible to construct a position without tripled pawns where a single move creates three different instances of tripled pawns!
Deletions:
{{image class="right" alt="Quadrupled leads to two tripled pawns" title="Quadrupled leads to two tripled pawns" url="images/CQL-QuadTo2Tripled.jpg"}} All these cases result in a new instance of tripled pawns in the game. Note that in the last case it is theoretically possible that the capture creates two different tripled pawns. The diagram shows an example. There are no tripled pawns on the board. It's white's move and if he plays 1. exd5 then he has tripled pawns on both the d- and the e-file. It is even possible to construct a position without tripled pawns where a single move creates three different instances of tripled pawns!
Additions:
All these cases result in a new instance of tripled pawns in the game. We need to come up with a CQL query that covers these cases. After seeing the query for the case when doubled pawns turn into tripled pawns it is easy to solve this problem:
Deletions:
We need to come up with a CQL query that covers the three cases above. After seeing the query for the case when doubled pawns turn into tripled pawns it is easy to solve this problem:
Additions:
Alway keep this little trick in mind when planning to do several related searches on a large database. As Tim Krabbé put it in his article [[http://www.xs4all.nl/%7Etimkr/chess2/cql.htm Chess Query Language]]: "...it pays to be stupid here, and search too broadly first". Whenever possible, use the lightning fast traditional search methods in Chess Assistant for the initial search.
Note that the above query specifies a total of //exactly// three pawns of the same color on the same file as tripled pawns while the original definition might raise a question about quadrupled pawns. The pawns h2, h3 and h4 are //three pawns of the same color on the same file//, so strictly speaking they are tripled pawns by the above definition. If we agreed to that then quadrupled pawns would contain three different sets of tripled pawns! Regardless of any definition of tripled pawns, this probably does not agree with a chessplayer's notion of tripled pawns.
A correct implementation of common chess terms, ideas, themes etc. in a programming language requires a precise definition. This also applies to CQL, and even in for a simple term like tripled pawns care must be taken when it is converted into precise computer instructions. By using the specification of tripled pawns contained in the query above as our definition, all ambiguity has been removed.
Now that a definition of tripled pawns is in place, the next question is what constitutes "different tripled pawns"? If they are of the same color, there are a few cases to think about:
~1) **Two different positions in a game have tripled pawns, but on different files.** Most people would consider these "different tripled pawns". Notice, however, that these might be the same pawns shifted one file. This has actually happened in a game (Stefanova - Repkova, Olympiade Jerevan 1996) as Tim Krabbé pointed out, where an entire triplet was shifted from the f-file to the g-file. So "different tripled pawns" can actually be composed of the same pawns.
(position :movefrom P[b2-6,d2-6] :moveto ?[c3-7]) ; A white pawn captures on c-file
(position :piececount P[c2-7] 3) ; Three white pawns on the c-file
:shifthorizontal ; Check all files
:matchcount 2 1000 ; Return games with at least two different tripled pawns
This query and all queries that follow only check for white tripled pawns. Chess Assistant users can also use the queries without modifications to search for black tripled pawns (See CQLQueryOrganization and CQLCompositeSearch).
covers both normal captures and en passant captures, so the query above catches all games where tripled pawns arise in this fashion. An even simpler implementation can be created based on the fact that before the move there are two pawns on the file, and after the move there will be three:
(position :piececount P[c2-7] 3) ; Now there are thee!
:shifthorizontal ; Check all files
:matchcount 2 1000 ; Return games with at least two different tripled pawns
So are we done? Not quite. It is still possible to complicate the issue!
We need to come up with a CQL query that covers the three cases above. After seeing the query for the case when doubled pawns turn into tripled pawns it is easy to solve this problem:
(position :piececount P[c2-7] 3) ; Now there are thee!
:shifthorizontal ; Check all files
(position :piececount P[c2-7] 3) ; Now there are thee!
:shifthorizontal ; Check all files
:matchcount 2 1000 ; Return games with at least two different tripled pawns
Again, this query can be simplified by using the fact that tripled pawns cannot arise unless the previous position did //not// have tripled pawns on the file in question:
(position :piececount P[c2-7] 3) ; Now there are thee!
:shifthorizontal ; Check all files
:matchcount 2 1000 ; Return games with at least two different tripled pawns
Deletions:
Alway keep this little trick in mind when planning to do several related searches on a large database. As Tim Krabbé put it in his article [[http://www.xs4all.nl/%7Etimkr/chess2/cql.htm Chess Query Language]]: "...it pays to be stupid here, and search too broadly first". In some cases it is best to use the lightning fast traditional search methods in Chess Assistant for the initial search.
Note that the above query specifies //exactly// three pawns of the same color on the same file as tripled pawns while the original definition might raise a question about quadrupled pawns. The pawns h2, h3 and h4 are //three pawns of the same color on the same file//, so strictly speaking they are tripled pawns by the above definition. If we agreed to that then the quadrupled pawns would contain three different sets of tripled pawns! Regardless of any definition of tripled pawns, this is probably does not fall under a chessplayer's notion of tripled pawns, so we will use the CQL query above as our definition of tripled pawns.
When implementing common chess terms, ideas, themes etc. in a programming language a precise definition is needed. This also applies to CQL, and even in for a simple term like tripled pawns care must be taken when it is converted into precise computer instructions. By using the query as a definition of tripled pawns all ambiguity has been removed.
The next question is what constitutes "different tripled pawns of the same color"? There are a few cases to think about here:
~1) **Two different positions in a game have tripled pawns on different files.** Most people would consider these "different tripled pawns". Notice, however, that these might be the same pawns shifted one file. This has actually happened in a game (Stefanova - Repkova, Olympiade Jerevan 1996) as Tim Krabbé pointed out, where an entire triplet was shifted from the f-file to the g-file. The conclusion is that "different tripled pawns" can actually be composed of the same pawns.
(position :movefrom P[b2-6,d2-6] :moveto ?[c3-7]) ; A white pawn on b- or d-file captures on c-file
(position :piececount P[c2-7] 3) ; As a result there are exactly three white pawns on the c-file
:shifthorizontal ; Check all files for tripled pawns
:matchcount 2 1000 ; We are only interested in games with at least two different tripled pawns
This query and all queries that follow only check for white tripled pawns. Chess Assistant users can use the queries without modifications to search for black tripled pawns (See CQLQueryOrganization and CQLCompositeSearch).
covers both normal captures and en passant captures that lead to tripled pawns, so the query above catches all games where tripled pawns arise in this fashion. An even simpler implementation can be created based on the fact that before the move there are two pawns on the file, and after the move there will be three:
(position :piececount P[c2-7] 3) ; Now they are thee!
:shifthorizontal ; Check all files for tripled pawns
:matchcount 2 1000 ; We are only interested in games with at least two different tripled pawns
So are we done? Not quite! It is still possible to complicate the issue.
In order to find all games where two different tripled pawns of the same color occurred we need to come up with a CQL query that covers the three cases above. After seeing the query for the case when doubled pawns turn into tripled pawns it is easy to solve this problem:
(position :piececount P[c2-7] 3) ; Now they are thee!
:shifthorizontal ; Check all files for tripled pawns
(position :piececount P[c2-7] 3) ; Now they are thee!
:shifthorizontal ; Check all files for tripled pawns
:matchcount 2 1000 ; We are only interested in games with at least two different tripled pawns
Again, this query can be simplified when we realize that tripled pawns cannot arise unless the previous position did //not// have tripled pawns on the file in question:
(position :piececount P[c2-7] 3) ; Now they are thee!
:shifthorizontal ; Check all files for tripled pawns
:matchcount 2 1000 ; We are only interested in games with at least two different tripled pawns
Additions:
This definition is often used and is sufficient for all practical purposes although it may raise a question or two. Let's formulate a CQL query based on this definition. The goal is to find all games where either Black or White had tripled pawns, on any file, at some point in the game. The following CQL query accomplishes this task:
:piececount P[b2-7] 3 ; Exactly three white pawns on the b-file
This query is actually a very sensible start to any further and more specific CQL queries involving tripled pawns. The reason is that complicated CQL queries can take a long time to run on millions of games, so it saves a lot of time to start out by running a simple query that greatly reduces the number of games for subsequent searches. When run on Hugebase in Chess Assistant 8, containing 2.7 million games, this query returns approximately 43.000 games. That's a reduction of more than 98%. After running the query use the dataset that is returned for all following searches involving tripled pawns.
Alway keep this little trick in mind when planning to do several related searches on a large database. As Tim Krabbé put it in his article [[http://www.xs4all.nl/%7Etimkr/chess2/cql.htm Chess Query Language]]: "...it pays to be stupid here, and search too broadly first". In some cases it is best to use the lightning fast traditional search methods in Chess Assistant for the initial search.
Deletions:
This definition is often used and is sufficient for all practical purposes although it may raise a question or two. Let's formulate a CQL query that uses this definition as a basis. The goal is to find all games where either Black or White had tripled pawns, on any file, at some point in the game. The following CQL query accomplishes this task:
:piececount P[b2-7] 3 ; Exactly three pawns on the b-file
This query is actually a very sensible start to any further and more specific CQL queries involving tripled pawns. The reason is that complicated CQL queries can take a long time to run on millions of games, so it saves a lot of time to start out by running a simple query that greatly reduces the number of games for subsequent queries. When run on Hugebase in Chess Assistant 8, containing 2.7 million games, this query returns approximately 43.000 games. That's a reduction of more than 98%. After running the query use the dataset that is returned for all following queries involving tripled pawns.
Alway keep this little trick in mind when planning to do several related searches on a large database. As Tim Krabbé put it in his article [[http://www.xs4all.nl/%7Etimkr/chess2/cql.htm Chess Query Language]]: "...it pays to be stupid here, and search too broadly first".
Additions:
So are we done? Not quite! It is still possible to complicate the issue.
{{image class="right" alt="Quadrupled leads to two tripled pawns" title="Quadrupled leads to two tripled pawns" url="images/CQL-QuadTo2Tripled.jpg"}} All these cases result in a new instance of tripled pawns in the game. Note that in the last case it is theoretically possible that the capture creates two different tripled pawns. The diagram shows an example. There are no tripled pawns on the board. It's white's move and if he plays 1. exd5 then he has tripled pawns on both the d- and the e-file. It is even possible to construct a position without tripled pawns where a single move creates three different instances of tripled pawns!
Now that we know how to search for all the different cases that can occur it is time to combine this knowledge into one complete query that will locate all games where two different tripled pawns of the same color occur.
First of all note that our initial query that searched for all games with tripled pawns in the Hugebase database also returned all games where quadrupled pawns occurred. The reason is simple. Quadrupled pawns cannot occur in a game starting from the normal initial position unless a previous position had tripled pawns. The first try for a solution might look like this:
(position
:or (
(position :piececount P[c2-7] 2) ; Two white pawns on the c-file
(position :piececount P[c2-7] 4) ; Four white pawns on the c-file
)
Deletions:
So are we done? Not quite!
{{image class="right" alt="Quadrupled leads to two tripled pawns" title="Quadrupled leads to two tripled pawns" url="images/CQL-QuadTo2Tripled.jpg"}} All these cases result in a new instance of tripled pawns in the game. Note that in the last case it is theoretically possible that the capture creates two different tripled pawns. The diagram shows an example. There are no tripled pawns on the board. It's white's move and if he plays 1. exd5 then he has tripled pawns on both the d- and the e-file. It is even possible to construct a position without tripled pawns where a single move creates three different tripled pawns!
Now that we know how to search for all the different cases that can occur it is time to combine this knowledge into one complete query that will locate all games where two different tripled pawns of the same color occur. First of all note that our initial query that searched for all games with tripled pawns in the Hugebase database also returned all games where quadrupled pawns occurred. The reason is simple. Quadrupled pawns cannot occur in a game unless a previous position had tripled pawns. The first try for a solution might look like this:
(position
:or (
(position :piececount P[c2-7] 2) ; Two white pawns on the c-file
(position :piececount P[c2-7] 4) ; Four white pawns on the c-file
)
Additions:
//Two tripled pawns of the same color are different if they are on different files or arise at different times in a game//
The first thing to take note of is that tripled pawns arise when a pawn captures an enemy piece on a file where there are already doubled pawns. This can be described in CQL by using the ##:sequence## keyword:
This query and all queries that follow only check for white tripled pawns. Chess Assistant users can use the queries without modifications to search for black tripled pawns (See CQLQueryOrganization and CQLCompositeSearch).
covers both normal captures and en passant captures that lead to tripled pawns, so the query above catches all games where tripled pawns arise in this fashion. An even simpler implementation can be created based on the fact that before the move there are two pawns on the file, and after the move there will be three:
{{image class="right" alt="Quadrupled leads to two tripled pawns" title="Quadrupled leads to two tripled pawns" url="images/CQL-QuadTo2Tripled.jpg"}} All these cases result in a new instance of tripled pawns in the game. Note that in the last case it is theoretically possible that the capture creates two different tripled pawns. The diagram shows an example. There are no tripled pawns on the board. It's white's move and if he plays 1. exd5 then he has tripled pawns on both the d- and the e-file. It is even possible to construct a position without tripled pawns where a single move creates three different tripled pawns!
Deletions:
//Two tripled pawns are different if they are on different files or arise at different times in a game//
The first thing to take note of is that tripled pawns arise when a pawn captures an enemy piece on a file where there are already doubled pawns. This can be achived by using the ##:sequence## keyword of CQL:
covers both normal captures and en passant captures that lead to tripled pawns, so the query above catches all games where tripled pawns arise in this fashion. An even simpler implementation is based on the fact that before the move there are two pawns on the file, and after the move there will be three:
{{image class="right" alt="Quadrupled leads to two tripled pawns" title="Quadrupled leads to two tripled pawns" url="images/CQL-QuadTo2Tripled.jpg"}} All these cases result in a new instance of tripled pawns in the game. Note that in the last case it is theoretically possible that the capture creates two different tripled pawns! The diagram shows an example. There are no tripled pawns on the board. It's white's move and if he plays 1. exd5 then he has tripled pawns on both the d- and the e-file!
Additions:
//Two tripled pawns are different if they are on different files or arise at different times in a game//
Deletions:
//Tripled pawns are different if they are on different files or arise at different times in a game//
Additions:
The following definition of "different tripled pawns" has the advantage that it is simple and can classify all instances of tripled pawns as either different or the same:
According to this definition 1)-3) and 5) above define different tripled pawns, while it also agrees with the conclusion of 4). Having defined different tripled pawns in this way it's time to formulate a CQL query that will find games where two different tripled pawns of the same color have occurred.
Deletions:
Let's propose a precise definition of "different tripled pawns":
According to this definition 1)-3) and 5) above define different tripled pawns, while it also agrees with the conclusion of 4). Having defined different tripled pawns in this way it's time to define a CQL query that will find games where two different tripled pawns of the same color have occurred.
Additions:
~1) **Two different positions in a game have tripled pawns, composed of different pawns, on the same file.** Let's say that a position arises with white tripled pawns on c2, c3 and c4. Later in the game the c4 pawn captures an enemy piece on b5 and the tripled pawns have been dissolved. Still later in the game a white pawn on d5 captures an enemy piece on c6 and again there are white tripled pawns on the c-file, although they are not (all) the same pawns as before.
~1) **A position arises with tripled pawns. One of the pawns is moved forward.** Of course, these are still the same tripled paws. Tripled pawns in a different position on the same file are still the same tripled pawns. There is one complication though...
Deletions:
~1) **Two different positions in a game have different tripled pawns on the same file.** Let's say that a position arises with white tripled pawns on c2, c3 and c4. Later in the game the c4 pawn captures an enemy piece on b5 and the tripled pawns have been dissolved. Still later in the game a white pawn on d5 captures an enemy piece on c6 and again there are white tripled pawns on the c-file, although they are not (all) the same pawns as before.
~1) **A position arises with tripled pawns. One of the pawns is moved forward.** Of course, these are still the same tripled paws. Tripled pawns in a different position on the same file are still the same pawn triple. There is one complication though...
Additions:
This definition is often used and is sufficient for all practical purposes although it may raise a question or two. Let's formulate a CQL query that uses this definition as a basis. The goal is to find all games where either Black or White had tripled pawns, on any file, at some point in the game. The following CQL query accomplishes this task:
The next question is what constitutes "different tripled pawns of the same color"? There are a few cases to think about here:
Deletions:
This definition is often used and is sufficient for all practical purposes although it may raise a question or two. Let's start out by formulating a CQL query that uses this definition as a basis. The goal is to find all games where either Black or White had tripled pawns, on any file, at some point in the game. The following CQL query accomplishes this task:
What constitutes "different tripled pawns of the same color"? There are a few cases to think about here:
Additions:
In January and March 2005 Tim Krabbé's [[http://www.xs4all.nl/%7Etimkr/chess2/diary.htm Open chess diary]] had two entries about tripled pawns that generated a lot of interest. It all started with the game Cheparinov - Stefanova, Corus B (8), 24 January 2005, where Black had two different tripled pawns, first on the d-file and then on the g-file. This raised the question if anything like that had happened before. More precisely, Krabbé wanted to find examples where
Let's start with a definition of //tripled pawns//:
This definition is often used and is sufficient for all practical purposes although it may raise a question or two. Let's start out by formulating a CQL query that uses this definition as a basis. The goal is to find all games where either Black or White had tripled pawns, on any file, at some point in the game. The following CQL query accomplishes this task:
This query is actually a very sensible start to any further and more specific CQL queries involving tripled pawns. The reason is that complicated CQL queries can take a long time to run on millions of games, so it saves a lot of time to start out by running a simple query that greatly reduces the number of games for subsequent queries. When run on Hugebase in Chess Assistant 8, containing 2.7 million games, this query returns approximately 43.000 games. That's a reduction of more than 98%. After running the query use the dataset that is returned for all following queries involving tripled pawns.
Alway keep this little trick in mind when planning to do several related searches on a large database. As Tim Krabbé put it in his article [[http://www.xs4all.nl/%7Etimkr/chess2/cql.htm Chess Query Language]]: "...it pays to be stupid here, and search too broadly first".
Note that the above query specifies //exactly// three pawns of the same color on the same file as tripled pawns while the original definition might raise a question about quadrupled pawns. The pawns h2, h3 and h4 are //three pawns of the same color on the same file//, so strictly speaking they are tripled pawns by the above definition. If we agreed to that then the quadrupled pawns would contain three different sets of tripled pawns! Regardless of any definition of tripled pawns, this is probably does not fall under a chessplayer's notion of tripled pawns, so we will use the CQL query above as our definition of tripled pawns.
Deletions:
Tim Krabbé's [[http://www.xs4all.nl/%7Etimkr/chess2/diary.htm Open chess diary]] is one of the most enjoyable chess web pages. In January and March 2005 he had two entries about tripled pawns that generated a lot of interest. It all started with the game Cheparinov - Stefanova, Corus B (8), 24 January 2005, where Black had two different tripled pawns, first on the d-file and then on the g-file. This raised the question if anything like that had happened before. More precisely, Krabbé wanted to find examples where
Let's start with a definition of //tripled pawns//. A typical definition can be found in one of Dan Heisman's Novice Nook columns on [[http://www.chesscafe.com/ ChessCafe.com]]:
This definition is sufficient for all practical purposes although it may raise a question or two. Let's start out by formulating a CQL query that uses this definition as a basis. The goal is to find all games where either Black or White had tripled pawns, on any file, at some point in the game. The following CQL query accomplishes this task:
)
%%
This query is actually a very sensible start to any further and more specific queries involving tripled pawns. The reason is that complicated CQL queries can take a long time to run on millions of games, so it will save a lot of time to start out by running a simple query that will greatly reduce the number of games for subsequent queries. When run on Hugebase in Chess Assistant 8, containing 2.7 million games, this query returns approximately 43.000 games. That's a reduction of more than 98%.
Note that the above query specifies //exactly// three pawns of the same color on the same file as tripled pawns. The original definition didn't contain the word //exactly// which might raise a question about quadrupled pawns. The pawns h2, h3 and h4 are //three pawns of the same color on the same file//, so strictly speaking they are tripled pawns by the above definition. If we agreed to that then the quadrupled pawns would contain three different tripled pawns! Regardless of any definition of tripled pawns, this is probably does not fall under a normal chessplayer's notion of tripled pawns, so we will use the CQL query above as our definition of tripled pawns.
Deletions:
:flipcolor ; Also check for black tripled pawns
:flipcolor ; Also check for black tripled pawns
:flipcolor ; Also check for black tripled pawns
:flipcolor ; Also check for black tripled pawns
:flipcolor ; Also check for black tripled pawns
Deletions:
:flipcolor ; Also check for black tripled pawns
:shifthorizontal ; Check all files for tripled pawns
:matchcount 2 1000 ; We are only interested in games with at least two different tripled pawns
Additions:
(position
:or (
(position :piececount P[c2-7] 2) ; Two white pawns on the c-file
(position :piececount P[c2-7] 4) ; Four white pawns on the c-file
)
(position :piececount P[c2-7] 3) ; Now they are thee!
(position :not :piececount P[c2-7] 3) ; There are not three pawns on the c-file
(position :piececount P[c2-7] 3) ; Now they are thee!
:flipcolor ; Also check for black tripled pawns
:shifthorizontal ; Check all files for tripled pawns
:matchcount 2 1000 ; We are only interested in games with at least two different tripled pawns
Deletions:
(position
:or (
(position :piececount P[c2-7] 2) ; Two white pawns on the c-file
(position :piececount P[c2-7] 4) ; Four white pawns on the c-file
)
(position :not :piececount P[c2-7] 3) ; There are not three pawns on the c-file
Additions:
(position :piececount P[c2-7] 4) ; Four white pawns on the c-file
====The general solution====
Now that we know how to search for all the different cases that can occur it is time to combine this knowledge into one complete query that will locate all games where two different tripled pawns of the same color occur. First of all note that our initial query that searched for all games with tripled pawns in the Hugebase database also returned all games where quadrupled pawns occurred. The reason is simple. Quadrupled pawns cannot occur in a game unless a previous position had tripled pawns. The first try for a solution might look like this:
(position
:or (
(position :piececount P[c2-7] 2) ; Two white pawns on the c-file
(position :piececount P[c2-7] 4) ; Four white pawns on the c-file
)
)
Again, this query can be simplified when we realize that tripled pawns cannot arise unless the previous position did //not// have tripled pawns on the file in question:
(position :not :piececount P[c2-7] 3) ; There are not three pawns on the c-file
Deletions:
(position :piececount P[c2-7] 4) ; Two white pawns on the c-file
Additions:
The first thing to take note of is that tripled pawns arise when a pawn captures an enemy piece on a file where there are already doubled pawns. This can be achived by using the ##:sequence## keyword of CQL:
covers both normal captures and en passant captures that lead to tripled pawns, so the query above catches all games where tripled pawns arise in this fashion. An even simpler implementation is based on the fact that before the move there are two pawns on the file, and after the move there will be three:
(position :piececount P[c2-7] 2) ; Two white pawns on the c-file
(position :piececount P[c2-7] 3) ; Now they are thee!
So are we done? Not quite!
~1) One of the four pawns is captured (either normal or en passant)
~1) One of the four pawns captures an enemy piece on an adjacent file (either normal or en passant).
{{image class="right" alt="Quadrupled leads to two tripled pawns" title="Quadrupled leads to two tripled pawns" url="images/CQL-QuadTo2Tripled.jpg"}} All these cases result in a new instance of tripled pawns in the game. Note that in the last case it is theoretically possible that the capture creates two different tripled pawns! The diagram shows an example. There are no tripled pawns on the board. It's white's move and if he plays 1. exd5 then he has tripled pawns on both the d- and the e-file!
In order to find all games where two different tripled pawns of the same color occurred we need to come up with a CQL query that covers the three cases above. After seeing the query for the case when doubled pawns turn into tripled pawns it is easy to solve this problem:
(position :piececount P[c2-7] 4) ; Two white pawns on the c-file
(position :piececount P[c2-7] 3) ; Now they are thee!
Deletions:
The first thing to take note of is that tripled pawns arise when a pawn captures an enemy piece on a file where there are already doubled pawns. So the objective is to find positions where a capturing move by a pawn leads to tripled pawns. This can be achived by using the ##:sequence## keyword of CQL:
covers both normal captures and en passant captures that lead to tripled pawns, so the query above catches all games where tripled pawns arise in this fashion. So are we done? Not quite!
~1) One of the four pawns is captured
~1) One of the four pawns captures an enemy piece on an adjacent file.
Note that in the last case it is possible that the capture creates two tripled pawns! The diagram shows an example.
Additions:
:piececount P[b2-7] 3 ; Exactly three pawns on the b-file
:shifthorizontal ; Search all files for tripled pawns
:flipcolor ; Also check for black pawns
Note that
(position :movefrom P[b2-6,d2-6] :moveto ?[c3-7])%%
covers both normal captures and en passant captures that lead to tripled pawns, so the query above catches all games where tripled pawns arise in this fashion. So are we done? Not quite!
====From more to less====
There is one more way for tripled pawns to arise that hasn't been mentioned yet. If there are quadrupled pawns on a file and one of those pawns is captured the result is tripled pawns. There are actually three possibilities for going from quadrupled pawns to tripled pawns:
~1) One of the four pawns is captured
~1) One of the four pawns is on the seventh (second) rank and is promoted
~1) One of the four pawns captures an enemy piece on an adjacent file.
Note that in the last case it is possible that the capture creates two tripled pawns! The diagram shows an example.
Deletions:
:piececount P[b2-7] 3 ; Exactly three pawns on the b-file
:shifthorizontal ; Search all files for tripled pawns
:flipcolor