January 18, 2022

Ex Nihilo IV: Tectonics

My previous work involved manually drawing out the tectonic boundaries. With the advantage of distance, I'm no longer married to that concept. Instead, we can generate them from scratch.

To approximate an irregular but blue-noised grid, I'll grab a Poisson Disk Sample from all points on the map. This is a pretty useful algorithm to know, so it's a good chance to rewrite it to be a bit more efficient. After generating the points, tectonic plates are generated as a Voronoi map with the Poisson Disks as the centers (the shapes it generates are too uniform, so I'll revisit that later). A Poisson radius of 100 hexes yields 36 centers and the following map. Oceanic plates (approximately % of the total area, close to Earth) are shown in a lighter shade.

Each plate is assigned a random Euler pole and angular rate of rotation. I can use this to find the strength of collision at each boundary. I'm not super satisfied with the equations I'm using but they can always be modified.

Next, the rate of tectonic uplift for a given hex is determined by each fault's effect on that hex, with a bonus for continental plates (which are lighter and tend to "float"). High uplift values will generate mountains and island chains.

In the past I've played around with various combinations of Perlin noise, domain warping, and other forms of distortion applied to the uplift map to get interesting topographies. The final topography is heavily dependent on the uplift value: the droplet model algorithm gives interesting local topography but is ultimately overpowered by the underlying uplift. So it's important to get it mostly right to begin with. That being said, I find it important not to get too caught up in fine details when there is underlying code to fix. And there is a lot of code to fix and refactor.

To get a rough idea of the kinds of terrain this will generate, we can mock up the elevation values from uplift (essentially scaling from 0 to our max height 25599) and apply a sea height of whatever makes the land percentage 29%. I changed the continents slightly from the plate image above.

Note how straight the lines are, something that will need to be fixed.

The elevation generator is quite slow (particularly given the size of the map), and so it may be a while before I have this round of kinks worked through. My basic algorithm is a droplet model which erodes land based on the tectonic uplift, water erosion, sediment deposition, and coastal erosion. In the past I have used the Wei-Zhou-Dong algorithm for depression filling (which makes all rivers flow to the sea), but I am not terribly pleased with it this time around. We'll see.

December 28, 2021

Elevation XVIII: A Bigger Map

The map I've been using is about half the size it should be. So I wrote some code to generate a map of arbitrary size. I'm actually a little mad about it, since it took about half an hour to generate what took me months to figure out 3 years ago. But I'll be better for it.

The next step is to regenerate elevation and terrain, wind and currents, climate and all that good stuff.

If you're just starting out, don't make the same mistake I made; do this in a language that can handle big data efficiently. Python can barely chug along through this stuff.

December 20, 2021

Ex Nihilo III: River Travel

 The first obstacle I encounter when finding river routes is that there's no immediate correlation between AP and river vehicles (barges, small ships, etc). So we begin with some initial thoughts and observations.

Almost all relevant river travel will be by barge or similar vessel. The navigability of a river will then be dependent on the depth of the river and to some extent its velocity - some rivers may be too fast to pole or tow against. Once width becomes an issue, the point is moot anyway.

The numbers I'm getting from my velocity model (I've since tweaked the width and depth equations slightly) appear roughly commensurate with the numbers ORBIS uses. They apply a constant 65km/day rate, which is about 1.6 mph. If I only consider 10 hrs of daylight travel, we can get that number up to 3.2 mph (ah, what if I used daylight hours based on latitude as my indicator? Thoughts for later). This indicates that river travel will only be faster than dirt roads or lower. However, the cost will be much cheaper than overland travel. This kind of problem can be left with partially incomplete information, as this makes the party's decisions much more realistic.

Assume a river with downstream velocity $v = 1.837$ mph. This is equivalent to a day's journey (10 hours) of 18.37 miles. For a party traveling on land with 3 AP, that's the equivalent of 6.123 mi/AP. My assumption here is that river travel works by the same AP travel rules as travel on foot.

By the same measure, moving upstream against the current is a much slower affair. ORBIS puts upstream motion (by poling, horse-hauling, or even tacking) at 15 km/day. Therefore, we can put an upper limit on navigable rivers at where this advantage becomes moot, about 2 mph of downstream velocity.

Consider two hexes, A and B. The river flowing from A to B is 26 ft deep, 612 ft wide, and has a velocity of 1.837 mph. There is also a high road which runs throughout.

Traveling along the road with 3 AP takes 2.56 total AP (thanks to the maintained road) and 0.85 days. However, since the river is not quite fast enough, rafting down takes 3.27 AP and 1.09 days. These differences can add up for a long journey.

Say we wish to travel back from B to A. The road journey takes 0.85 days as before. But fighting against the current slows our barge to 25.6 AP, 8.5 days!

This has a few implications for travel and trade. First, there will be a severe resource asymmetry for downstream collection centers. In this case, a good might be 10 times more expensive in B than in A! Due to the upfront costs involved, trade will always move by water if possible, regardless of small disadvantages in time. Second, travel will likely also be asymmetric, as it will often be faster to raft downstream and walk back upstream. In fact, we have real-world examples of this, where cheap flat rafts would be brought down the Mississippi then disassembled in New Orleans, after which the crews would travel on land back up the river.

So it seems we will need a few different pathfinding tools:

  • Routes by land only
  • Routes favoring water wherever possible
  • Routes combining water and land for maximum speed

December 16, 2021

Ex Nihilo II: Routing

I worked the number of total polities down to the low 2000s. This is probably still pretty high, but it takes a while to simulate warfare between so many cities, so I'll call it here.

The next thing is to place roads, according to Higher Path rules. I briefly tried a modification, where the number and type of roads was determined by the total infrastructure, and not the infrastructure category. For example, rather than primary, secondary, and tertiary routes, a hex with an infrastructure of 61 could have 1 low road (35), 1 cobbled road (20), 1 cart track (6), and finish out the 6 total connections with trails (0). This all adds up to $35\cdot1 + 20\cdot1 + 6\cdot1 + 3\cdot0 = 61$ total. However, I didn't much like this as the resultant network was weird-looking, with all routes being pulled towards the local center.

It's got kind of an artsy feel to it, but massive infrastructures would be necessary to make any kind of even network. So I went back to the old way but will continue to think about it.

It's a busy-looking map, but remember that this is primarily DM-facing (more accurately, computer facing). All we need to know for now is that there is a road from A to B of type C. From hence we can apply A* route-finding algorithms to find optimum travel paths between hexes. I'm using the AP weights from here, assuming a normal walking pace. The function will return both the route taken and the cost in AP, so that travel times can be determined for the trade network.

Note that these don't take into account the convenience of river travel if available. A comprehensive model will present the players with a plan involving the cheapest method: a boat from A to B, then overland from B to C, then finally upriver to D. For this, I'll probably rely heavily on the fascinating work by ORBIS. In the same manner, I need to re-address sea travel, so those are next on the list.

December 13, 2021

Ex Nihilo I: Starting Off

It's been a while since I've had much time to devote to my projects. I'm starting to get the itch to actually play again, and the problem rears its head that it's just not done. Nor will ever be done. I've spent a good deal of work on the tribal development system, which would eventually give rise to settled civilizations and more complex societies. I still want to develop that out, but a project of this magnitude is lifelong.

My thought at the moment is to generate a more or less fully populated world, without the benefit of the procedural history system. I would lose a lot of that organic weirdness, like the records of wars and such, but it would significantly shorten the timeline to a version that could be used in an actual game.

Instead of slowly planting and growing cities, I just place them according to the design principles I developed last year: the carrying capacity is determined first by the desirability of the location and then by proximity to nearby cities. This yields between 15,000 and 20,000 cities, ranging in size from villages of 200 to cities of about 75,000 inhabitants.

Infrastructure map: humans (green), elves (red), dwarves (blue), halflings (orange)

Not sure why halflings seem to dominate but there is plenty of time for modifying the variables later. This also brings to the front the issue that the world is roughly twice as small as it should be, and is incredibly habitable. Nothing wrong with that, but I do want to rework the map size (which gave me so much trouble 3-4 years ago) to be closer to Earth's surface area.

On the first pass, each city is its own hegemony, leading to a very busy map. About 86% of the habitable surface has at least 1 point of infrastructure, which is almost nothing anyway.

Hegemony map, very cluttered

The next step is to collapse these thousands of independent tribes into larger hegemons. Through the sword. This thins out the cities and yields a nicer political map.

Hegemony map, starting to firm up

This is approximately 10k hegemonies and about 25k cities. This is more than a pretty good start to create a playable world. I'll tweak this process some more, then begin to add resources and trade networks.

April 9, 2021

Detail XIII: A Case Study VII

One full region is now generated:

There's plenty of material here, of course, but I can do better, particularly with the addition of features. Let's zoom in on the capital city here (Hex 25, infrastructure 42).

The first and easiest thing to place is a bridge. Hex 25 has a high enough infrastructure to be able to place bridges (as opposed to ferries or fords). This river has a Strahler number of 4. Therefore, the two hexes where the roads cross the river will have bridges on them, notated by black squares (for now).

I recommend reading through this series of posts to understand where I'm going next. We want to know what features this hex has by virtue of the specific layout. Moreover, it'd be nice if this were a true function: that is, for a single input of hexes, we have a single output set of features. That will allow us to save some storage space, since all we'll need to know is the original layout.

To place these features, we loop through the hexes from highest to lowest infrastructure - not worrying about whether the hex is itself civilized. That is, for a hex and its six neighbors, if there are 4/7 civilized hexes present in that set, then the central hex is of Type 4, quite good. Depending on the exact distribution of those civilized hexes (Type 4 has 8 possible layouts), the possible features could be a large keep with a village, a manor house with a village, an aquifer, or a quarry. Once a feature has been identified, all hexes in the set are removed from the list: this prevents the map from getting too busy.

I've only added a few things to the list given by the Tao above. But there are a lot of configurations which are empty - again, that's fine. Scarcity breeds innovation.

In addition to the bridges, we generate a medium keep with village and church, a toll road, several mines, and a quarry. Additionally, there are several outlying hexes with no specific feature, but which in this case would most likely be farms or other "non-village/city" communities of a few families.

I could also make use of the wilderness and deep country features discussed here; but that would need be on a different layer, not player-facing. Still, could be a useful DM tool.

March 26, 2021

Detail XII: A Case Study VI

Next up: lakes.

Lakes were complex to handle back in Detail VI: Lakes, but this project should be much simpler; again, I am placing them manually. Hex 15:

There are two important things to note here. One, I trace a river through the center of the lake to ensure that drainage is calculated properly. Second, the road hugs the river pretty nicely this time.

What I've got so far:

March 19, 2021

Detail XI: A Case Study V

Let us take stock of the map so far, with Hexes 24, 25, and 26.

The terrain blends very nicely. But these settlements need to be connected - at least, if the infrastructure exists to support them. The infrastructures are as follows: Hex 24 with 9, Hex 25 with 16, and Hex 26 with 7. Not a great deal of population here to maintain a good trail, but it's enough to at least have a road of some kind.

Road placement uses an A* algorithm with defined endpoints. In the cases here, the endpoints are the defined settlement hex and the edge exits; if no settlement exists I'll just define two exits.

The route weight is a bit complex but generally tries to pick the route with the most gradual elevation change. These being rather flat hexes, we'd expect a more or less straight road. There's some complexity when it comes to rivers. Unless a 20-hex has at least 12 points of infrastructure, it can't build a bridge or ferry. If it has less than this, it can't have a simple ford either if the river is larger than 2 Strahler points. Those rules yield the following network:

Pretty good. Nothing complex to overcome in this particular slice. We can get slightly more interesting results by adding a bit of a terrain penalty. Hex 26 is mostly marshy terrain - not necessarily impassible, but the road will definitely hug firmer terrain where available. So we'll add in a bit of a penalty for such.

Eh. Kind of interesting. The penalty weights probably need tweaking but I'll wait until I have more use cases.

March 17, 2021

Detail X: A Case Study IV

Under normal circumstances, I would place the rivers at this point. However, I am adding them by hand. Rivers are saved as a list of the hexes through which they flow, which makes this part more or less trivial. The Strahler numbers are saved for each in-flow hex and so the width of the river can be drawn accurately.

Hex 25; river in white temporarily for emphasis

The next step is determining which hexes are settled and which are wild. The infrastructure for Hex 25 is $I=16$. This isn't quite as simple as placing, for instance, 16 of 400 hexes as "settled." I reviewed the system for determining the relationship between infrastructure and number of settled hexes back in Detail III: Infrastructure. Briefly, each hex contributes to the total infrastructure based on the number of settled hexes that it itself borders.

There are then two broad scenarios for placing these hexes. The first is the case here, where I already know the "core" location of the main settlement within the hex. I want the other settled hexes to "cluster" around this one, so the base chance of settlement ($P_s = I/400$) is modified based on proximity to the constraints (there may be more than one in other cases): \[P_s = \left(\frac{I}{400}\right)^{|s - c|\cdot t}\], where $|s-c|$ is the distance between the 1-mile hex $s$ and the constraint $c$, and $t$ is a factor such that the sum of probabilities is equal to $I$. This added factor makes convergence a lot faster. Thanks to Scott for this idea!

For now I'm coding the settled hexes as grassland. The algorithm yields two Type VII hexes (1) and four Type VI hexes (2) for a total of $2\times1 + 4\times2 = 16 = I$. Perfect! In this case, they are all contiguous, but this need not be the case. Just luck of the draw and a consequence of the low overall infrastructure. 16 is really not very much at all.

The second scenario (and honestly, more common) is a 20-hex without a named settlement, and thus no specific constraint. Settled hexes will then tend to cluster around river features or roads. Therefore, we can do a similar adjustment with the distance to a random river or road:

However, most of the 20-hexes I'm looking at initially will have settlement features. This will come in handy later on.

March 15, 2021

Detail IX: A Case Study III

I previously covered terrain placement in Detail III and a bit in Detail IV. At the time, I was thinking of the effect that infrastructure had on the terrain, and so I used the terms somewhat interchangeably. The terrain type was simplified into "primary" and "secondary," but there are many cases where neighboring 20-hexes may have several different types between them. So the system needs to be able to take that into consideration.

At first, I just used a random choice between the available neighbor types, yielding something a bit like this:

This isn't really great, because the shape of the 20-hex is immediately identifiable.

To the surprise of no one, I'll turn to my old friend IDW. Normally, IDW is concerned with interpolating numerical values. Instead, for each hex, I'll determine the weights assigned for each potential terrain type. The 20-hex terrains are as follows:

Darker green is shortleaf pine (coded as c), lighter green is longleaf pine (n). Not a huge difference but adds some flavor. The green-brown is marshy terrain and not in view here. So we see that Hex 24 will be dominated by shortleaf pine and begin to transition to longleaf towards the south. Running the algorithm for the weights on a 1-hex near the bottom yields:

{'c': 1.3e-06, 'n': 1.9e-06}

So the longleaf pine is much more likely to be generated near the bottom. To use this in a random selector, I normalize these numbers to sum to unity.

{'c': 0.401, 'n': 0.599}

So there is about a 60% chance that that 1-hex will be longleaf as opposed to the dominate shortleaf.

Quite satisfying.