Difference between revisions of "Diagonals"

From Chessprogramming wiki
Jump to: navigation, search
(Created page with "'''Home * Chess * Diagonals''' FILE:kleinbottle_inside.jpg|border|right|thumb|link=http://www.cs.berkeley.edu/%7Eug/slide/gallery/kleinbottle/index.shtml|...")
 
Line 9: Line 9:
  
 
=Square Mapping Notes=  
 
=Square Mapping Notes=  
A [[Flipping Mirroring and Rotating#Rotationby90degreesClockwise|90 degree rotation]] of the [[Chessboard]], as well as [[Flipping Mirroring and Rotating#FlipVertically|flipping vertically]] (reversed [[ranks]]) or (exclusive) [[Flipping Mirroring and Rotating#MirrorHorizontally|mirroring horizontally]] (reversed [[files]]), change the roles of diagonals and [[anti-diagonals]]. However, we define the main diagonal on the chess board from a1/h8 and the main anti-diagonal from h1\a8. Whether the square difference of neighbored squares on a diagonal or anti-diagonal is either 7 or 9, depends on the square mapping. We further rely on [[Square Mapping Considerations#LittleEndianRankFileMapping|little-endian rank-file mapping]].
+
A [[Flipping Mirroring and Rotating#Rotationby90degreesClockwise|90 degree rotation]] of the [[Chessboard]], as well as [[Flipping Mirroring and Rotating#FlipVertically|flipping vertically]] (reversed [[Ranks|ranks]]) or (exclusive) [[Flipping Mirroring and Rotating#MirrorHorizontally|mirroring horizontally]] (reversed [[Files|files]]), change the roles of diagonals and [[Anti-Diagonals|anti-diagonals]]. However, we define the main diagonal on the chess board from a1/h8 and the main anti-diagonal from h1\a8. Whether the square difference of neighbored squares on a diagonal or anti-diagonal is either 7 or 9, depends on the square mapping. We further rely on [[Square Mapping Considerations#LittleEndianRankFileMapping|little-endian rank-file mapping]].
  
 
=Square Difference=  
 
=Square Difference=  

Revision as of 14:13, 19 December 2018

Home * Chess * Diagonals

Diagonals go from south-west to north-east on a chess board, the main diagonal is a1/h8. There are 15 diagonals, with line-length from 1 to 8. A Diagonal is monochrome, all their squares are either white or black.

Main Diagonal

 abcdefgh 
8
7
6
5
4
3
2
1
    
    
    
    
    
    
    
    
        
        
        
        
        
        
        
        
       •
      • 
     •  
    •   
   •    
  •     
 •      
•       
8
7
6
5
4
3
2
1
 abcdefgh 

Square Mapping Notes

A 90 degree rotation of the Chessboard, as well as flipping vertically (reversed ranks) or (exclusive) mirroring horizontally (reversed files), change the roles of diagonals and anti-diagonals. However, we define the main diagonal on the chess board from a1/h8 and the main anti-diagonal from h1\a8. Whether the square difference of neighbored squares on a diagonal or anti-diagonal is either 7 or 9, depends on the square mapping. We further rely on little-endian rank-file mapping.

Square Difference

Within a 0..63 square index range and the mentioned square mapping (a1 = 0), the difference of two neighbored squares (if any) on a diagonal is nine.

Enumeration

If we follow a diagonal from south-west (a1) to north-east (h8) step by step, we increment the rank, and increment the file, which yields in same difference. Thus, subtracting rank from file indices (or vice versa) enumerates all Diagonals, unfortunately with negative numbers involved, which can easily adjusted by adding seven.

  • The main diagonal a1/h8 with index 0 and length 8.
  • The diagonals a8/ and h1/ with length 1, are index 7 and -7 respectively.
  • All even indices are the diagonals with dark squares

rank - file

r/f 0 1 2 3 4 5 6 7
7 7 6 5 4 3 2 1 0
6 6 5 4 3 2 1 0 -1
5 5 4 3 2 1 0 -1 -2
4 4 3 2 1 0 -1 -2 -3
3 3 2 1 0 -1 -2 -3 -4
2 2 1 0 -1 -2 -3 -4 -5
1 1 0 -1 -2 -3 -4 -5 -6
0 0 -1 -2 -3 -4 -5 -6 -7

7 + rank - file

r/f 0 1 2 3 4 5 6 7
7 14 13 12 11 10 9 8 7
6 13 12 11 10 9 8 7 6
5 12 11 10 9 8 7 6 5
4 11 10 9 8 7 6 5 4
3 10 9 8 7 6 5 4 3
2 9 8 7 6 5 4 3 2
1 8 7 6 5 4 3 2 1
0 7 6 5 4 3 2 1 0

Alternative Enumeration

Some alternative enumeration of diagonals to keep the main-diagonal index 0, by anding the difference with 15. This yields in a 0..15 range with 8 as gap or Nexus in the center of the range:

(rank - file) & 15

r/f 0 1 2 3 4 5 6 7
7 7 6 5 4 3 2 1 0
6 6 5 4 3 2 1 0 15
5 5 4 3 2 1 0 15 14
4 4 3 2 1 0 15 14 13
3 3 2 1 0 15 14 13 12
2 2 1 0 15 14 13 12 11
1 1 0 15 14 13 12 11 10
0 0 15 14 13 12 11 10 9

See also

References

  1. What is a Klein Bottle?
  2. Nerius Landys and Shad Roundy Klein Bottle Project
  3. Torus Games - players who master the games on the Torus may move on to try them on the more challenging Klein bottle

Up one Level