Hex Grid Distance Calculator

Calculate the shortest path distance between two hexagonal cells using cube coordinates (x + y + z = 0).

Hex 1
Hex 2
Distance
3 hexes
Minimum steps between the two hex cells
|Δx|
3
|Δy|
2
|Δz|
1

How to Use the Hex Grid Distance Calculator

  1. Enter Hex 1 coordinates — the cube coordinates (x, y, z) of your starting hex cell. All three must sum to zero.
  2. Enter Hex 2 coordinates — the cube coordinates of your destination hex cell.
  3. Check the validation — if your coordinates do not satisfy x + y + z = 0, the calculator will display an error message.
  4. Read the distance — the result is the minimum number of hex steps to travel from Hex 1 to Hex 2.

Understanding Cube Coordinates for Hex Grids

Hexagonal grids present a fundamental challenge: unlike square grids where each cell sits neatly at integer (row, column) coordinates, hex cells are offset in alternating rows. This makes distance calculations messy when using offset coordinates. The cube coordinate system solves this problem elegantly by introducing three axes that constrain every hex cell to satisfy x + y + z = 0.

The Distance Formula

In cube coordinates, the distance between two hexes is the maximum of the absolute differences along each axis, which also equals half the sum of all three absolute differences:

distance = (|x1 - x2| + |y1 - y2| + |z1 - z2|) / 2

This gives the exact minimum number of hex steps required to move from one cell to another, accounting for the hexagonal geometry where each cell has six equidistant neighbors.

Why Hex Grids Are Superior to Square Grids

In a square grid, diagonal movement is ambiguous — do diagonal moves cost 1 step or 1.41 steps? Hex grids eliminate this problem entirely. Every neighboring hex is exactly the same distance away, providing six equidistant directions instead of the confusing eight directions of a square grid. This makes hex grids the preferred choice for wargames, strategy games, and any application requiring fair and consistent spatial reasoning.

Applications in Game Design

Hex grids appear throughout the tabletop and video game landscape. Games like Civilization, Settlers of Catan, and Twilight Imperium rely on hexagonal tiles for movement, territory control, and line-of-sight calculations. In tabletop RPGs, hex grids provide a more realistic alternative to the traditional square battle map. Understanding cube coordinate distance is essential for building pathfinding algorithms, AI movement logic, and range calculations in any hex-based system.

Converting From Offset Coordinates

If your game uses traditional row/column offset coordinates, you can convert to cube coordinates using these formulas. For odd-row offset grids: x = col - (row - (row & 1)) / 2, z = row, y = -x - z. Once converted, the distance formula above works perfectly. Many game engines and map editors provide this conversion automatically.

Frequently Asked Questions

Cube coordinates represent hexagonal cells using three axes (x, y, z) where x + y + z always equals 0. This constraint maps a 2D hex grid into a 3D coordinate space, making distance calculations and pathfinding algorithms much simpler and more elegant than offset coordinates.
The constraint x + y + z = 0 ensures that each hex cell maps to exactly one point on a plane that cuts diagonally through 3D space. Without this constraint, multiple 3D points could map to the same hex, breaking the coordinate system. It is the mathematical foundation of the cube coordinate approach.
The distance between two hexes in cube coordinates is: (|x1-x2| + |y1-y2| + |z1-z2|) / 2. This gives the minimum number of hex steps needed to travel from one cell to another, equivalent to the Manhattan distance divided by 2 in the cube coordinate space.
Hex grids are widely used in tabletop wargames (Warhammer, Battletech), board games (Catan, Twilight Imperium), strategy video games (Civilization, Heroes of Might and Magic), and tabletop RPGs. They provide more natural movement than square grids because all six neighbors are equidistant.
For odd-row offset coordinates: x = col - (row - (row & 1)) / 2, z = row, y = -x - z. For even-row offset: x = col - (row + (row & 1)) / 2, z = row, y = -x - z. The conversion depends on whether your hex grid uses pointy-top or flat-top hexagons.