April 30, 2019

Demographics VI: Return of the Urbanites

The equations here are cool, but they start to yield some pretty large numbers when the empire size begins to grow. So I'm going to try an alternative system for a while and see how it feels.

This is just a simple logistic function centered at $I_0 = 400$, with a maximum value of 480 persons per 1hex: a very high rural density indeed for the development we're talking about. \[d(I) = {480 \over 1 + \exp\left(- k \left(I - I_0\right)\right)}\]. $k$ is set to 0.016, so that $d(5) = 1$. The population of a whole 20hex is given as $400 \cdot d(I)$.

Since this doesn't rely on the urbanization rate (which is now derived rather than set) to determine population, we can now get population numbers for hexes with no cities. The hinterlands.

April 16, 2019

History VII: Blood Alone Moves the Wheels of History

The simulator is working pretty well, so I took a few moments to make a nice historical snapshot. This image represents the growth of settlements over 2700 years. It's rotated so that north is to the left, to get a good view of the central continent.


There is a large band of civilization right in the middle. This represents the Cfb Koppen climate, so a European-type climate, where the jungles of the equator give way to lighter forest.

After 2700 years, the oldest empires are:
  • Delig, est. 1, population: 1,303,170. The capital city is Hvatfar (pop. 2,103). The largest city, however, is Jakom (pop. 28,001). They produce mostly agricultural products but have access to iron and copper ores and coal. Delig is a small halfling kingdom, with only 8 cities. Deligfar itself, the founding city, stood until 1030, when it fell to disaster (disease or natural disasters).
  • Tilaj, est. 1, population: 2,128,289. A dwarf kingdom, Tilaj is much bigger than Delig, with 31 cities (but hence a lower density). The capital city is Nzuavjuab (pop. 3,229). The largest city is Limai (pop. 13,839). Tilaj mines silver, iron, and copper. Tilajp lasted until 1701, quite a run.
I haven't run the full trade network yet, so I'm not sure if this will change, but notice that neither of these empires have access to gold or steel (which requires manganese and nickel). This will severely limit the trade abilities of these ancient peoples.

The largest empire is:
  • Popach, est. 3, population (human): 11,064,595. The capital is Tepwyð (pop. 151 - really??). The largest city is Dwrzwie (pop. 20,806). Comprises 176 cities. Again, no gold! Perhaps I should place a very high emphasis on gold during city placement.
The largest city is:
  • Ldwia, est. 2058, population (human): 69,402. Part of the Umidyl hegemony. Ldwia is due for a crash - they are far above their carrying capacity.
All told, there are 716,318,766 persons accounted for. That's a lot, especially for the short amount of time, but remember that I've got 5 races, not just one.

I like the war simulation so far, but the transition matrix does not account for empire minded cultures. The chance of a Cyrus the Great arising (20 year campaign) or an Alexander the Great sweeping across the world, moving so fast he appears to be flying, is very low. And perhaps it should be. But we have many examples of this type of thing in our own world, so I would imagine it could happen more often here. Perhaps there might be a special mechanic where a great leader arises and pushes the boundaries of the empire without suing for peace.

I'd also like to incorporate more bloodless politics (two kingdoms joining in a confederation or an empire) or more bloody politics (secession or balkanization). All things in time.


April 15, 2019

The Wolf and the Lady

This has been an appropriately dark week.

Last night, Gene Wolfe passed away. He was, in my mind, one of the greatest (if not the greatest) sci-fantasy writers of all time. To describe what Wolfe did as worldbuilding or story-telling is not really accurate, because neither word fully captures the breadth of what he created.

The Book of the New Sun is my favorite work of his, although it's all genius. Noisms suggests that the Soldier series may be more accessible, and that's true. BotNS is the type of book you read a dozen times and still have to work to understand; a key element of Wolfe's work is the unreliable narrator. Sometimes, the author/narrator is mistaken. Sometimes, he forgets or misremembers. And sometimes, he lies outright. And it is never clear, especially to the inattentive reader, which is which. Wolfe's books are not to be read as much as they are to be conquered.

Not hours after Wolfe's death, a devastating fire swept through the Cathedral of Notre Dame, a landmark of Christendom for nearly a millennium. This is probably the Pareto optimum tragedy: almost no lives were lost that I saw (one firefighter was severely injured), but this is a cultural loss of almost unimaginable scale.

It is also a learning point for any worldbuilder. Building and places are more than the stone and wood and glass that comprise their physical structure. They become loci for the identity of those who inhabit them. The identity lives on, but the loss of the structure is the loss of something real and metaphysical from that identity. People create place, and the interplay of person and place creates something that cannot be replicated, like a seasoned cast iron pan. Notre Dame was/is a collecting point for the shared experience of millions of people, pushing ever on into the future and spilling over into the next generation of sharers in that experience.

These events signal a genuine end of an era. One era lasted 93 years, the other 856. The world will be different forever.


April 8, 2019

History VI: It Is Well That War Is So Terrible

The enemy said, 'I will pursue, I will overtake, I will divide plunder, my desire will be full of them, I will draw my sword, my hand will destroy them.' - Exodus 15:9 LEB

The Heidelberg Institute for International Conflict Research (HIIK) defines 6 levels of violence intensity between nations.

lvldesc.
0no conflict
1dispute
2non-violent crisis
3violent crisis
4limited war
5war

Levels 0-2 are non-violent, while 3-5 are escalated into actual conflict. This fascinating paper gives me a great set of models to use to predict conflict between nations [1]. For example, a variable for "border conflict" $C$ can be used as a "bad neighbor index": \[C = \sum_1^n x_i p_i,\] where $n$ is the number of bordering nations, $x_i$ is the previous year intensity for nation $i$, and $p_i$ is the percent of border shared with nation $i$. This paper [2] takes it a step further by providing a transition probability matrix between peace and war!

However, Hegre's robust model only transitions between no conflict (0-2), minor conflict (3), and major conflict (4-5). So I can use this to create a full transitional matrix between the 6 levels (using my old friend Inverse Distance Weighting).


After a bit of testing, that seems like it transitions way too quickly. My tests devolved into war within 10 years. Guess that's possible when everyone is super touchy. Let's try something more fundamentally based.


That does a little better. Doing a few tests shows it has a nice spread leading up to war, between 70 and 280 years for 5 tests. Perhaps it could even be modified per nation. Some are naturally peaceful, some are naturally expansionist. It is quite obvious from even a few tests how massively the matrix affects behavior.


At creation, every nation will be at Level 0 with its neighbors (barring circumstances like a secession from the parent hegemony, in which case it would already be at war).

However, this transition matrix is situationally agnostic. It doesn't know how much border I share with that crazy king who's always eyeing my silver mines. It doesn't remember the bloody civil war in which my people were brutally defeated but still nurse their wounds with undaunted pride and opportunistic ears. So while this system can add some substantial random salt, it's not the end all be all. We need a few more mechanics and numbers for that (rebellions, treaties, overall population contentment, confederations, etc). But for now we will assume that war is only governed by this single mechanic.

If two nations are at war, they will seek to capture the bordering city which has the highest raw desirability.

Now, how do two nations actually fight? There has been some work done about this from a game design perspective, but I'm particularly drawn to the Lanchester equations. These are very simple equations which describe the attrition rates of two armies of size $A$ and $B$ at battle: \[A'(t) = - \beta A(0)^{2-n} B(t)\] \[B'(t) = - \alpha B(0)^{2-n} A(t)\], where $\alpha$ and $\beta$ are the combat effectiveness of $A$ and $B$ respectively, and $n$ is the attrition parameters. $n=1$ is the linear case, where one solider kills one soldier, but $n=2$ is the square case, more applicable to modern warfare. It also turns out that when a defender is fortified, the attack attacks linearly, while the defender defends with the square law. This makes sense intuitively - it is difficult to take a position. So how do I use this in my game?

First I need to determine the raw number of troops. I'll pull random low percentage (3-6%) from the rest of the country to determine a standing army size, and 5x that from the attacked hex. This includes both urban and rural populations (right now, my rural calculation is 5 times the infrastructure number but I don't like this and will address it soon).

Potential issues: it doesn't make much sense for the entire standing army to reinforce a single city in every case. It may not be strategically important, or it may be the fortress upon which the whole balance hangs. There's no way to know, and I'm looking for verisimilitude, not accuracy.

Consider the following free cities:
  • Wienw, population 559 (rural 11,670), founded 3604. Militarization rate: 5.6%. Total military: 2,860.
  • Aedcad, population 6,694 (rural 31,110), founded 3325. Militarization rate: 4.9%. Total military: 1,742.
Aedcad attacks Wienw but is met with a much larger defending force (Wienw gets a boost because it's being attacked). To figure out who wins and how many troops are lost, I need a measure of $\alpha$ and $\beta$. If one side has steel swords and the other has bamboo canes, it almost doesn't matter how many people you have with canes. Technically, I can get numbers for weapon availability by leveraging the market system, but I can't computationally afford to do that every simulated year. So instead, I'll use the desirability and infrastructure indexes, which are updated regularly. The theory being that resource availability yields a higher desirability, and a higher infrastructure gives you a better mechanism to train your troops. For Wienw ($\alpha$) and Aedcad ($\beta$), this gives \[\alpha = {0.7368 \cdot 103 \over 10} = 7.589\] \[\beta = {0.5242 \cdot 21 \over 10} = 1.101\] The indexes are averages of the entire hegemony (which in these cases is only one hex) and they are divided by 10 to bring it into a reasonable range. A soldier from Wienw can kill almost 8 enemies before he dies, but an Aedcadian can only manage around 1.

The solutions for the above equations are too long to display here, but suffice it to say that Aedcad was soundly defeated (using $n=1.25$). Defenders will hang on until they have lost 50% of their troops; attackers will break off if they have lost 30%. Aedcad (red) loses 528 men in the attack - a costly battle, and Wienw (blue) only loses 467. Because these are single cities, it's easy to just subtract the casualties; in the case of larger hegemonies, all cities will lose some in proportion to how many they supplied.


However, as robust as this may seem, I don't know if it will be fast enough to use as my primary engine of war. I'll have to run some tests with some non-linear solvers. But otherwise, it's a fair start.

Potential issues: why would Aedcad attack Wienw in the first place, given Wienw's military and numbers advantage? However, we have information that Aedcad does not: perfect information on the likelihood of a victory or loss. Until we salt the system, Aedcad will always lose this battle. It's just a question of by how much. I'd also like to create some castles/other fortifications, because these are gameably cool, would most likely be built in highly contested areas, and would give a significant defensive boost.

References:

  1. B. Boekestein, “A Predictive Logistic Regression Model of World Conflict Using Open Source Data,” Air Force Institute of Technology, 2015.
  2. H. Hegre, J. Karlsen, H. M. Nygård, H. Strand, and H. Urdal, “Predicting Armed Conflict, 2010-2050,” Int. Stud. Q., vol. 57, no. 2, pp. 250–270, Jun. 2013.

April 7, 2019

Demographics V: Urbanites

I've struggled for a while to come up with a reasonable mechanism to produce rural population numbers. The city numbers are determined by the growth system, but it doesn't account for those living outside the walls.

My first thoughts were that it should depend on the urbanization rate $u$ and infrastructure of the entire hegemony. Given $u$, the total urban population of the hegemony $P_u$, the total infrastructure of the hegemony $I_t$, and the local infrastructure $I_i$, I should be able to arrive at a reasonable rural population $P_r$: \[P_r = {I \over I_t} \left({P_u \over u} - P_u\right)\] So areas with high infrastructure will pull in a greater proportion of the total rural population. Makes sense at first.

But this can yield unreasonably high local densities. Considering the hegemony of Deribri. Deribri itself is quite small, and the more natural capital is the city of Guinrhyce (which is still in the Deribri hegemony). Guinrhyce has a population of $P_i = 44884$ and $I_i = 700$. For the Deribri kingdom/empire, $P_t = 939729$ and $I_t = 37787$. Assuming that $u$ is a function of $\bar{I}$, the average infrastructure of the hegemony, \[u\left(\bar{I}\right) = 0.96 \left(1-\exp\left(-\tau \bar{I}\right)\right) + 0.04\], where $\tau=0.00039$ is a constant which determines the speed at which the function varies, then $u\left(\bar{I}\right) = u\left(102\right) = 7.8\%$. This yields $P_r = 11108079$. Since the Kingdom of Deribri comprises 367 hexes, we can say that the population density of the entire kingdom is ${P_t + P_i \over 367 \cdot 347} = 94.605$ persons per square mile. This is pretty high. However, we can either 1) chalk it up to magic/it's my world, go kick rocks, 3) accept that the cities are too populous, or 3) increase the required distance between cities according to CPT.

Even if we accept a high density of 95 for the kingdom, there is still a really high local density based on the rural population. ${I_i \over I_t} = 1.852\%$, so Guinrhyce will support about $R_i = {I_i \over I_t} P_t = 206937$ people outside the city walls. This is a total hex density of ${P_i + R_i \over 347} = 706.409$ persons per square mile! Inside a city itself, this may be reasonable. But even leaving off the urban population still gives a density of around 600 pop/sqmi. Much too high.

However, it's still good to work through these things. These tools will be useful to approximate populations once I've reduced the overall city sizes appropriately.

April 4, 2019

Trade IV: Fixing the Seaways

I had a Big Problem with the way the seaways were generated, so I haven't included them in the trade network yet. But this is a shame. So I will fix it.


Mostly, it's good. But occasionally, weird stuff like this happens (the route marked in red). The error happens during the "refueling stops" portion of the code. First, a seaway is found between two cities of appropriate size and infrastructure. These are the anchor points. However, these routes are quite long - I limit it to search within 50 hexes, or around a month at sea. That's not impossible, but for a regular trade route is pretty tough. You want the ability to stop at a friendly port and resupply. So the code will then search along that route for nearby cities. They must have more than 1000 people, but can be much too small to originate a route of their own. So the code will split up the original, long route into manageable chunks.

However, I was getting this weird error where the splitting was rejoining everything back together incorrectly. That should be fixed now, and I can add these into the main trade network. As it is, everything is pretty isolated without access to other continents.


I would also like to determine a "piracy index" based on the frequency of ships passing through a given hex. This is gameable information: stuff that's not just pure numbers for my own enjoyment. Players can make decisions (to pirate, defend, or take the long way) based on this gameable information.

April 1, 2019

Demographics VI: Bring Class into It Again

With racial distributions in hand, I can create a simple system to populate a settlement with NPCs. Keep in mind that this is descriptive, not prescriptive: all I want is a list of the important characters in a place, and what their stats might be, and who their second-in-command is, when the PCs inevitably mouth off to them. I'm well aware that the 5e (or any edition) class system is not well suited to non-adventurers.

I've created an unholy mixture of Alexis's tables from here, here, and here, which provide excellent thought into how a population distribution is created in terms of level, and how base ability stats are inferred from that. The stats are modified based on this and the 5e Basic ruleset.

One thing to keep in mind is that these are not rules for character creation. There might be some overlap (for example, characters cannot decide their age).

Racial Distribution

This is determined in the similar way that a pricing reference amount would be determined for, say, wood or gold. Each settlement gets 1 reference for its base race. These are then distributed along trade routes. Once all this has been done, the total value is normalized so that we have a proper distribution which adds to 100%. Because orcs rarely trade, they are usually the minority, near those orcish cities which are plugged into the network. The deeper into a homogeneous nation you go, the less likely it is to see other races.

Class Distribution

According to this post, there are four types of 5e classes:

Type I - Institution based

Bards must train at a college. Clerics must train at a seminary. Wizards must train at a university. There are no monks in my world. These institutions are placed like any industry and distributed according to the same principles as the rest of the trade network (which is such a useful tool!).

institution infrastructure population
university 534 50000
seminary 534 25000
college 534 12500

Type II - Density based

Barbarians, druids, and rangers will all prefer wilder areas. They won't be totally absent from dense areas, just rare. On the other hand, rogues and thieves have more marks in a dense settlement.

Type III - Random

Paladins, sorcerors, and warlocks all have personal vows or obligations. So their distribution is small and random.

Type IV -Fighters

Everyone else is a fighter. Easy.

Score Determination

Depending on the class, the highest scores are assigned to appropriate abilities (e.g., wizards get the highest score in INT), and the rest are randomly assigned.

Age Distribution

Using the equations from here.

Aging Effects

Disclaimer: these are not character effects. They're just for NPCs for now. First, the age of the person is normalized to human-60. So a dwarf, with a slightly longer maximum lifespan of 125, is equivalent to human-60 when she is $60 \cdot {125\over 80}=93$ years old. Every year after this point, the character must roll 1d20 above their STR, DEX, and CON, or lose a point from each. Similarly, if they roll 1d20 above INT or WIS, they gain a point. CHA is unaffected.

Now then. How does it all shake out?

Drichsze, population 63122, founded in 3117. There is a seminary (possibly named after the town or for the deity it serves) and a bardic college (College of Drichsze) here. The top 25 highest leveled persons are:
  • Hilkamyn, a 30 year old human male, Fighter 11
  • Okorzych, a 55 year old human male, Fighter 11
  • Madwgawn, a 22 year old human male, Fighter 10
  • Czymiet, a 25 year old human male, Rogue 9
  • Noraw, a 31 year old human male, Fighter 8
  • Widdocko, a 45 year old human male, Rogue 8
  • Marryawn, a 25 year old human female, Rogue 8
  • Badow, a 22 year old orc female, Fighter 8
  • Brwych, a 22 year old human female, Fighter 8
  • Myszych, a 30 year old human male, Rogue 7
  • Popachno, a 67 year old human female, Fighter 7
  • Gwieck, a 52 year old human female, Cleric 7
  • Tryzniek, a 25 year old human female, Fighter 7
  • Rinajaal, a 31 year old orc female, Fighter 7
  • Jezhciski, a 53 year old human male, Fighter 7
  • Picarwe, a 56 year old human male, Fighter 7
  • Elodwe, a 28 year old human male, Cleric 7
  • Dwodre, a 47 year old human female, Warlock 7
  • Tegalwy, a 23 year old human female, Rogue 7
  • Dwowynn, a 25 year old human male, Rogue 7
  • Rowtrano, a 63 year old human male, Rogue 7
  • Dyceri, a 70 year old human female, Rogue 7
  • Gwalwymar, a 35 year old human male, Fighter 7
  • Dachafgalas, a 46 year old human male, Fighter 7
  • Krycigone, a 59 year old human female, Fighter 6
Here is the beauty of the system. I don't have to assume anything about these people. Maybe Hilkamen is the ruler of Drichsze, having climbed the ranks through skill or fortune of birth. Perhaps Gwieck's connections through the College of Drichsze have placed her in a high position. Or maybe the criminal gangs run the city, through their leader Widdocko.

The list is dominated by humans, of course, but Badow's militant prowess is nothing to scoff at. What sorts of things has she had to endure as minority, and how has that shaped her?

Dyceri is the oldest here, although with a statblock of 5/8/11/16/15/15, her activities are more limited to teaching new pick-pockets the higher arts of political subterfuge. The oldest person is Llermy, who at 80 years old should have advanced past level 1...

What about the highest for each class?
  • Glerwy, a 21 year old human male, Barbarian 5
  • Caro, a 57 year old human female, Bard 6
  • Gwieck, a 52 year old human female, Cleric 7
  • Emhach, a 31 year old human female, Druid 2
  • Hilkamyn, a 30 year old human male, Fighter 11
  • Zienys, a 24 year old human female, Paladin 5
  • Eniecho, a 55 year old human male, Ranger 6
  • Czymiet, a 25 year old human male, Rogue 9
  • Wocko, a 57 year old human female, Sorcerer 5
  • Afakiro, a 31 year old orc male, Wizard 4
  • Dwodre, a 47 year old human female, Warlock 7
What sorts of things have these people been through? What stories can they tell?

All this shows how a comprehensive framework does not replace imagination, but it provides a coherent structure upon which to base that imagination. Given the facts, we can easily construct a narrative which describes how this city operates, and how it might respond to the influx of a certain cast of party.