Procedural Map Generation for Crusader Kings II, Part 4: Markov Names

All of those counties, duchies, kingdoms and empires need names to go with the shiny new borders we’re drawing.

The easiest way to do procedural naming is with something called a Markov chain, a mathematical concept which models changes from one state to another based only on the current state, and not on any ‘memory’ of what happened before (which is not to say that a Markov chain doesn’t use RAM!). Markov chains have applications to other areas, notably in finance, Baseball, and biological population studies, but their most readily apparent application is to generating pronounceable random text.

It works like this: you look at the last N characters of your text, and then at the characters which are allowed to follow them in your sample words, choosing the next character from those among them at random. (The first character is chosen at random from all the characters used to start words in your sample.) We call N the ‘order’ of the Markov generator. Given a vocabulary of English text, Markov generators of order 4 or higher will regularly produce real words, and only rarely give output to make spellcheck unhappy.

I grabbed a Markov generator from the guys at Silicon Commander Games, and found its features to match exactly with my requirements. They were using it to name characters, but naming locations works just as well. I then copied the lists of counties, duchies, kingdoms and empires from the CKII wiki, massaged them as necessary to make comma-separated text files, and fed them to my program. There are only 15 empires in the vanilla game, so I added some more seed data, such as the “Romulan Empire.”

Here are the first few counties for one particular world seed:

Duchies:

All the Kingdoms:

Empires:

As you can see, the Empires are a little weird. I’ll add some custom logic to improve the imperial nomenclature later. The word list for kingdoms doesn’t seem to be long enough, since we’re seeing a lot of kingdom names from the vanilla game. It’s expected that you’ll see a few over time, but seeing Sicily, Arabia, Greece, Hungary, Italy, Denmark and Mesopotamia on my first run indicates that we’d be seeing multiple vanilla kingdom names in every game.