Changes

Jump to: navigation, search

Ranks

2,341 bytes added, 16:44, 9 May 2018
Created page with "'''Home * Chess * Ranks''' '''Ranks''' are the eight horizontal lines or rows of a Chessboard, labeled from '1' to '8'. Each rank contains eight horizon..."
'''[[Main Page|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]].

=Back Ranks=
The First Rank is White's back rank, while the Eights Rank is Black's back rank.
<fentt border="a1" style="font-size:24pt">(++++++++)/......../......../......../......../......../......../(++++++++)</fentt>

=Square Mapping Notes=
Whether the square difference of neighbored squares on a rank or [[Files|file]] is either 1 or 8, depends on the square mapping. We further rely on [[Square Mapping Considerations#LittleEndianRankFileMapping|little-endian rank-file mapping]], which keeps consecutive [[Squares|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 Considerations#LittleEndianRankFileMapping|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|little-endian]] rank-mapping enumeration in [[Cpp|C++]] might look like this:
<pre>
enum enumRank {
er1stRank = 0,
er2ndRank = 1,
er3rdRank = 2,
er4thRank = 3,
er5thRank = 4,
er6thRank = 5,
er7thRank = 6,
er8thRank = 7,
};
</pre>
=Rank from Square=
Rank-File mapping of squares keeps the rank index as the three upper bits of a six bit Square index.
<pre>
rank = square >> 3; // div 8
</pre>
<span id="RankDistance"></span>
=Rank-Distance=
The rank-distance is the [[Avoiding Branches#Abs|absolute]] difference between two ranks (their 0-7 indices). The maximum rank-distance is 7.
<pre>
rankDistance = abs (rank1 - rank2);
rankDistance = abs (rank2 - rank1);
</pre>
=See also=
* [[Files]]
* [[Diagonals]]
* [[Anti-Diagonals]]
* [[Squares]]
* [[Intersection Squares]]

=What links here?=
[[include page="Ranks" component="backlinks" limit="60" ]]
'''[[Chess|Up one Level]]'''

Navigation menu