Take the 2-minute tour ×
Chess Stack Exchange is a question and answer site for serious players and enthusiasts of chess. It's 100% free, no registration required.

I am looking for a way within any of the common chess packages to search for a specific maneuver - rook takes bishop that is protected (i.e. an exchange sacrifice)? I've heard of CQL, but never used, so I would be curious if it supports something like this.

share|improve this question
add comment

1 Answer

Chess Query Language does do this very well. The following short .cql file works like a charm to find all games in input.pgn in which one side is up an exchange (while allowing a difference in the number of pawns for each side) for 4 straight moves (picked so as to rule out, say, situations in which an equal sequence of trades happens to begin with a rook taking a minor piece, or other such temporary pseudo-sacrifices).

(match
    :pgn input.pgn
    :output output.pgn
    (position
    :sequence(
        (position :powerdifference [Rr] -5 -5 :powerdifference [Qq] 0 0 :powerdifference [BbNn] 3 3)
        (position :powerdifference [Rr] -5 -5 :powerdifference [Qq] 0 0 :powerdifference [BbNn] 3 3)
        (position :powerdifference [Rr] -5 -5 :powerdifference [Qq] 0 0 :powerdifference [BbNn] 3 3)
        (position :powerdifference [Rr] -5 -5 :powerdifference [Qq] 0 0 :powerdifference [BbNn] 3 3)
    )
    :flipcolor
    )
)

Standard point values for pieces are used, so the :powerdifference [Rr] -5 -5 condition means that Black has one more rook than White, while :powerdifference [BbNn] 3 3 guarantees that White has exactly one more minor piece than Black. The :flipcolor at the end does the same search with the roles reversed. By default, CQL inserts a "MATCH" comment in the games of the resulting output.pgn at the positions that warrant their inclusion, so you can quickly locate the exchange sacs.

share|improve this answer
    
awesome, sounds like kind of thing I was looking for CQL-wise. Do you use CQL implementation from rbnn.com/cql ? –  Joe Dec 31 '12 at 6:27
    
@Joe, yes, that's the one I used. –  ETD Dec 31 '12 at 11:51
2  
Great answer, I didn't know such a thing existed. –  Tony Ennis Dec 31 '12 at 12:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.