The Center Manhattan-Distance is the Manhattan-Distance or number of orthogonal 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 Distance a constant array might be considered as the base of Piece-Square tables. Center Manhattan-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 Manhattan-Distance from square coordinates, taking the sum from the file- and rank- Center Distance each, a lookup of a small array is appropriate. This is how the Center Manhattan-Distance might be defined in C or C++:
Avoid Memory lookup purists may use following calculation. The routine first extracts file and rank. If either is less than 4, its ones' complement is used, to get the file or rank wise Manhattan Center Distance from the two lower bits each (while the third lowest bit 2, is always set).
The file and rank distances are added for the final Manhattan Center Distance. The slight optimization considers each summand has bit 2 set, to perform the 'add' with a final post-mask 7, rather than to add two pre-masks with 3.
Table of Contents
The Center Manhattan-Distance is the Manhattan-Distance or number of orthogonal 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 Distance a constant array might be considered as the base of Piece-Square tables. Center Manhattan-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 Manhattan-Distance from square coordinates, taking the sum from the file- and rank- Center Distance each, a lookup of a small array is appropriate. This is how the Center Manhattan-Distance might be defined in C or C++:Calculation
Avoid Memory lookup purists may use following calculation. The routine first extracts file and rank. If either is less than 4, its ones' complement is used, to get the file or rank wise Manhattan Center Distance from the two lower bits each (while the third lowest bit 2, is always set).The file and rank distances are added for the final Manhattan Center Distance. The slight optimization considers each summand has bit 2 set, to perform the 'add' with a final post-mask 7, rather than to add two pre-masks with 3.
with following generated x86 Assembly:
See also
Forum Posts
What links here?
Up one Level