# Dwarves & D.Sci: Data Fortress Evaluation & Ruleset

This is a follow-up to [](https://www.lesswrong.com/posts/cesr2yGoZ2y327qKQ/d-and-d-sci-divination-nine-black-doves) [last week's D&D.Sci scenario](https://www.lesswrong.com/posts/wmG6kdcacNoB3HWJs/dwarves-and-d-sci-data-fortress): if you intend to play that, and haven't done so yet, you should do so now before spoiling yourself.

There is a web interactive [here](https://aphyer1992.github.io/dndsci_dwarf) you can use to test your answer, and generation code available [here](https://raw.githubusercontent.com/aphyer1992/dndsci-df/main/dnd_dwarves.py) if you're interested, or you can read on for the ruleset and scores.

*Note: the web interactive calculates average survival rates/values using Monte Carlo with small sample sizes.  The figures in the leaderboard are more accurate.*

THE RULESET
===========

The underlying ruleset was a resource-management minigame played behind the scenes for each fort.

Players were not expected to reconstruct the entire ruleset - rather, the minigame existed in order to create interesting multivariate effects in the output dataset.

Each fort plays 12 rounds of this minigame to determine survival and value.  (After this, a fort either dies, shuts down, or grows sufficiently to take in new migrants/raise children/etc, at which point its starting dwarves no longer matter.)

### SITE GENERATION

A site has a biome (chosen at random from the four available) and a Coal Level given by 1d4-1.

There are seven ores (the six mentioned in the dataset, plus Adamantine, which is buried too deep to be prospected for in advance).

Each ore has an independent 40% chance of being present in any site.

Any site where (# of ores found by prospecting + Coal Level) is less than 4, or any Tundra site where it is less than 5, does not get settled.  As such, all forts have at least that much coal/ore in them.

### RESOURCES

The main underlying mechanic is one of resource management - there are a variety of different resources involved, and high-value forts are those that manage to navigate the production chain to create high-value finished goods.

| Resource | Value | Produced By |
| --- | --- | --- |
| Food | 0.1 | Farmer, Brewer |
| Wood | 0.5 | Woodcutter |
| Coal | 1   | Miner |
| Ore - Copper | 1   | Miner |
| Ore - Tin | 1   | Miner |
| Ore - Iron | 3   | Miner |
| Ore - Silver | 3   | Miner |
| Ore - Gold | 5   | Miner |
| Ore - Adamantine | 15  | Miner |
| Finished Goods - Wood | 4   | Crafter |
| Finished Goods - Copper | 5   | Smith |
| Finished Goods - Tin | 5   | Smith |
| Finished Goods - Bronze | 10  | Smith |
| Finished Goods - Iron | 10  | Smith |
| Finished Goods - Silver | 10  | Crafter |
| Finished Goods - Gold | 20  | Crafter |
| Finished Goods - Steel | 20  | Smith |
| Finished Goods - Adamantine | 60  | Smith |

### WARRIORS, WOODCUTTERS AND BIOME

A fort is subject to many threats from the outside, ranging from the occasional goblins and mandrills of the Plains to the dreaded Elephants of the Jungle.

None of these things can destroy a fort on their own.  When threats from outside are too serious to deal with, the dwarves seal the gate, set up some traps with whirling serrated blades and huge menacing spikes, and wait for them to go away.  The use of Warriors is not directly to keep these threats from destroying your fort - rather, it's to allow your fort to keep access to the outside.

While you have access to the outside:

*   Farmers produce much more food (sunlight and wide open spaces make more food than caves).
*   Woodcutters can cut down trees (pretty clear).
*   Food and Fuel can be bought (at admittedly high prices) from wandering merchants.

While you don't have access, your Woodcutters are useless, your Farmers less useful, and you cannot buy emergency Food or Fuel.

Each turn, you determine the Threat Level of your biome:

| Biome | Threat Level | Trees |
| --- | --- | --- |
| Tundra | 75% 0, 25% 2 | 1d4-1 |
| Plains | 1   | 1d6 |
| Light Forest | 1d2 | 1d6+3 |
| Jungle | 1d4 | 99  |

If you have a # of Warriors >= the Threat Level, you have exterior access that turn.  If # Warriors < Threat Level, you are stuck inside that turn.

If you have exterior access, Woodcutters each cut 2 Trees, up to a limit of the # of Trees available in your biome this turn, and you gain 1 Wood per tree cut.  If you don't, Woodcutters are useless.

### MINERS, COAL AND ORE

Each ore type has a different Depth - how far below the surface it tends to be found.

The more Miners you have, the deeper you can dig, and the more ores you can find.

| Ore | Depth (# Miners Needed) | Yield |
| --- | --- | --- |
| Copper | 1   | 1d4 Copper Ore |
| Hematite | 2   | 1d3 Iron Ore |
| Tin | 3   | 1d3 Tin Ore |
| Silver | 3   | 1d3 Silver Ore |
| Magnetite | 4   | 1d6 Iron Ore |
| Gold | 5   | 1d3 Gold Ore |
| Adamantine | 7   | 1 Adamantine Ore |

Each round, you receive the Yield of each ore present in your fort that you can mine deep enough to reach.

If Adamantine is present in a fort, it has a Thickness of d20+1.  Every time Adamantine is mined, that Thickness is reduced by 1.  If it ever reaches 0, you have Delved Too Deep, and...well...let's just say that no fort that does this ever survives.

Each Miner also has a chance of (10% * Fort Coal Level) to produce 1 Coal.

### SMITHS, CRAFTERS AND FUEL

These professions create finished goods.  Finished goods are the highest-value things you can make, but most require multiple inputs, needing both ore and some kind of fuel.

*   Each Smith can do **one** of the following:
    *   Turn 1 Adamantine Ore and 1 Fuel into Adamantine Finished Goods (worth 60).
    *   Turn 1 Iron Ore and 2 Coal into Steel Finished Goods (worth 20).
    *   Turn 1 Iron Ore and 1 Fuel into Iron Finished Goods (worth 10).
    *   Turn 1 Copper Ore, 1 Tin Ore and 1 Fuel into Bronze Finished Goods (worth 10).
    *   Turn 1 Copper Ore and 1 Fuel into Copper Finished Goods (worth 5).
    *   Turn 1 Tin Ore and 1 Fuel into Tin Finished Goods (worth 5).
*   Each Crafter can do **one** of the following:
    *   Turn 1 Gold Ore and 1 Fuel into Gold Finished Goods (worth 20).
    *   Turn 1 Silver Ore and 1 Fuel into Silver Finished Goods (worth 10).
    *   Turn 1 Wood into Wood Finished Goods (worth 4).
*   Fuel:
    *   Wood can be used as fuel.
    *   Coal can be used as fuel (though your dwarves will use wood first, as coal is more valuable both as a resource and potentially for making steel).
    *   If neither of those are available, but you have exterior access (see Warriors), you can buy Fuel at a cost of 3 value of finished goods/Fuel.  (This is not very profitable, but is better than smiths and crafters sitting idle).

### FARMERS, BREWERS AND FOOD

Each round, each dwarf in your fort eats 1 Food.  Your fort begins with 1 round worth of Food (meaning that e.g. your 13-dwarf fort could actually manage with production of 12 Food/round).

Two professions produce Food:

*   Farmers produce 10 Food/round if you have exterior access, but 4 Food if you do not.
*   Brewers produce 4 Food/round regardless of exterior access.  However, **having alcohol to drink also makes your dwarves work harder**: if your fort has at least 1 Brewer, each dwarf has a 10% chance per round to enter a strange mood and work twice as hard (counting as 2 dwarves of their profession).  If you have no brewers, your listless, alcohol-deprived dwarves will not do this.

If you do not have enough Food at the end of a round, but do have exterior access, you can buy Food at 3 value of finished goods/Food.  This is an extremely high price (reflecting the risks and costs of merchants launching speculative expeditions to your fort), but the alternative is for your fort to collapse of starvation.

STRATEGY
========

Once you know how the rules work:

*   Survival strategy is pretty simple:
    *   Have enough Brewers/Farmers (and possibly Warriors to help the Farmers) to feed your fort.
    *   Do not have so many miners you hit adamantine (7 Miners will always reach adamantine every round, but if you have a Brewer lower numbers of Miners can still hit it with alcohol-induced hard work.  With that said, 5 miners are very unlikely to dig enough Adamantine to destroy your Fort, and 4 miners are astronomically unlikely.
*   Profit requires more effort:
    *   Have Miners to hit whatever ores are present.
    *   If available coal isn't enough, have Woodcutters (and Warriors to let them get outside) to cut trees and fuel things.
    *   Have Smiths (for Iron/Bronze/etc) and Crafters (for Gold/Silver) to produce high-value finished goods.

In your fort, ideal strategy was:

*   3 Miners.  Since your fort contained many shallow ores, but not Magnetite or Gold, and not much Coal, more miners had very limited value.  You don't know whether adamantine is present, but shouldn't try to dig for it anyway - it adds risk, and you have a lot of value available from smithing and crafting the ores you're getting just at Depth 3.
*   2 Woodcutters.  Since you are mining lots of ore, you will need lots of fuel - and since your Coal Level is low, you won't be getting it just from mining.
*   2 Warriors.  In a Light Forest, this is what's required to guarantee you external access for wood.
*   1 Farmer and 1 Brewer.  With guaranteed external access, these will feed your fort while also giving you the chance at some bonus actions.
*   3 Smiths and 1 Crafter.  With 3 different smith-based ores but only silver for Crafters, a third Smith produces a bit more value than a second Crafter.

LEADERBOARD
===========

*N.B: performance here was Monte-Carlod rather than calculated.  There is some ambiguity in ordering re. how you prioritize a small reduction in safety vs a substantial increase in profit - depending on how risk-averse/risk-loving you are, you could choose to rank GuySrinivasan lower or Alexander Ledovsky higher.*

| **Player** | **Expedition** | **Survival Rate** | **Average Value** |
| --- | --- | --- | --- |
| **Optimal Play** | **3 Miner, 2 Warrior, 2 Woodcutter, 1 Farmer, 1 Brewer, 3 Smith, 1 Crafter** | **100.0%** | **599.3** |
| simon | 4 Miner, 2 Warrior, 1 Woodcutter, 1 Farmer, 1 Brewer, 3 Smith, 1 Crafter | 100.0%* | 531.2 |
| gammagurke | 4 Miner, 2 Warrior, 1 Woodcutter, 1 Farmer, 1 Brewer, 2 Smith, 2 Crafter | 100.0%* | 520.7 |
| Treeslaughtered (abstractapplic) | 4 Miner, 2 Warrior, 2 Woodcutter, 1 Farmer, 1 Brewer, 1 Smith, 2 Crafter | 100.0%* | 508.4 |
| GuySrinivasan | 5 Miner, 2 Warrior, 1 Woodcutter, 2 Farmer, 1 Brewer, 1 Smith, 1 Crafter | 99.3% | 452.4 |
| Noosphere89 | 5 Miner, 1 Warrior, 4 Farmer, 2 Smith, 1 Crafter | 100.0% | 321.8 |
| Magh Loduhr (Yonge) | 6 Miner, 1 Warrior, 4 Farmer, 1 Smith, 1 Crafter | 100.0% | 302.0 |
| Alexander Ledovsky | 6 Miner, 1 Warrior, 1 Farmer, 2 Brewer, 2 Smith, 1 Crafter | 90.8% | 386.9 |
| **King Urist McAnvil** | **13 random dwarves grabbed from the town square** | **90.3%** | **209.7** |
| **Entirely Random Play** | **A random distribution of 13 dwarves** | **73.9%** | **120.6** |

*These allocations in theory have a non-zero risk of Delving Too Deep with a string of very lucky/unlucky alcohol-fueled Mining, but in practice the odds are negligible (I believe on the order of 10^-8).

Players all did a good job of identifying how to survive, with no fort risking starvation, and no fort having 7 Miners.  There was more variation in how well players produced value, with the top players coming very close but not quite hitting the optimal allocation.  The most notable thing that got missed was the depth of available metal ores and how it made bringing fewer Miners reasonable - every submission brought at least 4 Miners, and many went up higher.

Congratulations to all players, particularly to **simon (1st)** and **gammagurke (2nd)**, who came very close to optimal but most notably brought only 1 Woodcutter each (meaning that quite a bit of money went to buying wood to keep their Smiths and Crafters running), and to **abstractapplic (3rd)**, who brought 2 Woodcutters but went low on Smiths and high on Crafters.  

(**abstractapplic** gained 10 Dwarf Points for their fort's suitably Dwarfy name, but lost 10 Dwarf Points for looking at a fort with four different types of shallow metal deposit and declaring that they were going to make money by crafting things out of wood like some kind of pansy Elf.  Our Dwarf Point Leader is therefore **Yonge**.)

I also see we've got some new players - congratulations to you as well!  I hope you enjoyed the scenario - if you did, the [D&D.Sci tag](https://www.lesswrong.com/tag/d-and-d-sci) contains a list of past scenarios, and you can subscribe to that tag to get notifications when new ones are posted (abstractapplic and I try to make sure this happens around once a month).

FEEDBACK REQUEST
================

As usual, I'm interested to hear feedback on what people thought of this scenario.  If you played it, what did you like and what did you not like?  If you might have played it but decided not to, what drove you away?  What would you like to see more of/less of in future?  Do you think the scenario was too complicated to decipher?  Or too simple to feel realistic?  Or both at once?  Do you have any other feedback?

Thanks for playing, and I hope you had fun!