26 lines
17 KiB
HTML
26 lines
17 KiB
HTML
<!DOCTYPE html PUBLIC ""
|
||
"">
|
||
<html><head><meta charset="UTF-8" /><title>the-great-game.merchants.merchants documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">The-great-game</span> <span class="project-version">0.1.0-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="intro.html"><div class="inner"><span>Introduction to the-great-game</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>the-great-game</span></div></div></li><li class="depth-2 branch"><a href="the-great-game.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gossip</span></div></div></li><li class="depth-3"><a href="the-great-game.gossip.gossip.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gossip</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>merchants</span></div></div></li><li class="depth-3 branch"><a href="the-great-game.merchants.markets.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>markets</span></div></a></li><li class="depth-3 current"><a href="the-great-game.merchants.merchants.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>merchants</span></div></a></li><li class="depth-2 branch"><a href="the-great-game.utils.html"><div class="inner"><span class="tree" style="top: -83px;"><span class="top" style="height: 92px;"></span><span class="bottom"></span></span><span>utils</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>world</span></div></div></li><li class="depth-3 branch"><a href="the-great-game.world.routes.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>routes</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.world.run.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>run</span></div></a></li><li class="depth-3"><a href="the-great-game.world.world.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>world</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-add-known-prices"><div class="inner"><span>add-known-prices</span></div></a></li><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-add-stock"><div class="inner"><span>add-stock</span></div></a></li><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-augment-plan"><div class="inner"><span>augment-plan</span></div></a></li><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-burden"><div class="inner"><span>burden</span></div></a></li><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-can-afford"><div class="inner"><span>can-afford</span></div></a></li><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-can-carry"><div class="inner"><span>can-carry</span></div></a></li><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-expected-price"><div class="inner"><span>expected-price</span></div></a></li><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-generate-trade-plans"><div class="inner"><span>generate-trade-plans</span></div></a></li><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-make-target-filter"><div class="inner"><span>make-target-filter</span></div></a></li><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-move-merchant"><div class="inner"><span>move-merchant</span></div></a></li><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-nearest-with-targets"><div class="inner"><span>nearest-with-targets</span></div></a></li><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-plan-and-buy"><div class="inner"><span>plan-and-buy</span></div></a></li><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-plan-trade"><div class="inner"><span>plan-trade</span></div></a></li><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-re-plan"><div class="inner"><span>re-plan</span></div></a></li><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-run"><div class="inner"><span>run</span></div></a></li><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-select-cargo"><div class="inner"><span>select-cargo</span></div></a></li><li class="depth-1"><a href="the-great-game.merchants.merchants.html#var-sell-and-buy"><div class="inner"><span>sell-and-buy</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">the-great-game.merchants.merchants</h1><div class="doc"><div class="markdown"><p>Trade planning for merchants, primarily.</p></div></div><div class="public anchor" id="var-add-known-prices"><h3>add-known-prices</h3><div class="usage"><code>(add-known-prices merchant world)</code></div><div class="doc"><div class="markdown"><p>Add the current prices at this <code>merchant</code>’s location in the <code>world</code> to a new cacke of known prices, and return it.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L255">view source</a></div></div><div class="public anchor" id="var-add-stock"><h3>add-stock</h3><div class="usage"><code>(add-stock a b)</code></div><div class="doc"><div class="markdown"><p>Where <code>a</code> and <code>b</code> are both maps all of whose values are numbers, return a map whose keys are a union of the keys of <code>a</code> and <code>b</code> and whose values are the sums of their respective values.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L243">view source</a></div></div><div class="public anchor" id="var-augment-plan"><h3>augment-plan</h3><div class="usage"><code>(augment-plan merchant world plan)</code></div><div class="doc"><div class="markdown"><p>Augment this <code>plan</code> constructed in this <code>world</code> for this <code>merchant</code> with the <code>:quantity</code> of goods which should be bought and the <code>:expected-profit</code> of the trade.</p>
|
||
<p>Returns the augmented plan.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L188">view source</a></div></div><div class="public anchor" id="var-burden"><h3>burden</h3><div class="usage"><code>(burden merchant world)</code></div><div class="doc"><div class="markdown"><p>The total weight of the current cargo carried by this <code>merchant</code> in this <code>world</code>.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L23">view source</a></div></div><div class="public anchor" id="var-can-afford"><h3>can-afford</h3><div class="usage"><code>(can-afford merchant world commodity)</code></div><div class="doc"><div class="markdown"><p>Return the number of units of this <code>commodity</code> which this <code>merchant</code> can afford to buy in this <code>world</code>.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L174">view source</a></div></div><div class="public anchor" id="var-can-carry"><h3>can-carry</h3><div class="usage"><code>(can-carry merchant world commodity)</code></div><div class="doc"><div class="markdown"><p>Return the number of units of this <code>commodity</code> which this <code>merchant</code> can carry in this <code>world</code>, given their current burden.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L161">view source</a></div></div><div class="public anchor" id="var-expected-price"><h3>expected-price</h3><div class="usage"><code>(expected-price merchant commodity city)</code></div><div class="doc"><div class="markdown"><p>Find the price anticipated, given this <code>world</code>, by this <code>merchant</code> for this <code>commodity</code> in this <code>city</code>. If no information, assume 1. <code>merchant</code> should be passed as a map, <code>commodity</code> and <code>city</code> should be passed as keywords.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L9">view source</a></div></div><div class="public anchor" id="var-generate-trade-plans"><h3>generate-trade-plans</h3><div class="usage"><code>(generate-trade-plans merchant world commodity)</code></div><div class="doc"><div class="markdown"><p>Generate all possible trade plans for this <code>merchant</code> and this <code>commodity</code> in this <code>world</code>.</p>
|
||
<p>Returned plans are maps with keys:</p>
|
||
<ul>
|
||
<li>:merchant - the id of the <code>merchant</code> for whom the plan was created;</li>
|
||
<li>:origin - the city from which the trade starts;</li>
|
||
<li>:destination - the city to which the trade is planned;</li>
|
||
<li>:commodity - the <code>commodity</code> to be carried;</li>
|
||
<li>:buy-price - the price at which that <code>commodity</code> can be bought;</li>
|
||
<li>:expected-price - the price at which the <code>merchant</code> anticipates that <code>commodity</code> can be sold;</li>
|
||
<li>:distance - the number of stages in the planned journey</li>
|
||
<li>:dist-to-home - the distance from <code>destination</code> to the <code>merchant</code>’s home city.</li>
|
||
</ul></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L61">view source</a></div></div><div class="public anchor" id="var-make-target-filter"><h3>make-target-filter</h3><div class="usage"><code>(make-target-filter targets)</code></div><div class="doc"><div class="markdown"><p>Construct a filter which, when applied to a list of maps, will pass those which match these <code>targets</code>, where each target is a tuple [key value].</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L41">view source</a></div></div><div class="public anchor" id="var-move-merchant"><h3>move-merchant</h3><div class="usage"><code>(move-merchant merchant world)</code></div><div class="doc"><div class="markdown"><p>Handle general en route movement of this <code>merchant</code> in this <code>world</code>.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L385">view source</a></div></div><div class="public anchor" id="var-nearest-with-targets"><h3>nearest-with-targets</h3><div class="usage"><code>(nearest-with-targets plans targets)</code></div><div class="doc"><div class="markdown"><p>Return the distance to the nearest destination among those of these <code>plans</code> which match these <code>targets</code>. Plans are expected to be plans as returned by <code>generate-trade-plans</code>, q.v.; <code>targets</code> are expected to be as accepted by <code>make-target-filter</code>, q.v.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L104">view source</a></div></div><div class="public anchor" id="var-plan-and-buy"><h3>plan-and-buy</h3><div class="usage"><code>(plan-and-buy merchant world)</code></div><div class="doc"><div class="markdown"><p>Return a world like this <code>world</code>, in which this <code>merchant</code> has planned a new trade, and bought appropriate stock for it. If no profitable trade can be planned, the merchant is simply moved towards their home.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L278">view source</a></div></div><div class="public anchor" id="var-plan-trade"><h3>plan-trade</h3><div class="usage"><code>(plan-trade merchant world commodity)</code></div><div class="doc"><div class="markdown"><p>Find the best destination in this <code>world</code> for this <code>commodity</code> given this <code>merchant</code> and this <code>origin</code>. 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. <code>merchant</code> may be passed as a map or a keyword; <code>commodity</code> should be passed as a keyword.</p>
|
||
<p>The returned plan is a map with keys:</p>
|
||
<ul>
|
||
<li>:merchant - the id of the <code>merchant</code> for whom the plan was created;</li>
|
||
<li>:origin - the city from which the trade starts;</li>
|
||
<li>:destination - the city to which the trade is planned;</li>
|
||
<li>:commodity - the <code>commodity</code> to be carried;</li>
|
||
<li>:buy-price - the price at which that <code>commodity</code> can be bought;</li>
|
||
<li>:expected-price - the price at which the <code>merchant</code> anticipates that <code>commodity</code> can be sold;</li>
|
||
<li>:distance - the number of stages in the planned journey</li>
|
||
<li>:dist-to-home - the distance from <code>destination</code> to the <code>merchant</code>’s home city.</li>
|
||
</ul></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L118">view source</a></div></div><div class="public anchor" id="var-re-plan"><h3>re-plan</h3><div class="usage"><code>(re-plan merchant world)</code></div><div class="doc"><div class="markdown"><p>Having failed to sell a cargo at current location, re-plan a route to sell the current cargo. Returns a revised world.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L323">view source</a></div></div><div class="public anchor" id="var-run"><h3>run</h3><div class="usage"><code>(run world)</code></div><div class="doc"><div class="markdown"><p>Return a world like this <code>world</code>, but with each merchant moved.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L412">view source</a></div></div><div class="public anchor" id="var-select-cargo"><h3>select-cargo</h3><div class="usage"><code>(select-cargo merchant world)</code></div><div class="doc"><div class="markdown"><p>A <code>merchant</code>, in a given location in a <code>world</code>, 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.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L211">view source</a></div></div><div class="public anchor" id="var-sell-and-buy"><h3>sell-and-buy</h3><div class="usage"><code>(sell-and-buy merchant world)</code></div><div class="doc"><div class="markdown"><p>Return a new world like this <code>world</code>, in which this <code>merchant</code> has sold their current stock in their current location, and planned a new trade, and bought appropriate stock for it.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/merchants/merchants.clj#L342">view source</a></div></div></div></body></html> |