Thursday, July 3, 2014

Hex Vs. Square, How Do They Compare?

I’ve been doing a lot of research and exploration of hex grid systems lately for a personal project, and I thought it might be good to share the things I’ve found so far. Not only does this provide a good one-stop-shop for learning about hex systems, but it’s an excellent way to organize and share my notes with other people in order to hopefully discover some new things.


Let’s start with the basics. What is a hex grid system? Simply put, it’s a grid that uses hexagons instead of squares.


On the surface, this seems pretty arbitrary, but hex grids have some advantages over traditional square grids.

For instance, in a square grid system there’s some ambiguity when it comes to defining “adjacent” spaces. Do you include diagonal spaces, or just those who share a side with the current square? For the purpose of this blog, I will be defining adjacent spaces as any spaces that “touch” the current space. So, in a square grid, that’s eight adjacent squares for any square that’s not an “edge” or “corner” square. With a hex grid, there’s no ambiguity. Every adjacent hex shares a side with the current hex, and thus there are always 6 adjacent hexes for any hex that’s not an “edge” hex.

Similarly, there’s ambiguity when discussing distance in a square grid system. Any adjacent square that shares a side with the current square is a distance of one square away. Logically, you could say the same for diagonally adjacent squares in the sense that a chess piece such as the king, which can move one space in any direction, can move to diagonal squares and it “counts” as having moved a single space. In reality however, the distance from a square to a diagonally adjacent square is the square root of two. So accurately calculating distance from one square on a grid to another could potentially be quite difficult to do. By contrast, distance from a hex to an adjacent hex is always one, which can make calculating distance in some cases much easier. It also makes it easier to define distance-related rules such as “game piece X may move Y number of spaces.” While this seems like a simple rule to us, it’s because we can view grids in a more abstract way. If you try to write this as an algorithm, it becomes much more complex when you have to factor in diagonals as well as horizontal or vertical adjacent spaces.


You may be asking at this point, if there are so many advantages to using a hex grid system, why is the square system more common? For one, a square system is more intuitive to navigate. In a square grid, the two axes (commonly referred to as X and Y) are perpendicular, so one of them runs vertically and the other runs horizontally. This makes it very easy for us to see that the distance between two spaces is X spaces horizontally and Y spaces vertically. In a hex grid system, the axes are generally not perpendicular, but rather at an angle to one another, which is more challenging for us to visually navigate. Some calculations may be simpler with a hex system, but a square system is easier for us as humans to understand.


(Please note that the third axis for the grid system is unnecessary. I’ll be going more in depth into the differences between a hex grid coordinate system and a square grid coordinate system in the next post.)

Both systems have their advantages and disadvantages. Ideally, we would like to be able to convert data from one system to another, but this has many challenges, and it is the goal of this blog to explore some of those challenges.

No comments:

Post a Comment