Hex Grid Distance Calculator
Calculate the shortest path distance between two hexagonal cells using cube coordinates (x + y + z = 0).
How to Use the Hex Grid Distance Calculator
- Enter Hex 1 coordinates — the cube coordinates (x, y, z) of your starting hex cell. All three must sum to zero.
- Enter Hex 2 coordinates — the cube coordinates of your destination hex cell.
- Check the validation — if your coordinates do not satisfy x + y + z = 0, the calculator will display an error message.
- 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.