Changes

Jump to: navigation, search

Center Distance

2,267 bytes added, 13:48, 9 May 2018
Created page with "'''Home * Chess * Squares * Center Distance''' The '''Center Distance''' is the distance (also known as [https://en.wikipedia.org/wiki/Cheb..."
'''[[Main Page|Home]] * [[Chess]] * [[Squares]] * Center Distance'''

The '''Center Distance''' is the [[Distance|distance]] (also known as [https://en.wikipedia.org/wiki/Chebyshev_distance Chebyshev distance]) or number of [[King]] moves on the otherwise empty board from any square to the four squares {d4, d5, e4, e5} in the [[Center|center]] of the board. In conjunction with [[Center Manhattan-Distance|Center Manhattan-distance]] a constant [[Array|array]] might be considered as the base of [[Piece-Square Tables|Piece-square tables]]. Center distance is used in various [[Evaluation|evaluation]] terms, for instance to encourage the king to [[King Centralization|centralize]] in the [[Endgame|ending]], as well in [[Mop-up evaluation]].

=Lookup=
Rather than to calculate the Center distance from square coordinates, taking the max from the file- and rank- Center distance each, a lookup to a small array is appropriate here.

This is how the Center distance might be defined in [[C]] or [[Cpp|C++]]:
<pre>
const int arrCenterDistance[64] = { // char is sufficient as well, also unsigned
3, 3, 3, 3, 3, 3, 3, 3,
3, 2, 2, 2, 2, 2, 2, 3,
3, 2, 1, 1, 1, 1, 2, 3,
3, 2, 1, 0, 0, 1, 2, 3,
3, 2, 1, 0, 0, 1, 2, 3,
3, 2, 1, 1, 1, 1, 2, 3,
3, 2, 2, 2, 2, 2, 2, 3,
3, 3, 3, 3, 3, 3, 3, 3
};
</pre>
=In Register Lookup=
The avoid memory lookup purists may use two 64-bit in register lookups instead <ref>[http://www.talkchess.com/forum/viewtopic.php?t=13344 Two small in-register-lookups] by [[Gerd Isenberg]], [[CCC]], April 23, 2007</ref>, but most likely it don't pays off.
<pre>
int centerDistance(enumSquare sq) {
const U64 bit0 = C64(0xFF81BDA5A5BD81FF);
const U64 bit1 = C64(0xFFFFC3C3C3C3FFFF);
return 2 * ((bit1 >> sq) & 1) + ((bit0 >> sq) & 1);
}
</pre>
with
<pre>
bit 1 bit 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 . . . . . . 1
1 1 . . . . 1 1 1 . 1 1 1 1 . 1
1 1 . . . . 1 1 1 . 1 . . 1 . 1
1 1 . . . . 1 1 1 . 1 . . 1 . 1
1 1 . . . . 1 1 1 . 1 1 1 1 . 1
1 1 1 1 1 1 1 1 1 . . . . . . 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
</pre>

=See also=
* [[Center Manhattan-Distance]]
* [[Distance]]
* [[King Centralization]]

=References=
<references />

'''[[Squares|Up one Level]]'''

Navigation menu