Any faster method?
- by rajeshverma423
Manhattan distance is used to the center in chess code that uses an 0x88 board .
0x88 board is 128 square.
public static final byte DISTANCE[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 7, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 7, 6, 7, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 7, 6, 5, 6,
7, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 7, 6, 5, 4, 5, 6, 7, 0, 0,
0, 0, 0, 0, 0, 0, 7, 6, 5, 4,
3, 4, 5, 6, 7, 0, 0, 0, 0, 0,
0, 7, 6, 5, 4, 3, 2, 3, 4, 5,
6, 7, 0, 0, 0, 0, 7, 6, 5, 4,
3, 2, 1, 2, 3, 4, 5, 6, 7, 0,
0, 7, 6, 5, 4, 3, 2, 1, 0, 1,
2, 3, 4, 5, 6, 7, 0, 0, 7, 6,
5, 4, 3, 2, 1, 2, 3, 4, 5, 6,
7, 0, 0, 0, 0, 7, 6, 5, 4, 3,
2, 3, 4, 5, 6, 7, 0, 0, 0, 0,
0, 0, 7, 6, 5, 4, 3, 4, 5, 6,
7, 0, 0, 0, 0, 0, 0, 0, 0, 7,
6, 5, 4, 5, 6, 7, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 7, 6, 5, 6,
7, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 7, 6, 7, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0
};
Is there any other faster method instead of 0x88 to find distance?