How far is it to walk somewhere on a game's grid?

It depends on how you're allowed to move. If you can only go up, down, left, or right, the steps are the tiles across plus the tiles up. With diagonals you take fewer steps, but each diagonal crosses a square corner to corner, which is the square root of two, about 1.41 tiles. Flying straight is shortest of all.

To (2, -6) with diagonals: 6 stepsa diagonal step is √2 ≈ 1.41 tiles, so the walk is really 6.83 tilessteps6really walked6.83 tilesflying straight6.32 tilesdashed: straight lineorange: your path
Steps
6
Real length walked
6.83 tiles
Straight line (flying)
6.32 tiles

Many grid games count a diagonal as one step even though it’s longer. That’s why moving diagonally can feel like a shortcut.

Challenge: Using diagonals, find a trip of at least 4 steps where each step is really more than 1.41 tiles on average.

tiles
tiles

Play

Try the 3-4-5 trip with and without diagonals, then press "Run it: walk there."

Challenge: Using diagonals, find a trip of at least 4 steps where each step is really more than 1.41 tiles on average. The box under the picture turns green when you get it.

Stuck? Pick one of the examples from the “Try an example” menu, or press “New example.”

Understand

∣Δx∣+∣Δy∣ vs. Δx2+Δy2\lvert \Delta x \rvert + \lvert \Delta y \rvert\ \text{vs.}\ \sqrt{\Delta x^2 + \Delta y^2}

Without diagonals, every tile across and every tile up costs one step: ∣Δx∣+∣Δy∣\lvert\Delta x\rvert + \lvert\Delta y\rvert, the taxicab distance. With diagonals, you cover one tile across and one up at the same time, so the steps drop to the larger of the two. But a diagonal crosses a square corner to corner, and the Pythagorean theorem says that's 12+12=2≈1.41\sqrt{1^2 + 1^2} = \sqrt2 \approx 1.41 tiles.

The orange path is the walk, and the dashed line is the straight line you could fly. Press "Run it" to watch the hero walk it step by step.

Use

Every input has a unit menu, so you can type values in the units you already have. Results follow your units.

Show the work

  1. With diagonals, step diagonally until one direction is done, then go straight\text{steps} = \max(2, 6) = 6
  2. Real length: a diagonal step crosses a square corner to corner, √2 tiles\min(2, 6)\sqrt2 + \lvert 2 - 6 \rvert = 6.828\ \text{tiles}
  3. Flying straight (the Pythagorean theorem)\sqrt{2^2 + 6^2} = 6.325\ \text{tiles}

Export

Export PDF

Pick a target and how you can move. The panel compares steps, the real walking length, and flying straight.

  • Pathfinding avoids walls too. This is the open-floor distance, the best a path can do.

For learning and estimation. Verify with applicable codes, standards, and a qualified professional before using in design, construction, or safety-critical work.

Cheat card

4-way steps=∣Δx∣+∣Δy∣\text{4-way steps} = \lvert\Delta x\rvert + \lvert\Delta y\rvert
8-way steps=max⁡(∣Δx∣,∣Δy∣)\text{8-way steps} = \max(\lvert\Delta x\rvert, \lvert\Delta y\rvert)
8-way length=min⁡⋅2+(max⁡−min⁡)\text{8-way length} = \min\cdot\sqrt2 + (\max - \min)
straight=Δx2+Δy2\text{straight} = \sqrt{\Delta x^2 + \Delta y^2}
SymbolMeaningUnit
Δx,Δy\Delta x, \Delta ytiles across and up to the targettiles
  • A square's diagonal is √2 times its side, about 1.41. So diagonal moves cover more ground than they look.
  • Without diagonals the distance is called taxicab distance, like driving on city blocks.
  • Pathfinding in games, like the A* algorithm, uses these distances to guess how far away a goal is.

Print this card

Where it’s used

  • Computer Science
    Strategy and tactics games use these rules to decide how far a unit can move in one turn.
  • Computer Science
    Robots and delivery apps measure city distances the taxicab way, along the streets.
  • Hobbies & Crafts
    In chess a king moves 8 ways, so it reaches any square in max(Δx, Δy) moves.

Questions people ask

Why is a diagonal step longer?

It goes corner to corner across a square. By the Pythagorean theorem, that's √(1² + 1²) = √2, about 1.41 tiles.

What is taxicab distance?

The distance when you can only move along the grid lines, like a taxi on city blocks. It's the tiles across plus the tiles up.

Why do some games count diagonals as one step?

It's simpler, and it keeps movement on a grid easy to count. But it makes diagonals a little faster than going straight, which players often notice.

Updated : First published.

See everything that’s new on Maps for Math