Difference between revisions of "Diagonal Mirroring"

From Chessprogramming wiki
Jump to: navigation, search
(Created page with "'''Home * Chess * Position * Diagonal Mirroring''' '''Diagonal mirroring''' mirrors all pieces along the Diagonals|main diag...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
'''[[Main Page|Home]] * [[Chess]] * [[Chess Position|Position]] * Diagonal Mirroring'''
 
'''[[Main Page|Home]] * [[Chess]] * [[Chess Position|Position]] * Diagonal Mirroring'''
 +
 +
[[FILE:Hilma af Klint - Group IX SUW, The Swan No. 7 (13945).jpg|border|right|thumb| [[:Category:Hilma af Klint|Hilma af Klint]] - Group IX SUW, The Swan No. 7 
 +
<ref>[[:Category:Hilma af Klint|Hilma af Klint]] - [https://commons.wikimedia.org/wiki/File:Hilma_af_Klint_-_Group_IX_SUW,_The_Swan_No._7_(13945).jpg Group IX SUW, The Swan No. 7], 1915, [https://en.wikipedia.org/wiki/Wikimedia_Commons Wikimedia Commons]</ref> ]]
  
 
'''Diagonal mirroring''' mirrors all [[Pieces|pieces]] along the [[Diagonals|main diagonal]] or [[Anti-Diagonals|main anti-diagonal]]. It is applicable in pawn-less [[Endgame|endgames]] with [[Castling|castling]] no longer possible. Along with [[Horizontal Mirroring|horizontal]] and/or [[Vertical Flipping|vertical flipping]], diagonal mirroring is used in pawn-less [[Endgame Tablebases|endgame tablebases]] to restrict a white king to the 10 squares of the a1-d4-d1 triangle of the board.
 
'''Diagonal mirroring''' mirrors all [[Pieces|pieces]] along the [[Diagonals|main diagonal]] or [[Anti-Diagonals|main anti-diagonal]]. It is applicable in pawn-less [[Endgame|endgames]] with [[Castling|castling]] no longer possible. Along with [[Horizontal Mirroring|horizontal]] and/or [[Vertical Flipping|vertical flipping]], diagonal mirroring is used in pawn-less [[Endgame Tablebases|endgame tablebases]] to restrict a white king to the 10 squares of the a1-d4-d1 triangle of the board.
 +
 +
=Mirroring an 8x8 Board=
 +
An [[8x8 Board]] with a [[Squares|rank-file mapping]] needs to swap [[Ranks|rank]] and [[Files|file]]. A pure 8x8 Board may be mirrored along the main diagonal that way in [[C]]:
 +
<pre>
 +
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;
 +
}
 +
</pre>
  
 
=Sample Position=
 
=Sample Position=
Line 18: Line 37:
 
|  k1N5/2K5/8/8/2B5/8/8/8 w - -  
 
|  k1N5/2K5/8/8/2B5/8/8/8 w - -  
 
|}
 
|}
 
=Mirroring an 8x8 Board=
 
An [[8x8 Board]] with a [[Squares|rank-file mapping]] needs to swap [[Ranks|rank]] and [[Files|file]]. A pure 8x8 Board may be mirrored along the main diagonal that way in [[C]]:
 
<pre>
 
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;
 
}
 
</pre>
 
  
 
=See also=
 
=See also=
Line 49: Line 52:
  
 
'''[[Chess Position|Up one Level]]'''
 
'''[[Chess Position|Up one Level]]'''
 +
[[Category:Hilma af Klint]]

Latest revision as of 15:25, 6 March 2020

Home * Chess * Position * Diagonal Mirroring

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

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.

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 w - - 8/8/8/5B2/8/8/5K2/5N1k w - - k1N5/2K5/8/8/2B5/8/8/8 w - -

See also

External Links

Up one Level