Preliminaries:
-This is my first post on the forums, but i've been playing for ~1 year and am reasonably active on the Wiki. I've also been lurking the forums for a bit (hi).
-While some aspects of this seem to have been discussed before (local supply/demand), I could find no real proposals for global market modeling based on supply and demand (and lots of random stuff also popped up in my search, which made finding relevant links hard). I acknowledge previous discussions when I get to local markets. (If you know of a previous discussion on global modelling, a link would be handy).
---------------
Motivation:
-The Caravan arc, while proposing to allow caravans to physically move around the world, doesn't propose altering the way the economy is handled.
-The long-term Merchant Arc proposes that the real economy is somehow set by these caravans. There are no details as to how. By this statement I greatly doubt ToadyOne means to actually alter how prices are calculated, and instead means that goods must be produced in one location and moved to another by a caravan, all of which are to be actually simulated by the game.
-The pricing scheme in DF is horribly naive and behaves in a counter-intuitive way. In effect, the game assumes an absolute theory of value, with predictable headbreaking consequences. I have made my thoughts on the current economy well-known on the
DF Wiki-Despite the rather recent date for a good formulation of the Supply and Demand theory (certainly no earlier than the 18th century), it has always been the way the real world economy has actually functioned, regardless what governments have pretended.
-The current economic model receives a lot of abuse ('action X is an exploit') because people don't understand how an absolute model value works *because they've never seen one in practice*. On the other hand, its impossible to pretend its a Supply and Demand economy because there are then 'exploits' which are foisted upon you (room pricing invariant in the face of demand, for example) with no work around.
-Current prices are unreasonable for the known availability of particular commodities. For example, the price of Iron is ridiculously high relative to some other alloys (for example, Nickel) given the frequency and size of Magnetite deposits (in appropriate strata).
-------------
Proposal:
Implement a new model of pricing which takes into account supply and demand at local and global levels.
-------------
Thoughts:
Determining Local or Global.
Some good types are only traded locally (eg, Rooms) while others are generally traded globally via the caravans (eg, metals) but could be traded locally. In general, anything traded through the Depot is being globally traded, and anything else is traded locally.
Local goods which cannot be traded globally have no global market (eg, Rooms). (Ok, actually, supply of rooms being high relative to local demand as compared to other settlements should apply upward pressure on immigration... but that's another post in its own right).
Determining Supply
-Local supply is obviously the number present in the fortress, a quantity already indexed by the game.
##Note: Game will need to stop recording lumber, metal, and stone used as elements of constructions and buildings in the same location in the stock menu as similar items which are still available for use##
-Global supply is going to receive input from every settlement in the world. For the moment i'm going to discuss a naive version which assumes the Caravan Arc isn't finished. This can be adapted to a distance-sensitive metric by applying an exponentially decaying weight based on distance to the supply contributed by each settlement, and calculating global supply for each location separately. I'm also going to assume the Bustling Towns Arc isn't finished (obviously if towns are actively producing goods then we can just count them).
-Each town sits on a particular plot of land with particular local resources. In addition, each race has variable affinities for particular activities, such as mining, and each town has some known population. We define a production function for each good which takes as arguments Population, Race, and Local Resource Abundance and generates a number of units produced per year.
-It may be desirable in some cases to also account for ease of accessing a resource. For instance, Iron ores are generally deposited near the surface, whereas Nickel is deep underground - making it plausible that Iron is easier to mine and therefore has higher effective supply. This could be done on a tile by tile basis if necessary, but probably best done by making some generalizations for each resource if handled at all.
-Good with multiple sources should account for all those sources. (ie, trade in iron ores would treat limonite, hematite, and magnetite as distinct, but trade in Iron Bars would account for the smelting products of all three).
-The players fortress does not use this metric, but rather the actual number traded at the Depot. (You can't use total produced because that number is economically invisible to the rest of the world - you could if dwarves owned workshops and had to buy raw materials, but since the production economy seems to be jointly owned, materials processed internally into other goods are invisible to the market).
-Actually determining Global Supply has to wait until we have demand, but we have Supply/Settlement now.
Demand
Another place where the Bustling Town Arc would make a big difference, we'll assume the current state of the game for the purposes of the present discussion. Thus we need to abstract demand quite a bit.
-Define a demand function that depends on Population and Race for each good.
-The player's fortress sends as Demand a number = # purchased from the caravan + some quantity based on negotiations with the liaison + epsilon if the player bought all of the goods of that type the caravan had available for sale.
Global Supply and Demand.
-Subtract the Settlement's demand for a good from its supply of that good. A negative number is net demand, a positive number is net supply.
-For each good, send its total either to the net Supply or net Demand set (and 0 to the other set), and sum within sets across all settlements.
-The player's fortress sends Supply and Demand of each as appropriate, and does not account for overlap between goods supplied and demanded.
Determining Price
EASY WAY
Seed initial prices
If Global Supply > Global Demand, decrease price from last year. If Demand > Supply, increase price from last year. Amount of increase or decrease should be a function of good type (representing price elasticity) and degree GS > GD or vice versa.
MORE AWESOME ALTERNATIVE
-In the ideal case we'd know what each settlement could turn any production good into and therefore be able to set price maximums a settlement would be willing to pay. However, at present we have to abstract that. Finished goods are also going to be set by end-consumer needs. Thus we need...
(1) a function which determines the expected value of production goods. Ie, what are all the finished products it could be turned into and how much are they worth. Since we're modeling this, we'll assume that local markets everywhere are the same as global markets (the player will make his own decisions, so his fortress is irrelevant for this). It should basically take a weighted average of the current price of all possible derivative goods and weighted by the Race's propensity to produce that good. (ie, since production spread is invariant in this model, they know the distribution of good types they're actually going to make). We should also subtract the wage paid for production of the derivative good from each term. This gives the average value of the production good, and thus the maximum they would pay for it.
Now we have a Max Value for each settlement for production goods.
(2) Consumer goods max value are going to be set by individual buying behavior, which we can actually model. Figure out how much the settlement exported the previous year and assume that number is the total available wealth. Figure wealth is hugely asymmetric, and take some percentage to determine what the buying power of the wealthiest entity is (recommend ~50%). Using the Race's demand function, figure out the percentage of wealth spent per item type, and double that (not every individual needs every item every year), multiply by buying power. That's the max price said individual would pay for the item in question. Figure out how many they would want (based on Demand function), that's max quantity.
We can specify out N buyers where N is local population and model each one's buying power, but probably a 1st, 2nd, 3rd, and general (remainder) is more than sufficient.
(3) If Demand > Supply, create an ordered list of prices and start 'filling' orders. The last one filled sets the price of every unit. (Orders aren't actually 'filled', but its a useful way to think about it).
(4) If Supply > Demand, set price at some fraction of lowest max price, possibly good dependent, and certainly excess quantity dependent. (In a properly specified model, this should never happen. The reason economics exists is because resources are scarce - when that isn't true things are weird.)
Do note the More Awesome Alternative is even more awesome if/when the Bustling Towns Arc is completed, because then you really do know the uses the material will be put or the buying power of individual dwarves, and can create real demand lists. (You can also check personal supply of goods and have them queue demand for an item when they need it, like a new shirt when their old one gets ratty).
-----------
Local Markets
I did find threads about local supply/demand elsewhere, such as
here and
here and is sort of touched on
here. I'm sure there's more. Thus, I'm mostly going to sketch this for completeness, and because its a logical extrapolation of a global supply/demand market. It should be noted that I consider this an extension of the global market change because it needs the global market to govern it. (Local individual dwarves are price takers not price setters and thus somewhat subject to the whims of the global market).
Unlike global market modelling, local sellers are more likely to price wrong and adjust to perceived demand. The following should be true:
1) The global market should be considered as a possible customer for globally traded goods at the last known global market price. All prices should start at the global market price and adjust from there, and should never drop below the global price. Changes in the global price should have an impact on local price if local =/= global.
2) Prices of underselling item types should decrease over time. So if you have many empty rooms of a particular quality level, the cost of rooms at that level should decrease.
3) Jobs are a good. Unfulfilled jobs in the queue should cause the price (wage) for performing the job to increase, and dwarves should preferentially perform high-paying jobs they are authorized to perform. (Each job should have a minimum wage as well below which no dwarf would do the job).
4) The fortress government should be able to prioritize particular jobs or subsidize particular items. Prioritized jobs receive a bounty from the government in addition to the normal price of the job. Subsidized items have some fraction of the cost paid from the treasury. Players should have some control over this.
5) Obviously rival stores should be able to compete in price
6) Obviously every individual dwarf needs some money management code (set aside money for lodging/food and then must make decisions about how to dispose of the remainder).
------------
So, that's the basics and some thoughts on implementation. Enjoy.
Outstanding Issues:
Determining specific algorithms
Handling good substitution