Skip to content

[Dev] The Resource Broker

Detailed insight, explained by Volker Wertich

Introduction:

The heart of the Settlers economy is the distribution of goods and their transportation. As many of these processes are automated, a complex game system is necessary to make smart decisions. We call this the “Resource Broker,” and it plays an important role since the very first game, “The Settlers.” Today, we want to give you a detailed insight into how it works!

The “Resource Broker” decides which goods are transported to which location and by what unit. For the player, it is important that the automated ruleset behind these decisions is effective on the one hand, but also predictable, as the player needs to understand what is happening in their settlement.

As hundreds, or even thousands of transports happen simultaneously without player commands, the player instead needs to be able to make decisions that influence the Resource Broker indirectly. The player does this all the time by choosing locations for buildings, deciding when to place or upgrade a building, or by ordering troops of a specific type. But we will also see that the player has control in increasing the priority for a building or by pausing specific production chains of selected buildings.

1. Piles:

A pile is a certain amount of a single good type at a specific location. There are piles in the game that either offer goods, request goods, or do both at once.

Piles that offer goods:

  • (A) Outgoing piles at resource buildings: For example, a woodcutter cuts a tree and brings home a tree trunk to his hut, which is offered as soon as it arrives on the pile.
  • (B) Outgoing piles at production buildings: For example, the smelting works turns coal and ore into iron and offers it as soon as the iron is ready.
  • (C) Currently transported pile: Even a pile which is currently being transported can be offered and redirected. E.g., if a donkey cart moves five wood units which were not needed elsewhere to a storage building, and in the meantime another new building has been placed by the player that requires these units, they will be redirected to the new building site. Anything that is currently being transported to a storage building can still be offered.

Another reason why a transported pile can turn into an offer is when a cancellation occurs. If a transport cannot be resolved anymore, for example because the player decided to cancel a build order, or the target building was destroyed by enemies, the current transport is canceled. The goods will be offered again. If there is currently no need elsewhere, the carrier looks for a nearby place to drop the goods and creates a “landscape pile.”

  • (D) Landscape piles: For different reasons, one reason described above, the player can have landscape piles in their territory. These also offer goods.

Piles requesting goods:

  • (E) Production buildings: E.g., the Smelter has input piles for both coal and ore to be able to operate.
  • (F) Recruitment buildings: E.g., the Archery yard asks for bows to be able to recruit new troops.
  • (G) Building sites: Any new building that is constructed has input piles.

Piles offering and requesting goods at once:

  • (H) Storage buildings offer and request the goods they store simultaneously. They request goods to ensure they are using additional storage capacity, and at the same time, they offer their currently stored goods.

2. Priorities

Now that the Resource Broker knows the locations and amount of offered goods as well as the locations of requested goods, priority comes into place.

If there is a substantial surplus of goods and enough transport capacity is available, priorities do not matter a lot: every request can be fulfilled. But as the player will try to optimize their economy and make the best and most efficient use of their goods, there will be a shortage of specific goods all the time and probably a shortage of transport capacity at some point, too. To ensure meaningful decisions by the Resource Broker, there are different priority levels, and within a priority level, there are sub-levels and urgencies to determine decisions.

Let us run through the priorities from the lowest to the highest level:

Priority 5: The lowest priority is level 5, which includes all requests for storage buildings. It applies to surplus production that must be stored and brought to specific storage locations, which is usually not urgent. As mentioned, all transports heading to storage can still offer their transported goods and may be redirected if there is a need.

Priority 4: The standard priority is level 4, which includes all the normal economy requests of production and recruitment buildings. This applies to the majority of all existing requests and includes all continuous goods distributions. Within this category, all decisions are taken using urgencies, which will be explained below.

Priority 3: The highest automatic priority is level 3, it includes all current orders to build or upgrade something that requests goods.

Generally, we define that anything the player wants to build-up has higher priority than the normal economy requests of priority 4. While this is, of course, questionable under certain circumstances, it is usually a good approach as the new buildings often play a key role in the player advancement and the resource requests for build-ups are one time only while all the requests of finished buildings are unlimited and happen continuously.

Within priority level 3, there are two more sub-levels which further decide the priority:

  • The first sub-level defines that buildings have priority over fortifications and fortifications have priority over roads. As above, this is a pre-defined priority which is usually, but not always, a good choice.
  • The second sub-level defines that older build orders have priority over newer build orders. This ensures that the order placement by the player matters and that the result after some time will be, e.g. 5 of 10 new buildings finished and operating instead of 10 buildings all half-finished and all non-functional.

Priority 2: To ensure that the player can overrule the Resource Broker’s decisions if needed, we grant the player a “high priority” function for finished buildings, which raises priority 4 to priority 2. This means the player can prioritize individual finished buildings higher than everything that the Resource Broker decided. This allows the player, for example, to grant a weaponsmith building highest priority because they want the deliveries for the sword production handled with highest priority.

Priority 1: The player can also use the “high priority” function for building sites, which raises their priority from 3 to 1. The sub-levels of Priority 3 work the same way here, which means if the player sets five building sites to “high priority,” the same sub-priority rules as described above are used to further differentiate between those.

3. Urgencies and distances

While the priorities already separate all the possible matches between offers and requests, within the same priority there can still be dozens or hundreds of valid offers and requests. A single building site may receive the missing boards for construction from any of the sawmills the player owns, or from any storage that contains boards, or potentially from landscape piles if they exist. Now the urgencies and distances decide which offer is matched with which request.

Urgencies go from very high to not-at-all, and work as follows:

The input pile of a building site has a higher urgency if it is empty or almost empty, as the building cannot be constructed without the goods.

The input pile of a production or recruitment building has higher urgency if it is empty or almost empty, as the building cannot operate/train without the goods. The urgency drops to zero if the pile is full.

The output pile of a resource or production building has higher urgency if the pile is full or almost full, as the building stops operating if there is no room left to store.

The landscape piles get an urgency above average, but not very high. In theory, they could remain forever, but for a better overview by the player, it is better to get rid of them sooner or later.

Distances are quite obvious: The higher the distance between a requesting and offering pile, the less effective the transport order is compared to another transport with less distance. It is important to know that the real walking distance, not the direct-line distance needs to be considered.

Distances are considered together with urgencies, and basically, the Resource Broker accepts the double distance if the overall urgency is twice as high too. As the urgency values can be balanced individually, this grants the game design team a way to control the impact of distance.

 The match: Finally, when the Resource Broker matches a request with an offer, a carrier will be assigned to execute the transport job… but we will skip the details for carriers, as we will grant more insight about different carrier types and their behavior in another article!

4. The Extended Example

Now you have heard all these rules, can we explain the impact with some examples?

Let us assume we have a woodcutter hut and a sawmill approximately 30 meters away and another sawmill approximately 60 meters away.

The first trunk the woodcutter produces will be brought to the nearby sawmill, as it is closer and shorter distance matters. Since the sawmill is fast enough to handle the input of 1 woodcutter easily, the input pile will stay empty or almost empty, and the transports only deliver to the nearby sawmill, which is fine.

Now if we assume that we place another woodcutter next to the one we already have, it will soon happen that the first sawmill has a few tree trunks in the input pile as they start to pile up, and the urgency of the request for more trunks will drop. At this point, the Settlers start to deliver tree trunks to the distant sawmill too. Usually, the input pile of the 2nd sawmill will be half as full as the first one, as it has double the distance.

Now if we place another two woodcutters closer to the 2nd sawmill, those trunks will be delivered to the 2nd sawmill instead, basically until the sawmill input piles are balanced. Because distances and urgencies balance out, the transports will now usually always go to the sawmill nearby.

If we assume that the four woodcutters produce more trunks than the two sawmills can handle, sooner or later the input piles of the sawmills run full and the output piles of the woodcutters will fill as well. At that point, they would stop working for a moment until they have room again. We may want to place another sawmill or upgrade them. But instead we do something different, we place a storage for tree trunks!

Now, but only if we have enough transport capacity (because storing goods is priority level 5 only), the carriers will pick up the trunks and bring them to the storage. This ensures that the woodcutters keep working, as their output piles are not full anymore since we increased the size of our buffer. Only after the storage is full too, the woodcutters would take a break again.

…but before the storage is full, we order five new residential buildings, which need tree trunks to be built. Depending on the distance those materials will be hauled from the storage or the woodcutters to the new building sites.

If we have a shortage of carriers, those new orders would be handled first as new building sites have priority over standard economy transports like “woodcutter => sawmill,” which means the sawmills now work with the trunks they have already stored. In the worst case, the sawmills would stop working temporarily until the carriers finished the building material deliveries.

However, if the player needs boards created by the sawmills urgently, they could grant “high priority” to one or both sawmills, lifting their economy requests above anything the Resource Broker decides on its own.

Now the sawmills will get all tree trunks available until their input is full, only the surplus available would be delivered to the building sites… in the worst case, the ordered buildings will not be finished for a long time if we insist on priority for the sawmills (which we could disable anytime).

Let us assume we now have an urgent need for a new city wall to protect us from enemies, as we just scouted the enemy and consider an imminent attack. We quickly place two towers and a connecting wall between.

As fortifications do not get priority over buildings, the Settlers would deliver the tree trunks to the residential buildings first. Since we are worried about an attack, instead we set the towers and walls to high priority, and now all tree trunks will be delivered to those first, which ensures that the towers and walls are built as fast as possible.

We hope that this detailed insight provided you with interesting information and that you can use this to your benefit when playing the game later!

de en es fr it pl ru

2 Comments

  1. Pandanen

    Looking great so far! Cant wait! 🙂

  2. BlueBlop

    Unrelated, seems like the walls snap to terrain like in the older titles just hope it is better optimized.
    Otherwise glad to see the game is steadily progressing to launch.

Leave a Reply

Please change your username here