Any faster method?

Posted by rajeshverma423 on Game Development See other posts from Game Development or by rajeshverma423
Published on 2012-06-30T11:04:31Z Indexed on 2012/06/30 15:26 UTC
Read the original article Hit count: 167

Filed under:

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?

© Game Development or respective owner

Related posts about chess