Creating realms

Posted on Sun 22 June 2014 in worldbuilding • 5 min read

The story so far

In the last month or so, I've been building the groundwork of a world-building application. The aim is to create fictional or constructed worlds quickly that are both internally logical and have some ingredients from historical models baked in. The application itself is currently a bunch of PHP and shell scripts that create and manipulate markdown and json files on the command line. Eventually, I'll redevelop the application into something anyone can use in a graphical environment but now I want to get the internal logic right and for that I don't need much more than scripts.

So far I've created skeleton module to manage stories and characters. Characters are fundamental to both world and story so it makes sense (to me) to include them in the application. Likewise, creating tools to help me develop stories in a structured manner within the context of the world also makes sense.

Today, I start to build the first physical elements of my worlds: namely countries or realms.


Realms are where the events of a story occur; they're where characters live. The realm is the basic building block of the world and they can be as complex as a mighty multinational empire spanning continents or as simple as a modest city-state. Realms will have different political and economic systems, languages and ethnicities, technologies and religions. An empire may have dozens of jurisdictions, regions and settlements whilst a city-state may have only one.

Therefore, whatever I build has to be flexible enough to handle different realms and grow on demand while being accessible enough that I don't drown in a sea of unrelated data. Above all, I want to be able to automate the process of creating data accordingly to internally consistent rules inspired by historical models and some of the tricks that tabletop game-masters have developed.

Realm template

As with characters and stories, I'll start with a basic template composed of pre-defined content in markdown and json format in a folder structure. It will look something like this:

        realm 1/
            region 1/
                /settlement 1
                /settlement 2
            region 2/
                /settlement 3
                /settlement 4
        realm 2/

I'll look at creating settlements in the next post so today, I'll concentrate on getting the top-level structure and files right.

realms_index.json will be an index of all realms with some basic information that I'll be able to parse quickly into an array.

Each realm will then be stored in a folder, titled with the realm's slug, for example kingdom_of_england. Within that I'll have two files:

  • realm.json containing top-level statistical information, and
  • containing a narrative overview of the realm. will probably end out looking like a wikipedia entry for a country though at some point, I may decide to break it up into separate files such as:, and et cetera.

Each realm will have any number of regions. My thinking at the moment is to include a region as a separate folder containing multiple settlements. I'm not 100% convinced this is the right approach (the other approach being to tag a settlement's metadata with a region). Regions represent administrative districts or provinces within a realm with historical examples being:

  • Roman imperial and senatorial provinces
  • Satrapies of the Persian Empire
  • Counties, baronies, duchies and principalities of the Kingdom of England
  • Diocese and bishoric in the papal states and Holy Roman Empire
  • The kuni (国) han (藩) of Feudal Japan
  • The Thirteen Colonies of North America.

In centralised and well organised states this makes sense, but in the middle ages, where rulers could be a king in one realm and a duke in another, administration was much more complicated.

Multiple Templates

Given the complexity and variety of realms we could complete, I want to build into the application the ability to use different templates. This may sit at the realm or settlement level or both. Implementing it has proved to be easy but I'll have to experiment a bit to see how practical it is.

Creating realms

As with the other modules, the basis of the create_realm tool will be to duplicate the realm template and begin to customise it as a new realm inside the world folder. However, part of that customisation will be to generate much more data about the realm than I've previously done. So the tasks I want the tool to accomplish are:

  • Duplicate the realm template (user's choice), renaming various default files and folders accordingly
  • Ask for key geographical information including:
    • Area of the realm in square miles
    • The Realm's population density
    • The level of urbanisation
    • The average population of an urban settlement
    • The average population of a rural settlement
  • Use that supplied information to generate the realm's:
    • Total population and population pools for urban settlements and the hinterland
    • Ratios of arable land to wilderness
    • Approximate number of urban settlements
    • Approximate number of rural settlements
    • Possibly the realm's capital city

The code for copying the template and requesting information is no different to what I outlined in the create_character and create_story tools so I won't labour over it.

Once the the geographic information is entered, the application then uses is it to calculate the data listed above according to the following formulae:

  • Total population is the Area x Population
  • Urban population pool is based on the urbanisation percentage of the total population
  • The Hinterland population is what's left of the total population
  • Arable land is calculated as the amount of land needed to feed the total population with the wilderness being what's left
  • No. of urban settlements is the urban population divided by the average population of urban settlements*
  • No. of rural settlements is the hinterland population divided by the average population of rural settlements

Note These are averages only rather than representative of the actual number of settlements. When I go to generate settlements, I'll use a more complex algorithm.

Generating the capital city is also something I want to do. Since the capital city is a settlement, I'll write about that in my next post as segwey into the development of the settlement module.

Share on: Diaspora*TwitterFacebookGoogle+Email