Developer Diaries

The diaries we keep while building MKA Engine: what we built, why, and what we measured.

The diaries we keep while building MKA Engine. Each diary covers one decision, the reason behind it and the result we measured. For the engine itself, see the MKA Engine page.

Developer Diaries

Dev Diary #17: Making Impassable Terrain Borders Look Natural

· Open separately

A stepped, grid-aligned boundary on the left and a flowing mountain-following boundary on the right, beside a separate sea map

In short: Impassable terrain borders drawn to square measurements made mountains look stepped. A new method considers nearby land together; in the 1337 Mandates of History map package, the share of border lines aligned with the square grid fell from 0.822 to 0.129, while worldwide impassable area changed by about one percent. Small coastal fragments and islands were handled separately, and changes on land no longer shifted the sea map.

What was the problem?

Imagine the edge of a mountain range on a map. The old drawing measured terrain in squares eight pixels wide; a pixel is one of the tiny colored squares that make up the map. Each square received a single decision, so the border became a staircase following the square corners. Small fragments and holes could also spoil the result.

This diary is about the tool that prepares game maps, not MKA Engine's world simulation. The figures are from a comparison of the 1337 Mandates of History map package, using settings chosen for that game.

How did we solve it?

The old method classified non-overlapping squares, each eight pixels wide. In the Mandates of History map, the results document equates that width to about 20 kilometres. Once a square was classed as impassable, its border inherited the same decision. The resulting line followed the measuring grid.

The new method looks at an eight-by-eight-pixel neighbourhood around each land pixel. Results from nearby areas are gently combined: nearby squares influence the decision more than distant ones. If at least half of the resulting share around a land pixel belongs to impassable terrain, that pixel remains impassable. Water is excluded from this share, so coastal sea does not change a land classification. Openings for settlements, rivers and roads remain open as well.

Small fragments and islands need separate treatment

A flowing border alone does not resolve every tiny land feature. For Mandates of History, the game selected a threshold of 128 pixels for small pieces. Impassable fragments smaller than that threshold and connected to passable land became passable; small holes inside passable terrain were filled. Small islands that were entirely impassable were preserved.

A small impassable coastal fragment is removed and a small land hole is filled, while a tiny island that is entirely impassable remains

This distinction matters when reading the measurement. Under the old method, 400 impassable fragments touching passable land were each smaller than 64 pixels; the source does not report the total number of old fragments under 128 pixels. Under the new method, no impassable fragment under 128 pixels remained touching passable land. The 134 small islands that were entirely impassable were kept.

What did we see?

The comparison used two copies of the Mandates of History map configured for the same year, 1337. These figures belong to that map package; they are not general results for every game.

MeasureSquare-based borderTerrain-following border
Share of border lines aligned with the square grid0.8220.129
Worldwide impassable area22,831,005 km²22,609,150 km² (−1.0%)
Impassable area in the Trabzon–Erzurum region5,997 km²3,656 km²
Land map units: total / settled / corridor / impassable28,032 / 25,678 / 133 / 2,22127,772 / 26,420 / 130 / 1,222
Small passable holes filled—144 pieces, 17,718 km² in total
Share of border lines aligned with the square grid: 0.822 for square-based borders and 0.129 for the smoothed method

The grid-alignment share describes how often the class-change lines follow the old square grid. It fell from 0.822 to 0.129. Worldwide impassable area changed by about one percent; redrawn borders, the treatment of small fragments and preserved openings all contributed to that difference.

The drop in impassable map units from 2,221 to 1,222 does not mean that half the impassable area disappeared. A map unit is one of the pieces used to divide the world for the game; this count measures how many pieces belong to the impassable class, not their total area. As small pieces declined, the number of large impassable units rose from 563 to 570.

In the selected Trabzon–Erzurum region, impassable area fell from 5,997 to 3,656 km². This local figure measures a different area from the worldwide result, so we do not apply it to the whole map. Both compared packages met the map checks.

We separated sea-map choices from land changes

In the first attempt, changes to land also unexpectedly redrew the sea map: 5,472 of the previous 5,733 sea units moved. Land and sea choices had been drawing from the same repeatable number sequence. When the number of land choices changed, later sea choices in the sequence shifted to different places.

Giving the sea its own sequence removed that connection. During the transition, the number of sea units changed once, from 5,733 to 5,739. After that, two maps with different land choices retained the same 5,739 sea units.

Separate bowls supply choices to the land and sea maps so changes in one no longer shift locations in the other

Why did we choose this approach?

The square method could spread one decision across a large area, but it tied the border shape to square measurements. Making the squares smaller would increase the number of decisions without removing the grid. We chose a smoother border that considers nearby terrain together; we treated tiny fragments and the sea map with separate rules suited to each problem.

What does it cost?

The new border considers nearby squares together and makes a separate decision for small pieces. This comparison did not measure map-generation time or memory use, so we make no claim about speed gains. The results apply only to the border shape, area and map units in the specified map package.

What comes next?

This comparison covers one game's map only. Finding out whether other games' maps behave similarly will require new measurements.

Frequently asked questions

Why did the impassable area change?

Borders no longer follow the single decision of each square; nearby terrain is considered together. Worldwide impassable area in the 1337 Mandates of History map package changed by about one percent.

Does a near-halving of impassable map units mean the area also halved?

No. The unit count measures how many pieces belong to the impassable class, while area measures the surface they cover. In this comparison, area changed by about one percent.

Were small islands removed too?

No. Small impassable fragments attached to passable land and small land holes were handled; 134 small islands that were entirely impassable were preserved.

Can land-map changes affect sea partitions?

They no longer do. Sea choices were separated; after a one-time change during the transition, later land choices left the sea units unchanged.

For map keys, see Permanent keys on a game map; for the separation between the map tool and game settings, see The map tool and game settings. More information is on the MKA Engine and contact pages.