-4
\$\begingroup\$

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?

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Basic mathematics? If you don't understand how to calculate the manhattan distance you need to go back and read those articles on manhattan distance because they said how to calculate it. \$\endgroup\$ Commented Jun 30, 2012 at 11:11
  • \$\begingroup\$ In simple words manhattan distance is going squares of corners,I got that. Any other faster method? \$\endgroup\$ Commented Jun 30, 2012 at 11:29
  • 3
    \$\begingroup\$ You're new to this site. I suggest you have a look at other up-voted questions to understand how to ask good questions. Good questions get excellent answers. \$\endgroup\$ Commented Jun 30, 2012 at 12:53

1 Answer 1

2
\$\begingroup\$

To make sure you know how Manhattan Distance works

Manhattan distance is the sum of the total difference along each axis. In regular geometry you use Pythagoras' theorem:

where a and b are the difference along the x and y axes, and c is the total distance between the points.

In Taxicab geometry you don't need to square it. It's extremely simple. The distance between one point and another is just the sum of the distance along each axis. In 2D:

x difference + y difference = Manhattan distance

The fast method to calculate this

Create a function which takes two points and calculates the above. If you don't know how to do that, you need to go find a tutorial and start learning your programming language through it.

\$\endgroup\$
1
  • \$\begingroup\$ +1 for not banging your head against the wall after reading his comment :D \$\endgroup\$ Commented Jun 30, 2012 at 12:51

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.