Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

Farming and the Mercantile

Cleared flat ground can become a field. A field grows one crop at a time. Harvested produce is sold to the Harrison Mercantile, a buyer run by the town, for lumber.

Crops. Grow is hours to the first harvest. Regrow is hours between harvests for the orchard. Depletes is the change to soil fertility after a harvest; a negative number adds fertility. Base is the Mercantile base price in bd ft per unit.
CropUnitSeed (bd ft)Grow (hr)Regrow (hr)YieldBase priceDepletes
Hayton303–440-0.15
Oatssack404–6300.08
Potatoessack606–10280.12
Wheatsack508–8450.12
Apple orchardcrate30024810400

Breaking ground costs PLOW_COST = 150 bd ft and one crew-day.

A parcel can be broken for a field when it is cleared (no standing timber), has no building and no field, is not steep, and is not the landing. Meadow parcels qualify. The new field starts with no crop and fertility 1.

A field can be returned to stump land at any time when no crop is in it. This is free and removes the field and its fertility. It does not restore timber.

plant(crop): requires a field with no crop and lumber >= seed
lumber -= seed; planted = now; bearing = false
ready when now - planted >= (regrow if bearing else grow) * 3600000
harvest: requires ready and one crew-day
units = max( 1, round( yield * fertility ) )
produce[crop] += units
fertility = clamp( fertility - depletes, 0.4, 1.0 )
if crop is apples: planted = now; bearing = true
otherwise: crop = none (field stays, fertility is kept)

The first apple harvest comes after 24 hours. After that the orchard stays in the field and bears every 8 hours. Fertility is applied before the harvest reduces it, so the first harvest of any crop on a new field has full yield. Hay gives a negative depletes, which raises fertility, to a maximum of 1.

Produce is a counter per crop, S.produce. It has no capacity and does not spoil.

The Mercantile holds a stock of each crop. Stock rises with other farmers’ deliveries and falls with what settlers eat. It pays by how full the shelf is.

Mercantile shelves. Cap is shelf capacity in units. Eat is consumption per settler per hour.
CropShelf capEat per settler per hr
Hay600.12
Oats900.18
Potatoes1400.3
Wheat1100.22
Apple orchard800.14

Starting stock is half of each cap. Stock is stored with its last update time and advanced in steps of at most 30 minutes:

eat = settlers(t) * MERC[crop].eat units per hour
others = eat * ( 0.55 + 0.35 * sin( t / 3600000 / (5 + len(crop)) + len(crop) ) )
stock = clamp( stock + (others - eat) * h, 0, cap )

len(crop) is the number of characters in the crop key (hay 3, oats 4, wheat 5, apples 6, potatoes 8). The factor on eat ranges from 0.20 to 0.90 and averages 0.55. Other farmers therefore always deliver less than the town eats, and with no player sales every shelf trends toward empty.

f = (stock + extra) / cap
price = max( 1, round( base * clamp( 1.45 - f, 0.45, 1.45 ) ) )

An empty shelf pays 1.45 times the base price. A shelf at 100 percent or more of its cap pays 0.45 times it. Between them the multiplier falls in a straight line.

Selling sells the whole stock of one crop.

n = produce[crop]
price = price( extra = n / 2 ) (priced as if half the load is already on the shelf)
freight = 0.025 if the player owns a teamster stable, else 0.05
net = round( n * price * (1 - freight) )
stock[crop] = min( 1.2 * cap, stock + n )
produce[crop] = 0
lumber += net; farmed += net

Farm income does not count toward produced, so it does not help the deed goal or the Timber baron board. It does not count toward the Merchant board either, because that board reads only town business earnings. A stock above the cap is cut back to the cap the next time the shelf is updated.

Inputs are the crop choice, the crew, fertility, the clock, the settler count and teamster ownership. Outputs are lumber and counters. State: per parcel field = { crop, planted, fert, bearing }; the player counters produce, farmed; and the shelf merc = { at, stock }.

The Mercantile is the clearest case of a market that the prototype simulates and a server must replace. One shelf per crop, shared by every player, is the natural model: the price then reflects what all farmers sold. The simulated “other farmers” term should be dropped or tuned down once real farmers exist, since it is a constant drain. A server must own planting time, fertility and harvest, because the grow timers are the only thing that keeps farming from being instant, and must store the shelf with a timestamp so it can be advanced with the same step size for everyone. Selling a whole crop in one transaction at a half-load price is easy to reproduce, but the server will need to decide how a price is quoted to two players selling at the same moment.

Source: prototype/index.html · constants CROPS, MERC, PLOW_COST in rules.json · logic farmable, breakGround, plantCrop, cropState, harvest, backToTimber, updateMerc, mercPrice, sellProduce