The makesquare filter creates a square from either a file and a rank or from a string:
    makesquare (1 4)  a4
    makesquare "b3"  b3

file and rank argument to makesquare

In the first form of makesquare,
    makesquare (file rank)

The file argument is a numeric filter whose value represents a file on the chessboard, with the a file being 1, the b file being 2, and so on.

The rank argument is a numeric filter whose value is a rank on the chessboard.

The makesquare filter represents the square whose file and rank are equal to its file and rank arguments respectively. If either of its arguments do not match the position, or if either argumnet is not between 1 and 8, then the makesquare filter does not match the position.

For example

      makesquare (2 4)
represents the square b4. That is,
      b4 == makesquare (2 8)
will match any position.

Technically, makesquare filter is a set filter representing a set that contains exactly one square (unless either the file or the rank is not between 1 and 8, in which case makesquare represents the empty set of squares.)

string argument to makesquare

In the second form of makesquare, the argument is a single string filter denoting a single square:
      makesquare "a3"
      makesquare "a" + "3"
Note the precedence of makesquare is just below string concatenation.

If the string argument does not represent a square, then the makesquare filter does not match.

The functionality of this form of the makesquare filter is purely for convenience. If x is the string argument to makesquare, then

      makesquare x
       makesquare(ascii x[0]- ascii "a" + 1
                  ascii x[1]= ascii "1")}

This form of the makesquare filter is typically used for parsing fragments of PGN files or moves, or the en passant field of a FEN.


Be careful to get the order of arguments correct: the file precedes the rank, even though it is customary to say "rank and file".

The makesquare filter is not itself affected by transforms like flip or flipcolor, but its arguments are. Thus

      {flip makesquare "b4"} == b4
      {flip makesquare (2 4)}== b4
      {flip makesquare b4} == [d2,e2,b4,g4,b5,g5,d7,e7]

Note that the string literal "b4" is not affected by transforms, but the square b4, as an argument to str, is affected by transforms.


The makequare filter is used in flipverticalecho.cql and horizontallysymmetric.cql.