I've been thinking about a mechanism for allowing supply and demand to realistically shape local prices, while allowing plenty of flexibility to balance these features however is desired using just XML. Here are the ideas I've come up with, let me know what you think!
Where iBuyPrice is the current buying price in that city, and the already existing XML tags below come from CIV4YieldInfos.xml, allowing you to flexibly mod the characteristics and
price elasticity of each good:
iBuyPriceLow : minimum buying price of that yield
iBuyPriceHigh : maximum buying price of that yield
iPriceChangeThreshold : price sensitivity of that yield (how many units you'd need to sell to drive the price down to iBuyPriceLow, or how many units you'd need to buy to drive the price up to iBuyPriceHigh)
iSellPriceDifference : difference between buying and selling prices (may work best to convert this to a percentage rather than a fixed integer?)
Whenever a yield is bought from a city during trade, call the following function, thus raising the local price by a degree proportional to the amount bought, never exceeding iBuyPriceHigh.
iBuyPrice = min(iBuyPriceHigh, (iBuyPrice+(iBuyPriceHigh - iBuyPrice)*(iUnitsBought/iPriceChangeThreshold)))
Whenever a yield is sold to a city during trade, call the following function, thus lowering the local price by a degree proportional to the amount sold, never falling below the floor of iBuyPriceLow.
iBuyPrice = max(iBuyPriceLow, (iBuyPrice-(iBuyPrice - iBuyPriceLow)*(iUnitsSold/iPriceChangeThreshold)))
At the end of the turn, calculate the fraction of local Demand that got fulfilled, and use this to adjust local prices slightly up or down similar to the above functions.
The basic effects should be that local prices drift down slightly if you're earning lots of gold from selling a certain yield to a city via trade or Trading Post/Market; and drift up slightly as the city generates demand for that yield (especially if that demand goes unfulfilled by selling). If you're generating tons of money by fulfilling all the Demand for a good locally with your supply, local prices will drift downward, gradually stimulating you to seek out other export markets where that good is in shorter supply.
The price sensitivity and min/max price for each good can be easily balanced as desired using just XML. Overall it would be a cool way to generate realistic and subtle shifts in local markets in response to supply/demand, so you can benefit by satisfying your citizens' demand through good strategy (and by successfully trading from areas with oversupply to areas with undersupply), without having to micromanage to an artificially precise limit like "demands exactly 3 Cigars per turn". If you like, Trade Screens prices could work by generating a certain amount of Demands like other cities do to enable price adjustment (I agree it is somewhat too easy currently to simply dump everything on a single Trade Screen without thinking about things.)
The main issue I'd see with this (or any other system for price change) is that in vanilla, the smallest possible price change of 1 gold ends up being extremely large in percentage terms for many yields with low price per unit (less than 5 or so, where the smallest possible movement is 20%). And if a given transaction isn't big enough to move the price by at least 1 unit, its effects won't be stored. Maybe this could be easily solved too if prices could be a float instead of an int.