# Living markets (design 15.2, step 34a). Read at startup by the game and the server
# (src/sim/station/Markets.cpp). Every place that trades is a market: the station, and each research
# outpost, trading post, farmstead, research dig and mining camp. A market keeps a stock of each
# commodity, which the server moves with trades and lets drift back over time. Base prices are
# prices.txt's; anything that isn't a commodity keeps its static price and endless stock.
#
# [economy Rules]
#   k            the price curve: price = base x (target / max(stock, 1))^k
#   low, high    the clamps, as shares of the base price
#   drift        s of world time for a disturbed stock to come two thirds of the way back to rest
#   tick         s between the server's passes over its markets (records settle, screens update)
#   makes        where a good a market makes comes to rest, as a share of its target (cheap there)
#   needs        the same for a good it needs (dear there)
#   trend        a price this far from its price at rest (a share) shows a trend arrow
#
# [commodity GROUP]  design 15.3's groups. target: the stock a market of size 1 wants of each;
#                    items: price keys (items or resources) of prices.txt; ITEM = N overrides one
#                    item's target.
#
# [trader KIND]      a kind of market: `station`, or a structure kind's key (research_outpost,
#                    trading_post, farmstead, research_dig, mining_camp), `depot` (depots.txt), or
#                    `belt_station` (another station of a busy system, off a belt's edge).
#   size         scales every target (a station's stores are the biggest)
#   makes, needs commodity keys; `world_ores` for one of each ore its own world has
#   owner        `holder` (whoever holds the system, gates.txt), `self` (the place's own name), or a name
#
# [world NAME]       what a world adds to the markets on it, by its class (planet classes, as keys).
#   classes, makes, needs

[economy Rules]
k = 0.6
low = 0.3
high = 3.5
drift = 2400
tick = 60
makes = 2.5
needs = 0.4
trend = 0.04

[commodity Raw]
target = 400
items = stone, sand, wood, plant, ice, sulfur, crystal, iron_ore, copper_ore, ilmenite, rare_earths, cobalt
crystal = 120
rare_earths = 60
cobalt = 40

[commodity Refined]
target = 160
items = iron_plate, copper_plate, titanium_plate, glass_pane, woven_fiber, fuel_canister

[commodity Components]
target = 80
items = copper_wire, iron_gear, circuit_board, advanced_circuit, processor, power_cell, energy_cell
advanced_circuit = 30
processor = 16
energy_cell = 200

[commodity Food]
target = 160
items = meat, crop, forage, egg, cooked_meat, nutrient_paste, emergency_ration, meal, drink
egg = 40

[commodity Specimens]
target = 40
items = horn, hide

[commodity Data]
target = 8
items = black_box

[trader station]
size = 1
makes = fuel_canister, iron_plate, copper_plate, copper_wire, iron_gear, glass_pane, circuit_board, energy_cell, emergency_ration, drink
needs = iron_ore, copper_ore, ilmenite, crystal, rare_earths, meat, crop, egg, horn, hide
owner = holder

# A station off the edge of a belt (stations.txt `more stations`): it smelts the belt's ore and
# feeds the miners who bring it.
[trader belt_station]
size = 0.8
makes = iron_plate, copper_plate, copper_wire, iron_gear, fuel_canister, emergency_ration
needs = iron_ore, copper_ore, ilmenite, rare_earths, meat, crop, meal, drink, power_cell
owner = holder

# A fuel depot by an ice ring (depots.txt): it melts the ring's ice into fuel.
[trader depot]
size = 0.5
makes = fuel_canister
needs = ice, power_cell
owner = holder

[trader research_outpost]
size = 0.25
makes = energy_cell, nutrient_paste
needs = horn, hide, egg, crystal, rare_earths, emergency_ration, power_cell
owner = holder

[trader trading_post]
size = 0.5
makes = emergency_ration, drink
needs = fuel_canister, iron_plate, copper_wire, glass_pane, power_cell, energy_cell
owner = self

[trader farmstead]
size = 0.3
makes = crop, meat, egg, forage, cooked_meat, meal
needs = fuel_canister, iron_plate, copper_wire, iron_gear, glass_pane, power_cell, energy_cell
owner = self

[trader research_dig]
size = 0.25
makes = energy_cell
needs = horn, hide, egg, crystal, rare_earths, emergency_ration, fuel_canister
owner = holder

[trader mining_camp]
size = 0.4
makes = world_ores, stone
needs = meat, crop, cooked_meat, meal, nutrient_paste, emergency_ration, drink, fuel_canister
owner = self

[world Volcanic]
classes = volcanic, volcanic_barren, inferno
makes = sulfur
needs = ice

[world Cold]
classes = frozen, frozen_barren, tundra, cryogenic
makes = ice
needs = meat, crop, emergency_ration, nutrient_paste

[world Dry]
classes = desert, scorched, scorched_barren, steaming
makes = sand
needs = ice

[world Living]
classes = lush, temperate, tropical, ocean
makes = crop, meat, wood, plant
needs = circuit_board, power_cell

[world Barren]
classes = barren, toxic
needs = ice, crop, meat, emergency_ration

# ---------------------------------------------------------------------------------------------
# Lanes (design 15.2, step 34b): each lane of the system's routes (traffic.txt) carries the goods
# its two ends trade, and has a safety from 0 to 1. Pirates working a lane wear it down, patrols on
# it build it up, and ships lost on it move it at once. Goods flow faster on a safe lane: the
# markets at its ends drift back sooner.
#
# [safety Rules]
#   relax        s for a lane's safety to come 63% of the way to where its traffic puts it
#   pirate       less safety per pirate working the lane (lurking along it, or at its belt)
#   patrol       more per patrol on it (at either end, or going along it)
#   hauler lost  safety lost at once when a hauler is lost on it
#   pirate lost  safety gained at once when a pirate is lost on it (a patrol or a player shot it)
#   flow low     how fast goods flow on a lane with no safety, as a share of a safe one's
#   lure         pirates pick a lurk spot by its lane's value to this power (0: any alike)
#   HOLDER = N   a lane's safety with nobody on it, by the system's holder (gates.txt's keys)
#
# [goods PLACE]      what a kind of place ships out and takes in: belt, gate. The station's are its
#                    [trader station]'s; a world's are its [world]'s and its ores.
#
# [hold Rules]       a hauler's hold, filled from its lane's goods when it first comes near a player:
#   stacks       how many stacks, fewest and most
#   amount       how many of each, fewest and most (no more than a stack holds)

[safety Rules]
relax = 1800
pirate = 0.12
patrol = 0.06
hauler lost = 0.2
pirate lost = 0.15
flow low = 0.25
lure = 1
charter = 0.9
authority = 0.85
company = 0.75
frontier = 0.55
contested = 0.4

[goods belt]
makes = iron_ore, copper_ore, ilmenite, crystal, cobalt, rare_earths, ice
needs = fuel_canister, emergency_ration, power_cell, energy_cell

[goods gate]
makes = processor, advanced_circuit, titanium_plate, power_cell
needs = black_box, rare_earths, crystal, cobalt, horn

[hold Rules]
stacks = 2, 4
amount = 12, 48
