February 27, 2019

History V: The Darkness Dwells in Durin's Halls

I nuked the dwarfs.

The problem had something to do with how the carrying capacities were calculated. Due to the dwarves geographical blessings, they generated massive cities and huge numbers for infrastructure, allowing them to spread much more quickly.

No more.

Darker color = bigger city

Of course, now the human settings might be too high. But such tweaking is still progress.

There are also almost no elves now. Interesting! Part of the fascination of doing this is observing how different parameter combinations generate such unique historical/social outcomes.

February 23, 2019

History VI: The True Master Race

The dwarf problem.

That's what I've been calling it, anyway. I want this world to be fairly evenly distributed between the Big Three (elves, dwarves, humans), with humans having a slight edge. To account for this, I gave the human race a bit of a leg up, making their growth rate modifier 3x that of any other race (this affects random colonization as well as general population growth).

That's not even close to the case.

Dwarven cities far outnumber anyone else. By a lot.

850 years
Looking at the average $r$ of each race's cities sheds some light here but is ultimately no clearer as to why this is happening.

human     3.05%
halfling  3.67%
dwarf     6.74%
orc       0.52%
elf       0.79%

Dwarves are growing more than twice as fast! Insane.

I have some theories. Dwarves, who don't care if they're near a coast or not, have way more spaces to expand - all 6 hexes. So they are more likely to form roads, which do give a bonus to the growth rate. Only thing I can figure is that they're much more likely to form roads and build up their empires. Positive feedback.



To the tune of 52% of the world's entire population. Truly, the master race (for now...).

February 21, 2019

History IV: Diminishing Returns

I had some good discussion on Reddit about the last post, and one thing that stood out to me in particular was the idea of diminishing returns for the effect of infrastructure on desirability. If the contribution is linear, existing infrastructure may quickly come to dominate the scene.

Year 2000, way too much growth? Colored by political entity

However, I think I still want a separate metric for new city placement. I think both of these are worth implementing to see how they affect population distribution. Disregarding infrastructure will be the easiest way to find a new spot for a totally new settlement, whereas a city expansion or colonization will want to stick close to the original and make use of existing infrastructure.

Year 500, colored by race
It is still curious to me how the geographic isolation of the dwarves results in a rapid growth of both cities and infrastructure. Humans should technically expand faster...but they don't. I look forward to exploring if this is merely an error in my code, or an example of emergent order.

February 13, 2019

Roads V: Hard to Port

Testing roads is already pretty difficult, since I want to let the population build up organically before placing them. Seaway routes are even more so, because they require a little more infrastructure to generate. They look good, except there are too many and they're not quite long enough.

As pretty as these look, I'd like to add a little intelligence to them. For example, these are really long journeys. Let's say that A, B, and C cities lie along a coast.

Furthermore suppose that an established route already exists between B and C.

Now, if A jumps into the sea-trade game, and wants a route to C, would it be preferable to go straight there, without resupply?

Instead, it's preferable to harbor at B, assuming that B is a friendly city.
So when selecting targets, the code should be able to check if there's already an existing route from B to C (and maybe there are more stops in between?) and reroute through an existing channel. I already kind of do this with the roads, but they're also constrained to a limited number of connections (since roads are physical objects which require maintenance, a trade route is an abstract concept).

This also assumes that a route A>B>C is always preferable to A>C. This might not always be the case. If B fell into enemy hands, then obviously it would no longer satisfy the criteria for a safe harbor. However, I can take this one step at a time and see how things shake out before adding additional constraints and shifting conditions.

February 12, 2019

Roads IV: Take to the Sea!

Sea routes are essential for trade between people. I suppose you could have robust trade networks if you were confined to land, but it's a lot easier (not without risk) to put a bunch of stuff on a ship, rather than haul it across a dangerous terrain.

So naturally I needed to update my sea current algorithms and make sure everything is peachy there.

Once that's done, I can use my A* algorithms to place "roads" in the sea. Going with the current is easier, but the more you turn against the current, the more difficult it is. This means that a double-edged graph is in hysteresis: the return journey must take a different route.


It takes a while. The roads are by definition close by - sea routes theoretically make shorter work of a much longer journey. In addition, there are too many function calls in the algorithm right now, so I'll have to work on that.

Unlike roads, there is no maximum number of routes that may pass in a certain hex or a minimum score for a hex to support a route. You just sail through it. A higher number of routes might mean a higher risk of piracy, though.

I'd also like to add in a maximum distance that the route can be based on the development or infrastructure level of the originating harbor. A small fishing village will not be launching transoceanic trade routes.

It might also be good to penalize routes that are too far from a coast. It's harder to resupply when you strike out more than a day or two from a large landmass. But not impossible. So I'll work on that. It might make the route take longer but if you can avoid really long, empty routes, that would be desirable.

Even the shortest route here spends about 40 days out of sight of land
Regardless, this will be an interesting addition to the trade network.

February 11, 2019

Currents IV: Vitamin Sea

I couldn't help but think that there was something missing about my sea-current updates, as one does. And finally it dawned on me. When a current hits the shore, it should always go somewhere...somewhere not up onto the shore. Essentially, it should be parallel to the shore. It's not, and that was making things weird.



Turning them aside works a bit. Not great. But it'll do for now.


February 8, 2019

History III: Beyond the Pale

After several thousand years of peaceful simulation, I noticed an interesting phenomenon.

Hexes are supposed to have a random chance to generate a new settlement. However, the location for these places is determined by the desirability of a place.

The desirability is partially determined by the local infrastructure.

This means, apparently, that when empires reach a critical mass, it's essentially impossible for any hex that's not adjacent to one of these empires to generate a settlement! So once the first few large coalitions are formed, no others ever do (at least, not geographically separated).

year 2160, human kingdom
That's one reason I end up with every dwarf in the world in a single megalithic empire. It also kinda looks like Scotland.

year 2160, dwarfen empire

This could be solved by maintaining a separate desirability index that does not take local infrastructure into account.

After 2160 years:
race
urban pop.
orc
52,567
halfling
1,315,550
human
2,282,919
dwarf
1,535,095
elf
524,542

And that's a total (including rural) population of 101,621,930. Not bad.

February 5, 2019

History III: Rise of Civilizations

To this point, I've been placing cities more or less randomly. Sure, the presence of a large metropolis will increase the chances a bit, but the new cities are still spawning from nothing, essentially.

With the new changes, cities that are large enough (population at least 2500, for now) have a small chance to spin off a new city into a neighboring hex, if one is available. This should make things a little more procedurally driven. However, this can lead to a steady-state-esque system where all cities are around 2500 in population; every time they got bigger, the excess drained off into a new city somewhere.

Another big change is the way I'm processing the cities and placing new ones. Initially, I'd place all cities, then check all the new ones for birth/death rate, then check road availability, etc, etc. Now, I look at each city in turn and run through each of those functions in a random order. This allows a bit finer control over what's going on down at the local level, and I think it helps with the road generation as well, since I'm adding roads to cities as they become large enough, not waiting until the end of the year to place them.

The slowest parts of the algorithm are the remaining random city placement - I have to have some new civilization seeds - and the desirability/infrastructure algorithms. I mean, it's Python, so everything is pretty slow anyway, but those algorithms have to perform a calculation for each of the 108k hexes, sometimes many times. So there is definite room for improvement. My programming style is usually to hack something together that works inefficiently, and then target those inefficiencies later.

Generally speaking, it takes about 150-200 years for infrastructure to advance to the point of supporting actual maintained roads (keep in mind that the roads I'm generating are not the only way of traveling between settlements, just the only way of moving appreciable quantities of trade goods). A party could still travel along a trail, etc. The roads are looking much better.

Year 1030, halfling kingdom


Humans (green) spread out very quickly along the coasts. To adjust this, I can add some "gravity" to the expansion function to pull things closer together. These empires (if empires they be) would not be very manageable with early tech. Halflings (orange) dominate many areas, since so much of the map is near the southern pole.

Year 1030, human kingdom

Year 1030, halfling and dwarfen kingdoms
In every sim I've run so far, the dwarfs (blue) have about 3 or 4 kingdoms right here in the middle of the continent. This represents the only Dfc climate on the map, which my dwarfs like. So here they all are.

Elves (red) are pretty rare. I gave them a reduced modifier for growth rate (my elves aren't a bazillion years old, but they do live about 150-175 years), and that really tends to hurt.

Year 1030, human, elf, and halfling kingdoms
But what's this?

Year 1030, dwarfen kingdom...mostly
A pretty large elfish city, right smack dab in the middle of the biggest dwarfen empire in the world? How?

This is where the raw numbers can give rise to interesting story. The simulation says that a dwarfen city fell into ruins, through emigration or disease, and not long after, a group of elves moved into and took over, building their own metropolis! No doubt to the chagrin of the dwarfs. Fascinating.

race
urban pop.
dwarf184646
human444824
halfling429106
elf113819
orc61150

The total population (cities included) after 1030 years of simulation is 20,517,454. Not bad. Maybe a little much, but I do have five races. Elves grow very slowly, as intended. The dwarfs also lag, but since they are geographically clustered, it's not as obvious. But it might be rare to see a dwarf outside of those areas. Orcs are present on the map, but they rarely form permanent settlement, so their urban population is very low relative to the rest.

The next thing I need to do is figure out how these loosely connected settlements will coalesce into kingdoms and empires. I'd also like to include long-range colonization, not just expansion into an adjacent empty hex on land.