Squares, hexagons and distance

Most traditional board games use squares to segregate space.

Square terrain

Space is divided evenly. Lines are easy to draw. Everything is structured. Bliss.

Except that when you need to move to a diagonal square, you need to move 2 squares instead of √2 squares. Wait, a non-integer movement? That cannot be tracked!

Dungeons & Dragons 4th Edition (a tabletop RPG with physical positional tracking) state that a diagonal square movement costs the same as a perpendicular square movement. Meaning you just move 1 square to reach that diagonal square. This also has its problems.

For example, there’s a concept of push in D&D, where as long as the target being pushed is moved further away, it counts as a push. Bringing us to this situation:

Perpendicular push movement

I talked about this briefly on my other blog, but didn’t go into the math details. So the blue dot is you, the red dot is the enemy, and the brown dot is where the enemy is pushed to.

The distance between you and the enemy is (do the Pythagoras thing) 2√2 (approx 2.8284). The distance between you and the final position of the enemy is √10 (approx 3.1623). Sure √10 is greater than 2√2, so mathematically speaking, the enemy is moving away from you. But common sense is telling me otherwise, because the direction of the push emanates from you.

Anyway, to combat the shortcomings of the square terrain, there’s the hexagonal terrain.

Hexagonal terrain

Under this division of space, all adjacent spots are equidistant to your position. Well, it still has its problems. You still need 2 hexagons of movement to reach the first hexagon directly above you.

Hexagonal movement

So what’s the actual cost of movement? Let’s look at this extracted diagram:

Hexagonal movement calculation

Let h be half of the actual distance. Doing the Pythagoras thing again, we have
1^2 = h^2 + (1/2)^2
=> 1 = h^2 + 1/4
=> h^2 = 3/4
=> h = √3/2 (h is positive)

Therefore, the actual distance is 2h which is √3 (approx 1.7321). Not quite 2 hexagons, is it?

This is part of the reason why, when games are created on computers, that these limitations disappear. Because computers can do the distance calculations and tracking. You can move in any direction, for any amount of units of movement, as long as you do not hit anything.

And that is called collision detection.

  1. Tommi Brander

    Well, I’d say the (continuous version of the) metric provided by the squares is topologically equivalent to the euclidean metric of R^2. They both come from equivalent norms. I’m not sure if there is an inner product associated with the square metric.

  2. Vincent

    Hi Tommi, I think I’m very far removed from my math already… How would the R^2 space be equivalent to the D&D square board? A diagonal movement costs 1 square… Can you elaborate?

  3. Tommi Brander

    Hey Vincent.

    If we extend the square metric to continuum (so it is as if it covered the entire R^2 and not only few discrete points) we get topological concerns; that is, which sets are open (and thereby which sets are closed). The continuity of functions depends on topology. So, when I say that the metrics are equivalent, I mean that they generate the same topology and thereby keep the same functions continuous.

    Another way to think about it is that there is a homeomorphism between R^2 with Euclidian (standard) metric and R^2 with square metric. Homeomorphism is a bijection (one-to-one mapping that reaches every part of the target set, whatever it is called in English) that is continuous and further has a continuous inverse mapping.

    I think the mapping is even a diffeomorphism and so retains differentiability.

    Of course the two measures of distance are not equivalent in all ways. If you build a graph so that all squares with distance 1 are connected, there will be different graphs made with D&D 3rd edition’s metric, hexagonal metric and 4E metric. Different in that there is no isomorphism between them, where isomorphism is one that keeps the same edges (squares) connected.

    Does this clarify? I fear not.

  4. Vincent

    Tommi, I understand what you mean now (I think). If we map the square metric to the Euclidean R^2 space, the squares would be warped, and they would cover a “larger” space, so to speak (since both spaces/metrics are infinite). For every square, there is a unique (x,y) point where it maps to. And vice versa (hence the bijection).

    I’m not sure the average D&D player cares to that point though…

    Thanks for clarifying.

  5. Tommi Brander

    You have basically got it.

    The other notable feature of the equivalence is that the distances between points remain roughly the same in that they are at worst multiplied by some constant. This makes the two metrics basically equivalent for calculus. (When integrating this is known as change of variables.)

Comments are closed.