Ranks

toc
 * Home * Chess * Ranks**


 * Ranks** are the eight horizontal lines or rows of a Chessboard, labeled from '1' to '8'. Each rank contains eight horizontally arranged Squares of alternating white and black, or light and dark Color. The First Rank is White's back rank, while the Eights Rank is Black's back rank.

=Square Mapping Notes= Whether the square difference of neighbored squares on a rank or file is either 1 or 8, depends on the square mapping. We further rely on little-endian rank-file mapping, which keeps consecutive squares of a rank as neighbored elements in Memory (or register).

=Square Difference= Within a 0..63 square index range and the mentioned square mapping (a1 = 0), the difference of two neighbored squares on a Rank is **one**.

=Enumeration= As mentioned, on a Chessboard the eight ranks are labeled from '1' to '8'. To make them zero based indices as appropriate for C-like programming languages, we enumerate ranks from 0 to 7. Little-endian rank-mapping (as used here) assigns the first Rank to index zero. Three bits are required to enumerate from 0 to 7.

A little-endian rank-mapping enumeration in C++ might look like this: code format="cpp" enum enumRank { er1stRank = 0, er2ndRank = 1, er3rdRank = 2, er4thRank = 3, er5thRank = 4, er6thRank = 5, er7thRank = 6, er8thRank = 7, }; code =Rank from Square= Rank-File mapping of squares keeps the rank index as the three upper bits of a six bit Square index. code rank = square >> 3; // div 8 code  =Rank-Distance= The rank-distance is the absolute difference between two ranks (their 0-7 indices). The maximum rank-distance is 7. code format="cpp" rankDistance = abs (rank1 - rank2); rankDistance = abs (rank2 - rank1); code =See also=
 * Files
 * Diagonals
 * Anti-Diagonals
 * Squares
 * Intersection Squares

=What links here?= include page="Ranks" component="backlinks" limit="60"
 * Up one Level**