1
$\begingroup$

Say I have this map:

Hex Map with Coordinates

The first two digits on each hex represent the X axis, the last two digits the Y axis, with 60º between both.

How do I calculate the shortest distance between two hexes? E.g. the distance between (01,01) and (07,02) is 6. The distance between (02,08) and (04,04) is 5.

Preferably without a conditional algorithm, of which I've seen a couple... All the coordinates being positive will hopefully make it simpler.

  • 0
    Why not just count how many hexes you have to move to get from point 1 to point 2 on a shortest path? Yes, it will pad the distance in certain cases (01,01 to 07,02 becomes 7 rather than 6), but it's **simple**.2012-07-15
  • 1
    This definitely needs to be migrated. The answers require non-RPG math or programming expertise, hence it belongs where such experts are found, not here.2012-07-15
  • 0
    Can you explain what you mean by a "conditional algorithm" that you don't want? An explicit formula will probably need a few cases, but can be done without a full-fledged graph search.2012-07-15
  • 0
    By conditional I mean that I've seen a couple algorythms meant for programming languages; e.g. "if (x>y) then foo; else bar;". If at all possible, I'd like to have a direct formula to calculate the distance.2012-07-16

1 Answers 1