the-great-game.merchants.planning
Trade planning for merchants, primarily.
augment-plan
(augment-plan merchant world plan)
Augment this plan
constructed in this world
for this merchant
with the :quantity
of goods which should be bought and the :expected-profit
of the trade.
Returns the augmented plan.
generate-trade-plans
(generate-trade-plans merchant world commodity)
Generate all possible trade plans for this merchant
and this commodity
in this world
.
Returned plans are maps with keys:
- :merchant - the id of the
merchant
for whom the plan was created; - :origin - the city from which the trade starts;
- :destination - the city to which the trade is planned;
- :commodity - the
commodity
to be carried; - :buy-price - the price at which that
commodity
can be bought; - :expected-price - the price at which the
merchant
anticipates thatcommodity
can be sold; - :distance - the number of stages in the planned journey
- :dist-to-home - the distance from
destination
to themerchant
’s home city.
nearest-with-targets
(nearest-with-targets plans targets)
Return the distance to the nearest destination among those of these plans
which match these targets
. Plans are expected to be plans as returned by generate-trade-plans
, q.v.; targets
are expected to be as accepted by make-target-filter
, q.v.
plan-trade
(plan-trade merchant world commodity)
Find the best destination in this world
for this commodity
given this merchant
and this origin
. If two cities are anticipated to offer the same price, the nearer should be preferred; if two are equally distant, the ones nearer to the merchant’s home should be preferred. merchant
may be passed as a map or a keyword; commodity
should be passed as a keyword.
The returned plan is a map with keys:
- :merchant - the id of the
merchant
for whom the plan was created; - :origin - the city from which the trade starts;
- :destination - the city to which the trade is planned;
- :commodity - the
commodity
to be carried; - :buy-price - the price at which that
commodity
can be bought; - :expected-price - the price at which the
merchant
anticipates thatcommodity
can be sold; - :distance - the number of stages in the planned journey
- :dist-to-home - the distance from
destination
to themerchant
’s home city.
select-cargo
(select-cargo merchant world)
A merchant
, in a given location in a world
, will choose to buy a cargo within the limit they are capable of carrying, which they can anticipate selling for a profit at a destination.