Showing posts with label Economics. Show all posts
Showing posts with label Economics. Show all posts

July 6, 2023

Trade VIII: Pricing Abilities

DM's Escritoire says:

Been a while, but Alexis' recent post generated an interesting comment from you regarding using his Sage system to effect manufacturing and prices. Care to share the direction you're taking. I recently watched his (ten year old) youtube and caught something I missed in the last third regarding references for "service providers." I may try to revisit this approach unless the Sage abilities shows more promise.

I would care to share the direction I'm taking, thank you for asking.

Alexis' approach is to make the yearly income of a person with a certain skillset equal to the amount of time needed to train them to that level. I took a different approach, but I'm hoping his solution can inspire me to close some of my gaps.

My trade system still operates largely as described several years ago. My upgrades have largely been relegated to a better processing system: I no longer calculate each stage of good in turn. Instead, I overhauled the recipe system so that each good is calculated recursively based on the price of its ingredients. This also makes it trivial to add new items to the system, as no recalculation needs to be done for complex manufactured goods.

Raw resources are still assigned based on rarity calculations: I attempt to make these as accurate to the real world as possible, but I also keep a file to override those results in case I want to force a particular resource to occur somewhere.

Industries/labor was a different matter. I'd started out giving each industry a "support value" based on MDME: how many people are required to support the resource of an industry. Many people pointed out issues with MDME's support values, but I do think the core idea is sound. But that leaves us back at square one: what number for SV do we use? My answer so far, unfortunately, is do what I feel right.

{
  "item": "potter",
  "cpUnit": 10,
  "tech": 6,
  "SV": 300
}

Occasionally, a price will not make sense, and I'll reevaluate the SV. But this is the base number I use to determine whither and which. Let's take a population of 1000. We randomize the order of industries and begin with potter as above. $\left\lfloor\frac{1000}{300}\right\rfloor=3$. So there will be $1-3$ potter references here. Let's roll a $2$ (the actual roll percentage is also calculated from the SV and population). This means that $2\cdot300=600$ of the population is tied up in "supporting" the potter, leaving 400 for the next industry we consider. These base references are then spread across the trade network just like anything else.

This process results in a unique fingerprint of industries for each city.

It is no complex matter to extend this to sage abilities.

{
  "item": "hunting",
  "cpUnit": 2,
  "tech": 4,
  "SV": 50
}

Our fiat values are again cpUnit (the unit here being /day) and SV. Hunting ought to be a more common skill than most, so we begin with these numbers and see how it turns out. Because each ability is assigned independently, we can define all Amateur Logistics abilities to have the same base numbers, and the final output for a given market will still be unique. Authority/Expert/Sage abilities can be likewise scaled up appropriately from the Amateur values.

This lets the party acquire a hireling with a bespoke set of abilities and gives a total monthly price based on the specific set of skills they desire.

Future considerations:

  • Better understanding of how the various fiat numbers are derived, something more internally consistent like the price of training/apprenticeship
  • Replace some industries with appropriate skills, e.g., Potter can be replaced by Pottering. As mentioned above, I think this is probably a better approach overall, since it more directly ties the  market network into the sage system

September 15, 2022

Trade VII: Why Can't I Find What I'm Looking For?

The market system is based on rarity, a calculation derived from the local availability of a good and the total available amount of that good (or at least, the amount that is reachable). Goods are arranged hierarchically into stages, from "raw" materials all the way up to complex goods which require many precursors which themselves are often manufactured.

The system I've written to handle these complex goods works great. I can add "recipes" to a master file and calculate a price for any good I can dream up (and properly research).

A core concept of the system is that of a reference, which represents the amount of a good which can be purchased by 1500 oz of gold (approximately 3,125 gp). For small goods, like crops, a single reference can represent tons of material.

The question I am currently working through is: how to take the bits of information I have and translate them into an availability metric.

The market and price list provide two important functions to the party: they generate striving (to aspire towards a piece of equipment they can't yet afford) and scarcity (equipment that is not available for any cost).

We can, of course, allow the price itself to perform both of these functions. However, all equipment should not be available at all times simply because it exists somewhere in the system. The question is then how to determine how often a good will appear in a given market.

My initial thought is to use the local number of references to determine this rarity. If less than a single reference exists in the local market, then there is a good chance it'll not be available that week (or similar period of time). This means that we can recursively build up a local reference amount for manufactured goods based on the local references of its components.

Once I have this number, I can either use it as a probability straight up, or mitigate it a bit by comparing it to the rarity constant (itself a function of the size of the market). For now, I'm simplifying the final product by taking the log of that number and using that to determine a "rarity score."

\[\mathit{rarity} = \left\lceil-\log_{10}\left(\mathit{ref}_\ell\right)\right\rceil\]

Example: for a good with a 0.002 local references ($\mathit{ref}_\ell=0.002$), the rarity score is 3. That can be further used for a roll as needed. We could say that an item with a rarity of 3 will be available in a market on a 1 in 1d30, for example. This makes rare items difficult to find, but not impossible. The party could either hang around until some were available, or travel to another (and perhaps more favorable) market.

The simplest method to determine local references is to use the minimum of all constituent components, without regard to the amounts needed. I'm not super comfortable with this, because my conception of references is tied more tightly to actual production numbers (which I generate from the working population availability). But it has led to some bizarre cascades. Fodder, for example, is very cheap, but a lot of it is needed to raise a foal into an adult horse. This also means that the number of fodder references needed per horse is very very low. Both of these can quickly get out of hand as very small or large numbers are passed through several iterations of the recipe parser.

I tried dividing local references by the amounts needed, or comparing the local references available to the number needed. Neither are really satisfactory. I think I will use the simple method described above, and if I get a lot of complaints in play then I will revisit it.

The recipe system is built and effective. There are a lot of recipes to write, however.

April 21, 2022

Trade VI: Simplifying to Complexity

I've been working on my algorithms to generate trade networks and manufactured goods. Although probably several years out of date now, Tao's Trade System remains required reading for anyone wanting to do something similar.

This iteration was a much-needed rework of the way a lot of the prices were generated. I had gone through Alexis' work linked above and simplified it to my needs. He is using references based in the real world, whereas I am trying to generate from scratch.

I found that of all the equations, the final price of an object simplified to just a few variables. The first is the local value of a unit (oz) of gold (in cp, all prices are expressed in cp and can then be abstracted back up to sp or gp as needed). I'll call this $g$. To find this number, we need the local availability $g_\ell$ and the total availability $g_t$. $g_t$ is the total number of references reachable from the point in question. This is easy to do with network algorithms. Local availability is a weighted distance calculation over all locations $i$ reachable from $\ell$: \[g_\ell = \sum_i \frac{g_i}{\textrm{dist}\left(\ell, i\right) + 1}\] By this calculation, if $i$ has 2 gold references, but is 4 days away, it contributes $\frac{2}{4+1} = 0.4$ references to $g_\ell$.

Right now, I am treating each hex as a node in the graph, but if there is no defined settlement there, all its resources are given to the closest city hex for pricing purposes.

We need a rarity factor $r$ that scales with the size of the network. As the network grows larger, a smaller $r$ is needed to balance things out. I'm trying this out for now: \[r = -\frac{1}{n}\] where $n$ is the number of nodes in the network.

The last two constants are the number of gold pieces per oz ($p = \frac{1\textrm{ gp}}{0.48\textrm{ oz}}$) and ratio of cp to gp ($c = \frac{100}{1}$). These are easy to change. A half-ounce gold piece is somewhat hefty; many coins in history would have been much smaller amounts. Gold is valuable enough that a small bit is worth a lot, and hence a great deal of value can be expressed in quite tiny coins. I like the idea of a gp being a weightier coin. I also try to base the sizes of my coins on current analogs that I can actually show to my players.

A thousand of these is no joke

So the final equation comes together: \[g = \left(r \cdot \frac{g_t}{g_\ell} + 1\right) \cdot p \cdot c \]

For an individual resource $q$, the equation is similar. First, we have to define the base cost $b$ of a unit of $q$. I found that this was the most important factor; it essentially represents the ideal economy where everything is in perfect supply. Whether a board-foot of wood is defined as 1 cp or 18 cp will have approximately a 18x effect on the final price of wood no matter where you are in the world. This becomes the key object of research when sketching out the system. It is then an easy matter to determine how many units of $q$ are equivalent to one reference of gold (assuming a gold ref = 1500 oz): \[\mathit{ref}_q = \frac{b}{\mathit{ref}_g = 1500\textrm{ oz}}\]

We obtain the rarity $r_q$ in a similar way as above with gold, using the distance weighted availability. The final price (in cp) of an item at location $\ell$ is then: \[\$_q = \frac{g}{\mathit{ref}_q} \cdot \left(r \cdot \frac{q_t}{q_\ell} + 1\right) \mathit{ref}_g\]

There are some other ways to view this equation. It can simplify again to: \[\$_q = \frac{g}{b} \cdot \left(r \cdot \frac{q_t}{q_\ell} + 1\right)\]

The next step is to determine the availability of labor references. I haven't quite decided how to assign these so I'll save that for a future post. We obtain the available references by once again iterating on the network: \[L_\ell = \sum_i \frac{L_i}{\textrm{dist}\left(\ell, i\right) + 1}\]

The cost of a material $m$ at a given stage (eg, hematite $\to$ iron ore) is then the cost of the raw materials (the unit cost $\$_m$ times the number of units $n_m$) plus the labor cost, which is raw material cost divided by the labor references: \[\$_m = \$_q \cdot n_m + \frac{\$_q \cdot n_m}{\mathit{ref}_L}\]

This step is repeated for each stage of the process, which can be quite complex. I developed a JSON schema to represent each manufactured material. To raise an auroch from a calf to weaned, you require the following.

{
  "item": "auroch (weaned)",
  "unit": "hd",
  "stage": 1,
  "tech": 7,
  "weight": 200,
  "recipe": {
    "materials": {
      "auroch (calf)": 1,
      "min": [
        {
          "maize": 483,
          "oats": 483,
          "barley": 483,
          "cassava": 483,
          "rice": 483,
          "wheat": 483
        }
      ]
    },
    "labor": "herdsman"
  }
}

Our raw materials are 1 auroch calf + whichever is cheaper between 483 lbs of feed, plus the labor of a herdsman. As long as every manufactured item "downstream" exists, this "item" will be available for purchase.

July 16, 2019

Resources XXI: Aurochs

The auroch was a breed of very large cattle which went extinct in the 1600s. Rather than a generic "cattle" reference, I want to use them for a bit more exotic feel.


Since we have no live aurochs, I'm going to use stats for the Indian gaur, another very large taurine, as my base.


An auroch calf weighs about 50 lbs at birth. Based on current calf prices relative to gold, a reference of gold can purchase 15,000 head of calves. They are found in A/B/C Koppen climates.

A calf is economically useful after it's been weaned, which for aurochs is approximately 8 months. During this time, there is already a material upkeep cost because the mother's milk is gradually being replaced by solid food. This is factored as an upkeep cost even if the animal is largely grazing, because any forage the auroch gets off my land is potential food I can't grow and sell; it is a sacrificial investment. Overall, this works out to 483 pounds of food, selected by the lowest price available in the region.

Once the calf is weaned (about 200 lb), its food uptake is significantly increased. The animal will eat about 2% of its body weight per day for the next 2 years and 4 months (more or less). This is 23,679 pounds of food up to its full weight (2,500 lb).

Each of these costs is mixed with the labor of local herdsmen, which increases the cost somewhat. However, herdsmen are usually in good supply and so the added labor cost is generally low.

This makes a full-grown auroch quite valuable (depending on the cost of feed). This cost will be used to determine the local costs for meat, leather, horn, and bone glue (and perhaps other things, but these are the most important for now).

Looking at the city of Kwazfulnis (population: 3896 dwarfs, 795humans, 237 halflings, 101 elves): you can get a calf for about a copper; but a weaned calf will cost you 28 sp, and a fully grown beast is 141 gp!

It's possible these prices don't make sense. I feel like every time I look at my base commodities table I see another mistake to correct. But I'm making slow progress, and I'm more concerned that the system work flawlessly (or good enough) so that updates/corrections can be made more easily.

July 15, 2019

Trade V: Money Makes the World Go Round

The fantasy economy runs on gold.

But gold is rare.

Yet trade still manages to happen. How?

My world is very disconnected. There are many separate networks which do not interact at all: the tech level is too low, the roads haven't been built, the markets aren't connected.

Many places do not have any gold at all.

But they have silver.

So what I've done is check each sub-network to see if gold is available. If it is, all is well. If not, we move to a silver standard. If (and this is more rare still), silver is not available either, I fix the price of chalcopyrite, since copper is a Stage 1 good (gold and silver are both Stage 0). If copper is not available, you're out of luck; for now anyway. If I add another precious metal it should be easy enough to go back and add it into this selector. So eventually, everyone should have something to base a coinage economy on.

I do think it might be worth it to adjust the rarity of gold. In the iteration I'm testing at the moment, I have 10 gold mines for 17,290 settled hexes. That's an occurrence of about 0.058%, whereas gold should be around 0.3%. Of course, there is more gold...it just hasn't been found yet. In reality, it's a little higher than the target, around 0.5%. I think I'll add a stronger effect on desirability since gold is so important.

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.

March 20, 2019

Resources XX: Old Makes Way for the New

Not all resources can be extracted more efficiently or in greater quantities as local population increases.

In particular, raw agricultural resources will be pushed out of the way by the city.

Hence, I need a signal to indicate when a good is inversely proportional to local population (or infrastructure, or population density, etc).

I'll call this "Type A."

Type A goods, so far, are just those which require physical land to function, which is agricultural resources. Of course, we can think of cases where, say, a strip mine grows in area, but since this is only a single type of mine, we'll leave it alone for now.

The Type A goods (in the system so far) are:

commodity
wood
wheat
maize
oats
barley
cassava
rice

Inverting these numbers requires knowing (or guessing) the highest infrastructure. Although the infrastructure can rise quite a bit (the maximum I have so far is 2742), anything higher than 400 represents a fully settled hex. And indeed, there are considerations here that I might explore later: as the amount of available area grows, so does the number of hands necessary to farm that land. So there is inevitably a trade-off in how much you are able to produce.

All of the Type A goods are also Tech-6 (T-6). This means that only a single point of infrastructure is necessary to begin producing them. I think the best system as a first approximation is that of diminishing returns. A T-7 or T-8 hex may have more hands available, but each additional level reduces the efficiency of production. This is an easy way to account for the reduced amount of farmland or harvestable forest. If we consider that the production per person $p$ drops as the infrastructure $I$ increases $1\to400$, we then see that $p$ is related to base production $p_0$ by \[p = {p_0 \over 399}\left(400 - I\right)\]. I'll have to run some more tests and see how this actually works in practice, but I feel it's a reasonable start.

March 18, 2019

Resources XIX: Stage 0 Materials

Here are the raw resources I've researched so far.

But I have an interesting problem. A lot of these are ores with modern scientific names. That presents an odd immersion-breaker; a dwarf trader would (perhaps) not carry hematite. He'd carry red-iron, or something. However, I don't want to fall into the trap of making up too many names, while balancing that with playability.


For certain minerals, if only a few places produced it, it would make sense to call it after the producing nation or city. A good example is psilomelane, a manganese ore. Only 141 cities produce it. Of these, 10 cities control 50% of the total production: Nabib, Ashdinjem, Cusraq, Lahmanazlib, Rogan, Malia, Siaglen, Silil, Qoloob, and Crewnevanch. All great names to draw from: nabibite, Cusraq iron, qolooban. In an obscure, independent world, those would work great! Psilomelane is, after all, a Greek phrase meaning smooth-black, from the appearance of the stone. So all these things must be taken into account in order to present a consistent and immersive world to player. Having to memorize "qolooban" if you want to supply your blacksmithery is not terribly immersive.

But nonetheless, I will try.

commodity unit tech level occurrence unit/ref ref/acre acre/pop ref/1000 common
wood bd.ft 6 7000000 0.0029 100
goethite lb 7 0.0446 93750 6.311 bog-iron
limonite lb 7 0.0775 93750 157.8557 brown-iron
umber lb 7 0.0194 125000000 9.697
magnetite lb 8 0.0963 93750 0.2524
hematite lb 9 0.1008 93750 0.0101 red-iron
silver oz 8 0.0334 15000 3.8788
wheat lb 6 2500000 0.0001 100
maize lb 6 3528000 0.0001 500
oats lb 6 2500000 0.0007 1
gold oz 6 0.0035 1500 1.7455
barley lb 6 2500000 0.0001 1000
cassava lb 6 52083 0.0011 100
rice lb 6 62500 0.0001 100
chalcopyrite lb 6 0.1699 223404 24.4156 goldstone
azurite lb 7 0.034 47872 113.9394 bluestone
malachite lb 7 0.0777 103723 52.5874 greenstone
clay lb 6 0.0775 937500 157.8557
coal lb 9 0.11 9000000 0.1818
psilomelane lb 7 0.0123 23438 0.9697 bubblestone
pyrolusite lb 7 0.0201 23438 0.9697 blackstone

March 12, 2019

Trade III: You Have Something I Want

Time to put everything together and generate a trade network.

The network graph itself is created from the roads, seaways, and rivers. Right now, I have about 10 thousand separate resource-producing settlements, and about 20 thousand roads connecting them.

The problem I am running into is that networkx is pretty slow with this many edges (about 15,000 nodes and twice as many edges). But I found that pre-processing the trade distances makes this much faster. For instance, two cities may be connected by more than one route, even if its just a road and a navigable river. Although local circumstances may require trade to flow along a non-optimal route (the road is blocked, the river is too choppy), the vast majority of trade will occur in aggregate along the shortest route. Therefore, non-optimal routes are irrelevant to the market network; many of those 30,000 edges will never be used.

The process to assign a resource reference is as follows:
  • From the list of available raw resources for a given city hex, select those which the current infrastructure level will support
  • Determine the reference amount that the city can produce
  • Calculate the gold reference for every hex using the system described here
  • Calculate the reference costs for each raw resource
  • Calculate the labor costs for each raw resource. Really this is more of a measure of the amount of references available, and not the cost directly, but I can define a base cost just like any other material good and get, for example, the daily income of an ironworker
  • Calculate the costs for each manufactured commodity. Because a given good might depend on a number of other manufactured goods, I have to make sure that I do them in the right order. To this end, I define goods in stages. Hematite, as a raw resource, is a Stage 0 good. Iron ore is made from Hematite, and is thus a Stage 1 good. So all Stage 0 goods must be assigned and priced before the Stage 1 goods can be calculated. For every multi-stage good, the overall Stage must be $n+1$ where $n$ is the highest Stage used in the recipe
Manufactured goods are defined through recipes. This takes a lot of guesswork sometimes. For example:
'iron (ore)': {'min1': {'charcoal': 1; 'coal': 2};
'min2': {'goethite': 1.6; 'limonite': 1.8; 'magnetite': 1.4; 'hematite': 1.4};
'labor': 'ironsmith'}
This recipe for general iron ore says that you will need 1 lb of charcoal, or 2 lb of coal (whichever is cheaper), and the cheapest ore between 1.6 lb of goethite, 1.8 lb of limonite, 1.4 lb of magnetite, or 1.4 lb of hematite. These raw materials are then shaped by an ironsmith to produce 1 lb of iron ore.

This system is nicely versatile.

One snag that I've run into is the presence of trade networks without access to any precious metals at all, yet perhaps quite robust industry. There are a few solutions to this.
  1. Remove these networks entirely. No precious metal economy, no economy.
  2. Structure these to work as barter economies
  3. Use another substance as the practical fiat currency
  4. Assign a small amount of gold to the economy to lubricate it
2 and 3 are the most likely, historically speaking. But they also require the most work. The easiest for now is just 1. I think I'll redo a long history once I have a good number of raw resources defined. That should take care of most of these outposts. Most of them are small isolated mountain towns, which makes sense that they might not have structured economies, but there are several large cities in there (around 80k), which starts to make less sense in my mind.

Full trade network (sea routes not yet added), after many attempts to use force-directed layout

January 1, 2019

Desirability III

I am working on making the desirability index more parameterized. With this, I can create sets of parameters for each race, because humans, elves, etc will not desire the same climates, terrain, or biomes for their habitations.

I'll probably be tweaking those recipes for a long time. I haven't looked into details on the races (5e is, of course, deeply unsatisfying). But I'm not worried about that for now.

Most races avoid the rainforest - the soil is often poor for many types of crops. Dwarves like mountains and avoid the coast - but they're not total loners so they'll utilize rivers for travel. Stuff like that.

This is a hard map to read - essentially I've layered five races on top of one another; humans: green, elves: red, dwarfs: blue, halflings: orange, and orcs: purple. Why those five? No idea. I wanted the three classics, plus a feature race for ice and desert climates that would be inhospitable for the others. The orcs end up with a lot of territory, but they are not as gregarious (modeled with an infrastructure penalty), so the size of their empires should theoretically be limited. The elves also have a wide distribution thanks to the large amount of rainforest (unless I penalize them for it also).


All of this is, of course, very modular. It's easy to change the climate models and then propagate those changes to the desirability. This is a far cry from where I was earlier this year, where a map like this would require tons of manual rework.

Creating this Step 0 desirability map is more or less straightforward (tweaking is, as always, necessary). However, existing infrastructure will also affect the terrain...but I haven't built any of that code, so that will need to be next.

November 12, 2018

Resources XV: Revisiting Metals in Demoland

Now that we have data on all the metals we need, I'm going to revisit the resource distribution in Demoland. From here, we can gradually build up society as it might have expanded in this kingdom.

This map shows potential resources in each hex, not necessarily the exploited ones. I've also left off agricultural references, because the map tends to get pretty cluttered, even with just a few symbols. The symbol reference can be found here. I've grayed out the symbols on purpose. Once we being actually placing them (again), they'll be more visible to indicate their exploitation.

Maps like this can be helpful for certain types of campaigns. Knowing what materials are where can inform an ambitious party searching for a source of wealth, or a place to found a town and be king of their own country. At least, until Rich Neighbor gets jealous...

August 24, 2018

Resources X: A Man's Gotta Eat

As far as agriculture goes, there is no better resource I've found for implementing crop distribution than the Ramankutty Lab. This is an absolutely fantastic repository for the distribution of 175 different crops.

However, that's a lot of work for me to do, even though the heavy lifting has already been done. I have to figure out how to translate those stats into something my program can read. I have climate data, of course. Just have to decide which wires to plug in where.

Ramankutty provides some models for predicting crop cultivation based on the length of the growing season. This is a good start, although they use some data I don't have, like the actual evapotranspiration and the soil moisture index.

For my purposes, at first, I might just go through the data and figure out what Koppen climate the crops roughly align with. That's easy enough to do by layering the kml files which are easily available. I'll only post an example here: please go over to the repo linked above to get the data for yourself. It's very informative. This is probably the easiest way to do it: I can't find any crop lists compared to Koppen unfortunately; there are some broad generalizations but that's all.
Source: Earthstat

Then again, it'll take a long time to go through 175 crop types. So I think I'll prioritize and work through them here and there. I'm also having a lot of fun making the symbols for them. I've either used alchemy symbols straight from the Quivira font or combined glyph shapes in Inkscape to maintain a consistent style. I also like the Symbola and Esoterik fonts, but I haven't had occasion to use them yet. I don't always use the alchemy symbol, most for metals, but I do try and tie it in somehow if I can. If a bunch of mystic medievalists did all the work for me, why reinvent the wheel? For example, barley and rye (both used in alcohol production) use various forms of alcohol symbols.

In terms of translating the yield numbers to actual reference numbers, we can calculate the number of acres it takes to produce one reference, and we also need to know the amount of arable land that's available for agriculture. This varies from climate to climate, and I need to do a more detailed study of the percentages there. For instance, India's Aw climate gives them a mind-boggling 52% of arable land, but only 4% is used for crops. Then, how many people does it take to work a single acre? Estimates are all over the place (since it may vary per crop), but the basic grains seem to be around 20 acres a person. I'd rather use 10 in the absence of better data for now. I've worked 10 acres before (vineyard), and it was rough but doable.

So the code will need to decide if the settlement will run out of available hands or available land first. Not so hard.

I'm looking over these yield numbers and some seem a little high for a pre-modern society, even assuming some magical assistance from the local druid. So I may revisit them.

 
Wheat: Cfb. Primarily, at least. One thing I'm doing is ignoring some of the smaller yield areas to account for differences in technology. Wheat is pretty hardy and can be grown in many different climates, but the highest yields are predominately Cfb. Yields 1,000 lbs/acre.

Barley: Cfb, Cfa, BSh, Dfb, Dfa. Another versatile crop, without which your stereotypical dwarfs will be ale-less. Of course, if you want beer, you need hops as well. Yields 100 lb/acre.

Oats: Cfa, Cfb. Yields 480 lb/acre.

Maize: Cfa, Dfa, Csa, Csb, Cfb. Yields 500 lb/acre.

Cassava: Af, Am, As, Aw, Csa, Cfa, Cwb, Cwa, Cwc, BSk, Dwa, Dwb. Very wide distribution. Yields 1,300 lb/acre.

Rice: Aw, Am, Cfa, Cfb, BSh, Dfb, Cfa, Cwa, Csa. This stuff will grow basically anywhere you have water. Yields 1,125 lb/acre.

August 22, 2018

Expanding Demoland

So far I've only considered the people who live in the actual settlements as part of the industrial system. However, I neglected to consider the rural population in this equation. It's a lot more work to manually input everything, but I already mentioned that doing it by hand the first time helps me design a better program in the long run.

The biggest effect is that there will be more market towns. In fact, so much so that I might raise the support value for some of the industries. The system is much like a musical instrument - it must be tuned to produce optimal results.

I still had a few rules. I only expanded into hexes which bordered existing settled hexes. Otherwise, I'd have to make up a whole new set of rules for how far a hegemony extended, and that's a problem for another time.

I really like the way the map style is progressing. I need to think about how I'm going to make these automatically, but for now, the manual approach is nice. Hopefully this uploads with enough resolution to see the interesting features. Maybe I should have done like Chicago Wiz and stuck with 3 hexes at a time.


Cadewin and Ffrith are now market towns, but things are pretty expensive. Still, it's a long way down through the forest to Derl from Cadewin, so you should just suck it up and bear it. Cadewin, at least, is lucky to have a road down to Derl. Betryn isn't so lucky - they can take their chances through the forest (remember, no roads, so what trails are there will take a twice as long to traverse with a cart) or raft down the river.

August 20, 2018

Resources IX: Demoland's Iron Industry

Industry is kind of a strong word for what they've got. Remember, barely anyone lives here. They have a good bit of iron, and not that much money to buy it with. There are only three places where they even can buy it: Andox, Gerlin, and Malis. They also have no connection to any outside economy, so as far as they know, iron is just cheap as dirt.

It's possible that an economy this poor (or at least, lacking in the Big Three fantasy coinages of copper, silver, and gold) would be on the barter system. However, the trade system is still of use here because it provides a comparative measure of value. If a goat is worth 1gp, and a chicken is worth 5cp, then a goat is worth 20 chickens. Easy.

I'll be going through this a bit slowly, since I'm uncovering bugs as I go back through all my code.

Also, these numbers are constantly changing. Eventually, of course, this will all be generated, but I'm a strong believer in doing it by hand at least at a very small scale so that I can catch some of the bigger problems as they come up. So some of the reference numbers might be too small or too large. I already caught a problem like this for the wood reference. In large economies, this can get lost in the weeds, but in small economies like Demoland, it can have huge social ramifications.

With the same caveat of constant development, I haven't fully researched some of the ores that appear here, specifically copper and silver, at least in terms of putting them into the system. So they appear fully formed, for now. Clay also appears (since you need it to create the furnaces to refine iron).

Not all cities are markets. Market towns are displayed in small caps. I try to keep the resource symbols up to date here.

  • Andox is the market for Kenor, Norys, Derl, and Cadewin
  • Gerlin is the market for Llen and Betryn
  • Malis is the market for Ffrith
The reference amounts are as follows:
I'll put up another post soon talking about the recipe system I use to integrate my version of the Tao's trade network. But already I can see that this place is a total backwater. It helps to remember that about 80% of people live around, not in, the villages. Andox, for example, has over 5000 people scattered around it. So even though the town itself might be very small, it directly administers hegemony over a much larger population (including the surrounding hexes, so almost 8000 all told), many of whom will have to do business in Andox itself, since it's the best place to get iron tools (among other things).

August 13, 2018

Resources VI: Industry

I realized that I had discussed iron working without really talking about how, from an economic perspective, the raw materials get pushed down the chain. Of course, this is accomplished by industries.

This leads to the question of how many industrial references are present in a place? The first consideration is the tech level of the region (not necessarily the individual settlement). Remember that Demoland is T-8.

One of the really common things to do these days is look up the Support Value (SV) of the industry in question and use that as a cut-off for whether or not it's available. I don't really like this for a few reasons. For one, it's all based on medieval France. Secondly, just because you hit the correct cutoff doesn't automatically grant you that industry.

Instead, I'll use the concept of SV as a jumping-off point. Once the population reaches SV, the industry is possible but not necessarily present. A higher population grants a higher chance to acquire it.

We can codify this using the following equation, where $P_i$ is the percent chance that an industry exists, $p$ is the population of the settlement, and $\sigma_i$ is the industry SV:
\[P_i(p, \sigma_i) = {p - \sigma_i \over p - {\sigma_i \over 2}}\cdot(p\geq\sigma_i)\]
This returns zero if $p < \sigma$. I've also structured it so that if $p = 2 \sigma_i$, then $P = 0.5$.

Assigning the support values themselves is pretty arbitrary, but should be roughly matched to the tech level it's in. Using the example of iron working:

A charcoal burner is necessary to turn wood into the charcoal used in a forge (if coal is available, that will probably be used instead, but I digress). This is a pretty low-tech industry, and it's existed for thousands of years. I'll call it T-6. This level is available from around 170-360 population/sqmi, so I'll choose 250 as the SV.

Ironworking (to refine the raw ore) and blacksmithery (to turn it into something useful) are both a bit higher up the chain, but not too much. T-7 is 360-750, so these two can have an SV of 600. This will make it uncommon, if not super rare. They're specialized skills, after all. In higher populations, though, they'll become more and more common.

Right now, the function given above just returns a chance. If we compare this to a random number, that will tell us if a reference for that industry appears. If we repeat the process for the number of times the SV will fit into the local population (so repeat $n = \lfloor{p\over\sigma_i}\rfloor$ times), this will increase the number of references.

Using that logic: Andox has a population of 1208. Therefore, $P(1208, 250) = 88.5\%$ for a charcoal burner. Since $n = 4$, we can have up to 4 references of charcoal burner here. As it turns out, there are only 2!

Running the numbers for the rest of the cities and industries: Andox has 2 charcoal burner references, 2 ironworker references, and 1 blacksmith reference. Malis and Derl each have 1 charcoal burner reference.

A few things to keep in mind: this system does not capture what people make themselves, only what is available for purchase in the local market. Secondly, this doesn't necessarily mean that there are but 5 people employed in the metallurgy business in Andox - it's merely a number to aid the system. They even might be all the same person!

Even from this, it's obvious that Andox's higher population make it the place to go if you want an item to be crafted with any level of skill. Scarcity creates conflict! Idiosyncrasies also lead to good story opportunities. The illustration here is limited because of the low population size, but Gerlin has no charcoal burners, despite being technically larger. Why is that? Why does Derl, a smaller village, get one? Food for thought.

I wish I had more to offer here. The system is starting to take shape, but I had to throw out all the commodities I'd built up, because the system wasn't nearly cohesive as the one I'm designing now. I had 73 total raw commodities, 165 products, and 42 industries. Not bad. Before diving too deeply into Demoland, I need to add a few things to the system (like currency or food) in order to let it stand on its own two feet.

On the other hand...if I wait for the system to be complete before using it, I could be here a few decades.

June 22, 2018

Resources II: Iron Mining


Iron is a must have resource for a D&D civilization. I want to explore how iron can be found, and what other elements are found with it. I'm particularly interested in what kinds of things generally appear together. This will help me design a system for generating consistent placement of resources.

Iron has been mined for a long time. I found this article, about a Nasca ore mine, fascinating.

There are five major types of ore containing iron. There are some general trends that can help place them.

  • Hematite. This is probably the most common form. It usually occurs in banded iron formations in sedimentary rock. You can also use hematite to produce various ochres, specifically in the colors of yellow, red, purple, sienna, and umber, depending on the concentration of impurities.
  • Magnetite. Sometimes found in sands, but largely igneous and metamorphic rocks. It's also a good source of magnesium.
  • Siderite. A poor source of iron, so I'll pretend it doesnt exist.
  • Limonite. This is found in a class of soils called laterite soils. They are often found on plateaus, and contain large amounts of clay, aluminum (unknown to ancient peoples), and sometimes nickel. It's also useful for yellow ochre. More importantly, gold is often found in limonite deposits. It's generally formed in areas with alternating wet and dry seasons.
  • Goethite. Commonly found in bogs, an early source of iron for the Welsh and Norse. The generation of bogs is something I'm still trying to figure out. While most of the other ores must be dug up, goethite can literally be picked up by hand out of the muck. In addition, a bog that's been picked clean generally replenishes every 50 years or so as the iron from deposits continues to coalesce. Yields brown ochre.
There is also meteoric iron, but it is so rare that any weapon made from it would certainly be an artifact and therefore priceless in any game.

Goethite and limonite are the lowest-tech and lowest-yield sources. When the limonite is worked, it actually turns into hematite. So these will be the first available in the tech system. Hematite and magnetite are harder to get and require more infrastructure and technology to extract iron from the raw ore. I need to do more thinking about what levels to assign to each of these resources. Of course, it requires additional knowledge to extract nickel and magnesium.

I'm thinking that to get a good idea of the distribution of some of these ores, I need a better system for figuring out the distribution of the different types of rock.

Resources discussed: hematitemagnetite, limonite, bog iron, clay, nickel, yellow ochre, red ochre, purple ochre, sienna ochre, umber ochre, magnesium, gold

June 20, 2018

Desirability I

Where do people live?

My plan is to set rules to determine a value of desirability. Cities will then be placed at the most desirable locations first, and then less desirable. When I get around to the history simulator, this rating will be used to guide the spread of civilizations. Azgaar has a very nice demonstration of this process here.

The base desirability will be 0.

+1Coastal hex
+1Natural harbor (if only one of the hex touches the ocean). I need to think about how I can check for this, since I currently use hex centers and not edges
+1Per point of river drainage. This might be a little much, since these rivers can get fairly large. The Amazon would, by this system, have a drainage value of about 6800 at its mouth. Predictably then, the city of BelĂ©m was the first European settlement on the Amazon
+1Per number of rivers joining at this point ($n-1$).
+1Per raw (Stage 0) resource. Some will naturally be worth more than others (gold is better than copper), but overall this will be a good start.
+1Within a favorable biome. This will capture temperature ranges as well as roughly approximating agricultural potential. It's pretty difficult to find information on specific biome suitability, since mankind is incredibly adaptable. For now, I'll just add this if temperature is between 60 F and 90 F, and if the biome is not E (tundra) or B (desert)
-2In fact, E or B biomes are likely to be extremely unfavorable to settlement
-1Mountainous terrain isn't great either

Applying those simple rules yields this:

Desirability map
A few thoughts. First, the rivers are looking very nice. There are some which drain uncermonially into the sea after a few dozen miles, and some which arc across the landscape. This map is set to have no endorheic basins but I'll be changing that, maybe even to the 17% Earth value. Second, the ideal bands are still pretty sharp, and I don't really like that. I have my doubts that wind could push enough moisture to form a rainforest across nearly 6000 miles (bottom right). I might need to further reduce the penalty for the tundra.

However, I just had a thought that if different races prefer different climates, perhaps I could create a different map for each. Everyone likes river trade, but halflings are particularly suited to the cold and so have penalties in warmer climates, whereas orcs are desert dwellers and build their cities in heat that would make an elf weary. Food for thought. The system is extendable and takes very little time to solve - I've vastly improved the brute force algorithms of a few months ago and now changes are easy to make.

May 30, 2018

Trade II: Trading Cities

It's pretty easy to define a trading city by fiat. But what if there were a better way? A more consistent way.

Since I have all of the references and cities in a network, and I know how far references can travel and how far their influence reaches, I can directly measure which cities are natural bottlenecks for trade.

There's a couple of ways I can measure this. I can determine the total references flowing through a city. Or I can find out how many individual routes flow through it. Per reference, or simple? Per reference is probably more accurate, but simple (how many routes run through regardless of carriage) is faster. Now, I'm only concerned with how many routes pass through. This will help determine the type of culture the city has - a high volume trade point is politically advantageous.

I need to run some tests to know if that data is even useful, though. Given a scenario where all references are available (even at tiny quanities) to all other settlements, would the trade flow be the same for every city? Even in this case, I don't think so. A city on a river would be found by the algorithm more often than one near the hinterlands.

A truly isolated town may have zero routes (terminal nodes). What are the implications of this? For certain, if you're going there, you're going there, not through it (or you're leaving). That could lend it a certain importance, depending on the size. It may even be a destination settlement. More likely, though, it's a small mining town up in the mountains, probably with no market of its own. Maybe a small trading post for basic goods.

Such towns are cliche starting points for campaigns or stories. The Shire, Two Rivers. Whatever Eragon's village was called. The simple heroes, unspoiled by the modern life of the city. It's good for campaigns, because you can give the players a few sessions to get acclimated to their new surroundings.

May 9, 2018

A Model for Politics and History

For a few weeks now I've been mulling over a pretty complex problem.

I'd like to be able to simulate years and years of history, the rise and fall of civilizations, and the growth and decline of settlements.

Not only does this require a pretty indepth study of how individual settlements are formed, there is also much work that would have to be done to see how those settlements interacted, conjoined, fought, etc.

Assuming that I can figure out where the people live, I plan to build a series of simple Markov decision trees and cellular automaton to stochastically figure out what happens next. This is a good substitute for emergent order. In fact, I already have the structure for a cellular automaton, since my map consists of individual hex objects, each with its own properties.

Has it been done already?

Sort of. I suppose I need to step back and design this from the ground up. What features do I want? What sorts of inputs are important to the model? Most importantly, how does the model interface with the map I'm building (the timescales I need are far shorter than anything that would affect the geography significantly, barring a worldwide cataclysm)?

May 7, 2018

Trade I

I've mostly copied Alexis's trade system so I won't say much about it beyond that it's a fantastic conception at its core. Credit where credit is due.

My own take on it uses a network to model each market city as a node. By using a multi-directional graph, I can put all the different possible trade routes into the network, and let some simple algorithms figure out the shortest distance between two points. Should we go around the mountain, or through the desert? Paddle up the river or just take the road? All of that work is off-loaded to the algorithm. I still have to do some work inputing the raw distances between each city, but I hope to automatically calculate that as well from my mapping code.

Right now every industry is technically available in every place, given that the settlement meets the minimum population requirement for that industry. Ultimately, I don't quite like this, but I need to think of a way to determine which industries are available where. For example, for boatbuilding to be available, wood must be available, and presumably, access to the coast or a large river.

Ultimately, then, the best trade system is dependent on a robust resource description table. Each resource (including industries) must have prerequisites for its appearance on the world map. More complicated resources (such as worked metal) are calculated from a series of recipes, similar to the system found here.