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.
- 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.
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
Without diagonals, every tile across and every tile up costs one step: , 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 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
- With diagonals, step diagonally until one direction is done, then go straight
\text{steps} = \max(2, 6) = 6 - 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} - Flying straight (the Pythagorean theorem)
\sqrt{2^2 + 6^2} = 6.325\ \text{tiles}
Export
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
| Symbol | Meaning | Unit |
|---|---|---|
| tiles across and up to the target | tiles |
- 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.
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.
Related exhibits
- Start here
Frame rate: why some games go slow-mo when they lag
Move 5 pixels every frame and your speed depends on the frame rate. Multiply by the time per frame instead, and every computer runs the same speed.
- Go further
Hitboxes: how a game knows you got hit
Games wrap every character in an invisible circle or box. A hit is just a distance check, and the Pythagorean theorem does the work.
- Also try
Ladder against a wall: how high will it reach?
A ladder, a wall, and the ground make a right triangle. Pythagoras does the rest.
- Also try
World seeds: how one number builds a whole world
Games make “random” numbers with a formula: multiply, add, keep the remainder. Start from the same seed and you get the same world, block for block.
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.