This is a series about the basic components of a world generated LoreGen.

Note: as of version 0.11, the base shape of continents has changed to irregular regions, not rectangles, so some of the screenshots need to be updated and descriptions tweaked.

Updated as of version 0.1

The last post discussed the erosion algorithm for randomizing the shapes and borders of things. The case we’ve been using so far is continents. This post will continue to explore how these shapes are built, and will also use continental coastlines as an example.

As of the last post, our continents looked like this:


They’re starting to look like landmasses, but they’re still very obviously blocky and grid-based.

In order to give the continents more interesting shapes, LoreGen will apply edge patterns before eroding.

What is an edge pattern? It’s what it sounds like: a pattern to represent the shape of a piece of the edge of some region. In this case, that means coastline.

The Problem With Erosion

Let’s think for another moment about why we need edge patterns, or some other mechanism to supplement erosion as the primary tool for generating shapes of regions.

It’s actually pretty clear from the map: if you’re always eroding away some percentage of a square block (20-40% as the erosion rate), the blocks on average are still going to appear square.

Edge patterns effectively set a different starting shape for the erosion algorithm to work on. This prevents the final patterns from looking square on average, which prevents coastlines from having a “blocky” look.

Edge Patterns

Edge patterns are defined in a data file: EdgePatterns.csv.

The data file defines the various shapes that can be used for different kind of edge blocks.


A sample edge pattern from “EdgePatterns.csv”

The data is formatted as follows: the first line of data defines the size of the edge pattern. (Edge patterns can be scaled up or down; for example, if a block was 20 by 20, LoreGen would be able to apply a 10 by 10 pattern by stretching the pattern to twice its size on each dimension.) By default, the edge of all edge patterns is 10, as 10 by 10 is the default size of sub-grids (as described a few posts ago), so no scaling is required.

The next line defines how many and which edges are borders to the external area. In terms of continental coastlines, this basically means which sides of that block hit the ocean. For an island, it’s all four sides: to the North, South, East, and West. A block that is on the east coast of a continent might only be touching water on one side: East.

LoreGen knows from its surrounding blocks what edges of the given block touch the water.

The next X lines (where X is the size of that edge pattern; by default ten) actually lay out the edge pattern. Each row must have X cells (since an edge pattern is always square). Each cell contains one character: a period, an “O,” or an “X.”

A cell with a period marks something outside the region. In the case of a continental coastline, this means it’s part of the ocean. An “O” means it’s on the border of the region. In the case of a continental coastline, this is the actual coast. An “X” means it’s inside the region. In the case of a continental coastline, this means it’s inland.

As you can see from the example I included a screenshot of, the edge pattern visually represents a shape. The example represents a small, almost circular, island.

Applying an Edge Pattern

Let’s go look at our continents again, and go back a couple of steps to when we had detailed edges but had not applied the erosion algorithm at all.

Zoomed in coastline

Zoomed in coastline

If we apply edge patterns to the all of the coastal blocks, here’s what it looks like.


It’s still very uniform, but there’s some basic smoothing that’s been applied, especially to corners. The overall feel of the coastline is slightly less blocky, and this will be even more true as the shape of continents is varied.

Note that if we applied more edge patterns into the data file — which I plan on doing for future versions — we’d get something less uniform. As a test of this, I modified EdgePatterns.csv to throw in some more edge patterns beyond the default.

It still looks pretty uniform, but you can see some slight jaggedness:


Now let’s take that and apply the erosion not to the macro shape of the continents, but the just on the micro level, to the contour of the coastline.


We’re finally starting to see some character in the coastline, but let’s see what it looks like when we also apply the erosion algorithm to the overall continent shapes as well as the coastline.


The result is continents and coastlines that have less predictable and more interesting shapes.

In summary, the shape of any region — for example, a continent — is defined by its border — for example, its coastline. And in LoreGen, three techniques are used to determine those borders:

  1. breaking the word blocks that make up borders into smaller sub-grids so there’s finer detail
  2. applying edge patterns to those subgrids to give the border a base shape
  3. eroding away the remaining border to give it a unique shape

The next post looks at “seas” which are smaller bodies of water that appear within some continents.