Simulating Medieval Logstics

March 29, 2017 | Posted in Development | View comments

One of the challenges in creating a simulated medieval world is that nothing can be glossed over. In a normal strategy game, armies might consume a set amount of food per turn, which is simply deducted from the player's total supplies. In The Amaranth Saga, each individual soldier must be given rations. The rations must be physically carried, by couriers, to the army. The generals must actually tell the couriers to deliver food, and make sure it arrives when needed. And so on and so on.

Deciding how military (and civil) logistics will work in The Amaranth Saga is a hugely complex process, so we're going to break it down. For now, let's think about how the AI will make sure its armies receive supplies when needed. In this post, we'll look at one possible approach...

We'll approximate the food carried by an army (or anything else which consumes supplies, like a city) with a graph...

Graph of food over time

As we can see, some amounts of food may be more or less desirable than others. We'll measure this using utils. Perhaps having enough food is worth 10 utils, whereas starving is worth -50.

At any given time, an army has several ways of gaining food. For example:

  • Ask The Duchess for 100 food, which would arrive in 10 days.
  • Send a courier to collect 50 food from a cache, which would arrive in 5 days.
  • And so on...

We can visualise these opportunities on another graph, with each point representing an amount of food gained at a particular time...

Graph of opportunities 50 food from the cache and 100 food from the Duchess are marked A and B, respectively.

We can then consider the army's food-over-time, if different opportunities are taken advantage of...

Comparison of opportunities

We can measure how desirable each possibility is in utils-over-time. For example, the utility of an army that is ideally supplied (10 utils) for a month, and then starving (-50 utils) for a month, would be -20 utils per month ((10 - 50) / 2).

In order to calculate the ideal way of supplying an army, we would choose the best opportunity available, and then the next opportunity available after that, and so on. During this process, we could cut down the amount of food collected from each opportunity to avoid over-supplying the army. The end result would look something like this...

Supply optimisation steps

At the end of the process, we will have calculated the optimal way of supplying the army.

Now, this approach is very flexible. We can assign utility values to the supply opportunities, and include these in our calculations. This covers scenarios like pillaging the countryside being less desirable than simply collecting supplies from a stockpile.

Unfortunately, as we'll see in later posts (here), this approach isn't good enough for The Amaranth Saga. There are many complexities which it cannot handle. The medieval world is chaotic and unpredictable. Armies and supply sources move around. Opportunities for supply number in the thousands. Supply lines can be disrupted, communication delays prevent centralised control of resources, and so on.