Changes

Jump to: navigation, search

Ranks

707 bytes added, 14:07, 20 August 2020
no edit summary
rankDistance = abs (rank2 - rank1);
</pre>
<span id="TwoSquares"></span>
=Two Squares on a Rank=
Two [[Squares]] are on the same Rank, if their Rank distance is zero.
<pre>
bool squaresOnSameRank(int sq1, int sq2) {
return ((sq2 >> 3) - (sq1 >> 3)) == 0;
}
</pre>
The [https://en.wikipedia.org/wiki/Symmetric_difference Symmetric difference] aka xor is sufficent for the test of the rank bits as well <ref>[http://talkchess.com/forum3/viewtopic.php?f=7&t=74821 An undetected bug for 10 years] by [[Oliver Brausch]], [[CCC]], August 18, 2020</ref>
<pre>
bool squaresOnSameRank(int sq1, int sq2) {
return ((sq1 ^ sq2) & 56) == 0;
}
</pre>
* [[Files#TwoSquares|Two Squares on a File]]
* [[Diagonals#TwoSquares|Two Squares on a Diagonal]]
* [[Anti-Diagonals#TwoSquares|Two Squares on a Anti-Diagonal]]
 
=See also=
* [[Files]]
* [[Intersection Squares]]
=What links here?References= [[include page="Ranks" component="backlinks" limit="60" ]]<references/>
'''[[Chess|Up one Level]]'''

Navigation menu