# Hex Map MathMarch 23, 2017 3:16 PM   Subscribe

I'm totally blind, and interested in a number of tabletop games which use hexes to regulate movement. I don't have an actual tactile map at this point, but have a giant Excel spreadsheet which is a somewhat cumbersome equivalent. I'm wondering about mathematical ways to tell the distance between two hexes, given (X, Y) coordinates, and determine what hexes are in, say, a 60-degree arc from a sepcific hex?

The spreadsheet is rather annoying to use in a number of ways, but most obvious is that I can't use a visual scan to count hexes quickly. I have to move over each hex, and the "borders," between them, one by one, which is why I was hoping for mathematical solutions of some sort.

The grid uses offset hex coordinates, with each even column offset, apparently. It's rather hard for me to picture mentally, unlike with a square grid.
posted by Alensin to Sports, Hobbies, & Recreation (12 answers total) 12 users marked this as a favorite

Maybe this: Hexagonal Grids. I'm not sure how necessary the graphics on this page are. The textual descriptions have some unicode characters like 'less than or equal to' (≤), and 'multiplication' (x) that I don't know how a screen reader will handle. It also has a lot of pseudo-code for the calculations.
posted by zengargoyle at 4:08 PM on March 23, 2017

That page is pretty bad for screen reader access in general, unfortunately. The graphics get in the way of understanding the info. It does seem like a rather comprehensive resource, though.

Some of the games I'm interested in, (Starfleet Battles and StarFire, to name examples) have weapons which can only fire in specific arcs. FIguring out whether a hex is in the arc seems like a relatively easy exercise visually, but is a pain in the neck without being able to see the map. Any advice for figuring this kind of thing out without visuals would be appreciated, if possible :)
posted by Alensin at 4:19 PM on March 23, 2017

The Hexagonal Grids page links to this older source material from 1997 that is a plain ASCII text file. There are a bunch of ASCII art drawings of hex grids to skip over. The code examples are more like the C programming language. This page is more like an old FAQ than a modern fancy website.
posted by zengargoyle at 4:22 PM on March 23, 2017

EDIT: Stupid preview! I see somebody has already posted this article. I'll do some more hunting around.

This article (http://www.redblobgames.com/grids/hexagons/) discusses how to write reasonably simple code for calculating these sorts of things for different types of hex coordinate systems. The trick seems to be converting whatever system you're using - offset, in your case - to cube coordinates, which makes the measurements easy to calculate though more difficult to visualise - for me, anyway!

The article is image heavy - hopefully you can get what you need from the text alone.
posted by obiwanwasabi at 4:23 PM on March 23, 2017

If you want to explore and understand tiled hexagons by touch, consider that circles tile exactly the same way. If you lay out a bunch of pennies and push them together, they will take the same form as hexagons would.

If you lay out the pennies in a square grid (placing them inside a square corner will help) and then you push each successive column up by a half penny, they will pack in a hex shape.

If I imagine pushing and skewing your spreadsheet columns upward in the same way, I can see that moving in the spreadsheet up direction is 1 hex distance, spreadsheet down is 1, spreadsheet right and left are both 1, but now right plus down also make 1 hex distance, as does left plus up.
posted by fritley at 4:24 PM on March 23, 2017 [4 favorites]

This article has an interesting approach: the mathematics are much simpler if you consider it a problem in three dimensions.
posted by scruss at 4:53 PM on March 23, 2017 [1 favorite]

(Further detail: a hexagon is just a cube point-on. It's a trivial calculation to work out the depth coordinate of a hex cell, and distances fall out naturally.)
posted by scruss at 5:11 PM on March 23, 2017

I'm afraid I don't have a resource to offer, but I do want to offer my encouragement to keep at it even if it's difficult. I played a lot of Starfleet Battles and Starfire back when they were new, and they were not only a hell of a lot of fun, but the firing arcs for weapons weren't all that easy to figure for sighted players either!

Anyway, to add to what you and Fritley said, the best way to mentally imagine a hex grid as opposed to a square grid is to imagine every other column is offset vertically by one half. So if you're in cell B3, then it's one movement point to travel to B2 or B4, but there's no way to move directly right or left. But with one movement point you can move to A1.5, which will be left and front or LF, or A2.5, which would be left and rear or LR, or C1.5, which is right and front or RF, or C2.5, which is right and rear which is RR. I hope that helps and doesn't confuse!
posted by ejs at 5:13 PM on March 23, 2017 [1 favorite]

You might find hexagonal card stock Link to seller of blank Hex Cards may be useful. There are a couple of different hex grids types, but I figure you could use a dot of nail polish or other indicator on the top corner or side of a hex card, and a slate and stylus to write whatever coordinates for grid type makes sense to you into the card stock. An axial coordinate system would let you perform transformations so you know what cards are adjacent to each other, count movement, etc. That way you can lay it out, physically feeling the cards.

Distance is pretty simple in hex. What's important to remember, is any movement that changes both X and Y (only possible along edges, and occurs when x and y move in opposite directions) counts for half in terms of total distance. If you need to calculate it without obstacles, you can do it either with the maximum of abs (difference in X), abs(difference in Y) or abs(difference in X - Difference in Y)

or you can use the following, adapted from http://www.redblobgames.com/grids/hexagons/ that treats a and b as points.
function hex_distance(a, b):
return (abs(a.x - b.x)
+ abs(a.x + a.y - b.x - b.y)
+ abs(a.y - b.y)) / 2

That said, given hex movement for a game might be them giving you hex squares and you figuring movement, I think counting half for movement that changes X and Y, and regularly for movement that only changes one may be most helpful.
posted by gryftir at 5:21 PM on March 23, 2017

Here's a paper for game developers that looks like it gives all the math: Hex Grid Geometry for Game Developers . I found it searching for "Taxi Cab Geometry" which is a niche that calculates a metric of a grid like the blocks in Manhattan that are needed for an efficient cab ride.
posted by sammyo at 9:35 PM on March 23, 2017 [1 favorite]

Not that the math is not doable but consider building a physical model with like a pin at the center of each hexagon and a piece of string to viscerally measure different distances.
posted by sammyo at 9:38 PM on March 23, 2017

Thanks for all the insight, everyone. :)

I'd love to get something tactile going, if at all possible, but for now the mathematical methods outlined here seem to work reasonably well. max(difference in x, difference in y), in particular, seems to be a pretty reliable distance measure.

I'm less certain how I can handle the arc measurements, but Starfire at least has a relatively simple system, whereby anything within a 60-degree cone of the 'rear," of a target can't be fired at. The six possible facings correspond to the six possible movement directions on a hex board. This is definitely one area where something physical is probably far easier to work with. :) I appreciate all the help and wisdom to be found here, even if it still look a bit intimidating.
posted by Alensin at 4:27 PM on March 24, 2017