ChessAssistantDocs : CQLQueries

HomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register

Another take on the double tripled pawns

In January and March 2005 Tim Krabbé's 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

two different tripled pawns of the same color had occurred during a game

I'm sure that most chessplayers have no problem in understanding what is meant by this. But is it really that simple? Would everyone agree when they saw specific examples of "two different tripled pawns"?

Tripled pawns

Let's start with a definition of tripled pawns:

Tripled pawns are three pawns of the same color on the same file

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:
(match
  (position
    :piececount P[b2-7] 3  ; Exactly three white pawns on the b-file
    :shifthorizontal  ; Search all files for tripled pawns
    :flipcolor  ; Also check for black pawns
  )
)

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 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.

Doubled and tripled pawns
The diagram on the right has examples of doubled white pawns (d2, d3), tripled black pawns (f5, f6, f7) and quadrupled white pawns (h2, h3, h4, h5).

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.

Different tripled pawns

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. A position arises in a game where one side has two sets of tripled pawns. In this case they are, by definition, different pawns on different files.
  2. 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.
  3. 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.
  4. 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...
  5. Tripled pawns are dissolved and then reassembled on the same file. A white pawn triple on c2, c3 and c4 stays intact until the c4 pawn captures on b5 and leaves behind doubled pawns on the c-file. Later on that same pawn captures an enemy piece on c6 and the tripled pawns have been reassambled. Are these "different tripled pawns"?

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:

Two tripled pawns of the same color are different if they are on different files or arise at different times in a game

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.

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:
(match
  (position
    :sequence (
      (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).
Note that
(position :movefrom P[b2-6,d2-6] :moveto ?[c3-7])

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:
(match
  (position
    :sequence (
      (position :piececount P[c2-7] 2)  ; Two white pawns on the c-file
      (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!

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 (either normal or en passant)
  2. One of the four pawns is on the seventh (second) rank and is promoted
  3. One of the four pawns captures an enemy piece on an adjacent file (either normal or en passant).

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:
(match
  (position
    :sequence (
      (position :piececount P[c2-7] 4)  ; Four white pawns on the c-file
      (position :piececount P[c2-7] 3)  ; Now there are thee!
    )
    :shifthorizontal  ; Check all files
  )
)

A 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 starting from the normal initial position unless a previous position had tripled pawns. The first try for a solution might look like this:
(match
  (position
    :sequence (
      (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 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 of the same color on the file in question:
(match
  (position
    :sequence (
        (position :not :piececount P[c2-7] 3)  ; There are not three pawns on the c-file
        (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
  )
)

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.
Quadrupled leads to two tripled pawnsIt 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!

There are 7 comments on this page. [Display comments]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.3
Page was generated in 0.0698 seconds