top of page
Search

Hexagons rule the world!

Updated: Jun 5, 2020

Maths used in this blog: shapes, angles, tessellation, Pythagoras


Lots of famous computer strategy games are played in a world based on hexagons. For example, Civilization 5 has a hexagonal grid like this:



Age of Wonders looks like this:



Hexagonal grids are a lot better than square grids for many computer games, because the distance between the hexagon centres is constant. For example, as shown in Catlike Coding:


However, although a square grid might look simpler, moving on a square grid in a computer game is more difficult to get to work, because the distance between square centres varies. For example:

By Pythagoras’ Theorem, the diagonal distance between square centres is greater than the horizontal or vertical distance between square centres.

So let’s explore how to build a world made from hexagons!

We can start with a tessellation of hexagons:

A tessellation is a pattern of shapes that completely fills a surface, with no gaps. Hexagons work because the interior angle of a regular hexagon is 120 degrees, and three angles meet at a corner to make 360 degrees in total.

Let’s think about the coordinates of the hexagon centres, by looking more closely at just two of the hexagons.We’ll say that the hexagons have a side length of 1, just to keep things a bit simpler.

A hexagon is made of six equilateral triangles, so length AV is also 1.

We can get length AM either by trigonometry, or Pythagoras’ Theorem. Using Pythagoras,

The distance between the hexagon centres is just twice this length, and so

AB = √3

If centre A is at coordinates (0, 0), we can work out the coordinates of the centre B.

The y coordinate is length BC, which is the same as the AM that we worked out earlier: BC = √3/2.

The x coordinate is length AC, which is just equal to a side length of the hexagon plus another half side length: AC = 3/2.

We’ve worked out that if the first hexagon has a centre of (0, 0), then the second hexagon will have a centre of (3/2, √3/2).

However, although we’ve worked out how to tessellate hexagons on a flat surface, we still can’t do much to create a world based on hexagons. It would be good to tessellate hexagons with different heights, so that we can have hills and valleys in our world!

Computer games do this in a number of ways. Some use a combination of terraces and cliffs. Here is an example from Catlike Coding.



We will use a simpler version of this, and create a tessellation of hexagons, rectangles and equilateral triangles for our hilly world:


The rectangles and triangles surrounding each hexagon can be used as ‘spacers’, to create slopes between the hexagons so that the hexagons can then sit at different heights.The hexagons form flat plateaus and the rectangles and triangles form the slopes.Here is an example:


That’s just about all the maths needed for a hexagon-based world! We can make things more exciting by adding features like trees, rivers, lakes and the ocean. Here are two examples on different scales:





The mathematical rules which describe the flow of the rivers will be explained in a later blog. The colours of different parts of the hexagonal map shown above are calculated using rules for biomes – the white colour at the top of this map represents an arctic biome, for example.

If you would like to explore the hexagonal world further check out our app!






27 views0 comments

Recent Posts

See All
bottom of page