Center Distance

Home * Chess * Squares * Center Distance

The Center Distance is the distance (also known as 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 of the board. In conjunction with Center Manhattan-distance a constant array might be considered as the base of Piece-square tables. Center distance is used in various evaluation terms, for instance to encourage the king to centralize in the 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 C++: 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 }; =In Register Lookup= The avoid memory lookup purists may use two 64-bit in register lookups instead, but most likely it don't pays off. int centerDistance(enumSquare sq) { const U64 bit0 = C64(0xFF81BDA5A5BD81FF); const U64 bit1 = C64(0xFFFFC3C3C3C3FFFF); return 2 * ((bit1 >> sq) & 1) + ((bit0 >> sq) & 1); } with 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

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

=References=

Up one Level