This is a temporary, read-only recovery of the chessprogrammingwiki while a longer-term plan is worked out. Editing is not possible right now, but will be again soon.
Chess Programming Wiki All pages Other namespaces

Diagonal Mirroring

Home * Chess * Position * Diagonal Mirroring

Hilma af Klint - Group IX SUW, The Swan No. 7 1Hilma af Klint - Group IX SUW, The Swan No. 7 1


  1. Hilma af Klint - Group IX SUW, The Swan No. 7, 1915, Wikimedia Commons↩︎

Diagonal mirroring mirrors all pieces along the main diagonal or main anti-diagonal. It is applicable in pawn-less endgames with castling no longer possible. Along with horizontal and/or vertical flipping, diagonal mirroring is used in pawn-less endgame tablebases to restrict a white king to the 10 squares of the a1-d4-d1 triangle of the board.

Contents
  1. Mirroring an 8x8 Board
  2. Sample Position
  3. See also
  4. External Links

Mirroring an 8x8 Board

An 8x8 Board with a rank-file mapping needs to swap rank and file. A pure 8x8 Board may be mirrored along the main diagonal that way in C:

int board[64], f, r, sm, sq, s;

for (f = 1; f < 8; ++f)
for (r = 0; r < f; ++r)
{
  sq = 8*r + f;
  sm = 8*f + r;
  s = board[sq];
  board[sq] = board[sm];
  board[sm] = s;
}

Sample Position

Original Diagonal Mirror Anti-Diagonal Mirror
k7/8/NK2B3/8/8/8/8/8
8/8/8/5B2/8/8/5K2/5N1k
k1N5/2K5/8/8/2B5/8/8/8
k7/8/NK2B3/8/8/8/8/8 w - - 8/8/8/5B2/8/8/5K2/5N1k w - - k1N5/2K5/8/8/2B5/8/8/8 w - -

See also

Up one Level

Categories: Hilma af Klint

What links here

Contributors: GerdIsenberg.