rotate90
rotate90
is a transform filter corresponding to the following 4 basic transforms.
- id, the identity
- rotate90: counterclockwise rotation about the board center by 90°
- rotate180: rotation by 180° about the board center
- rotate270: clockwise rotation about the board center by 90°
rotate90
is normally called with a single argument filter, F:
rotate90 F
rotate90
also accepts an optional count
parameter.
rotate90 F
matches the current position if any transformation of F by one of the 4 basic transforms above matches the current position. These 4 transforms are examples of dihedral transforms.
For example, suppose F is the filter {Ka1 kh8}
, matching a position in which the white king is on a1
and the black king is on h8
. If we transform this filter by rotate90 we get the new filter {Kh1 ka8}
. That is, if spin the chessboard 90° counterclockwise about the center of the board, the a1
square will wind up on h1
and the h8
square will wind up on a8
.
The filters that results from transforming {Ka1 kh8}
by all the elements of rotate90
, which is to say the identity and the three rotations, are:
{Ka1 kh8} {Kh1 ka8} {Ka8 kh1} {Kh8 ka1}
The filter rotate90 {Ka1 kh8}
will thus match a position if any of these 4 filters match the position, that is, if the white and black king are on opposite corners.
(This can also be done, more efficiently, via k==diagonal 7 K[a1,h1]
)
If F is a set filter then so is
rotate90 F
in which case its value is the union of the values of each of the sets represented by each transformed version of F.
For example,
rotate90 a1
is the set [a1,h1,a8,h8]
.
If F is a numeric filter then so is rotate90 F
in which case its value is the maximum of the values of the 4 rotations of F which match the position.
rotate90 count F
is a numeric filter whose value is the number of distinct matching transformed versions of F. For example, if the current position is the initial position, then
rotate90 count find {Qa1 qh8}
is equal to 0 if neither {Qa1 qh8}
nor {Qh1 qa8}
occur in the game; is equal to 1 if exactly one of these configurations does; and is equal to 2 if both of them do.
The rotate90
filter also modifies directions parameters and filters. Thus,
rotate90 ray right (R K)
will match if and only if
ray orthogonal (R K)
matches.