I have learned new things while trying to solve programming puzzles. One of these is the calculation of distance.

There are many metrics to calculate a distance between 2 points **p (x**_{1}, y_{1}) and **q (x**_{2}, y_{2}) in xy-plane. We can count Euclidean distance, or Chebyshev distance or manhattan distance, etc. Each one is different from the others.

To simplify the idea and to illustrate these 3 metrics, I have drawn 3 images as shown below.

The first one is Euclidean distance. The distance can be defined as a straight line between 2 points. The formula to calculate this has been shown in the image.

In Chebyshev distance, all 8 adjacent cells from the given point can be reached by one unit.

The last one is also known as **L**_{1} distance. The distance between two points is the sum of the (absolute) differences of their coordinates. E.g. it only costs 1 unit for a straight move, but 2 if one wants to take a crossed move.

**Applications of these in Chess**:

In chess, the distance between squares on the chessboard for rooks is measured in Manhattan distance; kings and queens use Chebyshev distance, andbishops use the Manhattan distance (between squares of the same color) on the chessboard rotated 45 degrees, i.e., with its diagonals as coordinate axes. To reach from one square to another, only kings require the number of moves equal to the distance; rooks, queens and bishops require one or two moves (on an empty board, and assuming that the move is possible at all in the bishop’s case). (*Wikipedia*)

### Like this:

Like Loading...

*Related*

Thank you for sharing 🙂

thank you for clear explanation

Thank u.

Great explanations!