Manhattan, Euclidean, and Chebyshev Distance Game

https://charlesgibbons.github.io/graph_detective/

Manhattan Distance (L¹ Distance)

Manhattan distance, also called taxicab distance, measures the distance you’d travel if you could only move horizontally or vertically—like navigating city blocks. If you’re at position (0, 0) and want to reach (3, 4), you can’t cut diagonally. You have to go 3 blocks right and 4 blocks down, for a total of 7 blocks traveled.

Formula: distance = |x₁ - x₂| + |y₁ - y₂|

When to use it: Navigation systems, grid-based games with four-directional movement, urban planning.

Example: In a 9×9 grid, the Manhattan distance from the center (4, 4) to the corner (0, 0) is 8 steps.

Euclidean Distance (L² Distance)

Euclidean distance is the straight-line distance you learned in geometry class. It’s what you measure with a ruler. Going from (0, 0) to (3, 4) is just 5 units in a straight line.

Formula: distance = √[(x₁ - x₂)² + (y₁ - y₂)²]

When to use it: Physics simulations, real-world measurements, most intuitive spatial problems, computer vision.

Example: The Euclidean distance from (0, 0) to (3, 4) is exactly 5 units—the hypotenuse of a 3-4-5 right triangle.

Chebyshev Distance (L∞ Distance)

Chebyshev distance, also called chessboard distance, measures how far apart two points are by taking the maximum of their coordinate differences. It’s called chessboard distance because it’s how far a king would need to move on a chessboard—kings can move diagonally, horizontally, and vertically one square at a time.

Formula: distance = max(|x₁ - x₂|, |y₁ - y₂|)

When to use it: Minimax algorithms, game AI (king movement), warehouse logistics, situations where you can move diagonally.

Example: From (0, 0) to (3, 4), the Chebyshev distance is 4—you move diagonally 3 times and straight once.

Comparing the Three

Imagine you need to get from the center of a grid to a point 3 squares right and 4 squares down:

  • Manhattan: 3 + 4 = 7 steps (only horizontal/vertical movement)
  • Euclidean: √(3² + 4²) = 5 units (straight line)
  • Chebyshev: max(3, 4) = 4 steps (diagonal movement allowed)

All three are valid ways to measure distance—which one you use depends on your constraints and what movement rules apply in your space.

Why This Matters

Understanding distance metrics isn’t just academic. They show up everywhere:

  • Navigation apps use Manhattan distance in cities (you can’t drive diagonally through buildings)
  • Robotics often uses Euclidean distance for smooth, natural movement
  • Games with grid-based movement and diagonal support use Chebyshev distance
  • Search algorithms and clustering (like k-means) use Euclidean distance by default
  • Minimax and game-playing AI use Chebyshev distance to evaluate board positions

The choice of distance metric can dramatically change how your algorithm behaves, so picking the right one for your problem is crucial.

Leave a Reply