Page: [root]/code/rustorion/strategic/trading | src | faq | css

Trading

Planet populations can trade goods with each other (currently it's only food) using Void Church for transport.

example of trading in rustorion

Suppliers have a "minimum price" for which they are willing to sell the goods. Demanders have a "maximum price" which they are willing to pay. These are based on costs of producing the same goods locally. On top of that, demanders pay for shipping, so they will prefer shorter/cheaper routes. The system can be additionally modified with other factors like cultural preference, tariffs and local conditions.

Algorithm

Trading algorithm matches supply and demand and makes sure all deals are most profitable to both. Deals are made at the average of maximum (minus shipping) price of demander and minimum price of the supplier, simulating negotiation.

1. All planets calculate their supply, demand, minimum and maximum price.
2. Assemble "supplies" and "demands" tables, that list potential deal partners for each planet, sorted by price:

Planet Price Partner planet
Capital 0.05 Breadbasket 1
0.06 Breadbasket 2

3. For every demander:
3.1. Find the best supply partners with stock left (with equal minimum price)
3.2. For every best supply partner:
3.2.1: Find its best demand partners with demand left
3.2.2 If the demander is among these, add supplier to the viable suppliers list
3.3. Divide the demand between viable suppliers, weighted by their total stock
3.4. For each viable supplier:
3.5. Purchase as much from the demand share as possible from them, paying price to them and transport fee to VC.


Powered by bitcheese wiki engine