29 lines
11 KiB
HTML
29 lines
11 KiB
HTML
<!DOCTYPE html PUBLIC ""
|
||
"">
|
||
<html><head><meta charset="UTF-8" /><title>mw-engine.flow 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">Mw-engine</span> <span class="project-version">0.3.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 mw-engine</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>mw-engine</span></div></div></li><li class="depth-2 branch"><a href="mw-engine.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 branch"><a href="mw-engine.display.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>display</span></div></a></li><li class="depth-2 branch"><a href="mw-engine.drainage.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>drainage</span></div></a></li><li class="depth-2 branch current"><a href="mw-engine.flow.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>flow</span></div></a></li><li class="depth-2 branch"><a href="mw-engine.heightmap.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>heightmap</span></div></a></li><li class="depth-2 branch"><a href="mw-engine.natural-rules.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>natural-rules</span></div></a></li><li class="depth-2 branch"><a href="mw-engine.render.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>render</span></div></a></li><li class="depth-2 branch"><a href="mw-engine.utils.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>utils</span></div></a></li><li class="depth-2"><a href="mw-engine.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="mw-engine.flow.html#var-coordinate.3F"><div class="inner"><span>coordinate?</span></div></a></li><li class="depth-1"><a href="mw-engine.flow.html#var-create-flow-fraction"><div class="inner"><span>create-flow-fraction</span></div></a></li><li class="depth-1"><a href="mw-engine.flow.html#var-create-flow-percent"><div class="inner"><span>create-flow-percent</span></div></a></li><li class="depth-1"><a href="mw-engine.flow.html#var-create-flow-quantity"><div class="inner"><span>create-flow-quantity</span></div></a></li><li class="depth-1"><a href="mw-engine.flow.html#var-create-location"><div class="inner"><span>create-location</span></div></a></li><li class="depth-1"><a href="mw-engine.flow.html#var-execute"><div class="inner"><span>execute</span></div></a></li><li class="depth-1"><a href="mw-engine.flow.html#var-execute-flows"><div class="inner"><span>execute-flows</span></div></a></li><li class="depth-1"><a href="mw-engine.flow.html#var-flow-world"><div class="inner"><span>flow-world</span></div></a></li><li class="depth-1"><a href="mw-engine.flow.html#var-flow.3F"><div class="inner"><span>flow?</span></div></a></li><li class="depth-1"><a href="mw-engine.flow.html#var-location.3F"><div class="inner"><span>location?</span></div></a></li><li class="depth-1"><a href="mw-engine.flow.html#var-plan-flows"><div class="inner"><span>plan-flows</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">mw-engine.flow</h1><div class="doc"><div class="markdown"><p>Allow flows of values between cells in the world.</p>
|
||
<p>The design here is: a flow object is a map with the following properties:</p>
|
||
<ol>
|
||
<li><code>:source</code>, whose value is a location;</li>
|
||
<li><code>:destination</code>, whose value is a location;</li>
|
||
<li><code>:property</code>, whose value is a keyword;</li>
|
||
<li><code>:quantity</code>, whose value is a positive real number.</li>
|
||
</ol>
|
||
<p>A location object is a map with the following properties:</p>
|
||
<ol>
|
||
<li><code>:x</code>, whose value is a natural number not greater than the extent of the world;</li>
|
||
<li><code>:y</code>, whose value is a natural number not greater than the extent of the world.</li>
|
||
</ol>
|
||
<p>To execute a flow is transfer the quantity specified of the property specified from the cell at the source specified to the cell at the destination specified; if the source doesn’t have sufficient of the property, then all it has should be transferred, but no more: properties to be flowed cannot be pulled negative.</p>
|
||
<p>Flowing values through the world is consequently a two stage process: firstly there’s a planning stage, in which all the flows to be executed are computed without changing the world, and then an execution stage, where they’re all executed. This namespace deals with mainly with execution.</p>
|
||
</div></div><div class="public anchor" id="var-coordinate.3F"><h3>coordinate?</h3><div class="usage"><code>(coordinate? o world)</code></div><div class="doc"><div class="markdown"><p>Return <code>true</code> if this object <code>o</code> is a valid coordinate with respect to this <code>world</code>, else <code>false</code>. Assumes square worlds.</p>
|
||
</div></div><div class="src-link"><a href="https://github.com/simon-brooke/mw-engine/blob/master/src/cljc/mw_engine/flow.clj#L52">view source</a></div></div><div class="public anchor" id="var-create-flow-fraction"><h3>create-flow-fraction</h3><h4 class="type">macro</h4><div class="usage"><code>(create-flow-fraction source dest prop fraction)</code></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p>
|
||
</div></div><div class="src-link"><a href="https://github.com/simon-brooke/mw-engine/blob/master/src/cljc/mw_engine/flow.clj#L172">view source</a></div></div><div class="public anchor" id="var-create-flow-percent"><h3>create-flow-percent</h3><h4 class="type">macro</h4><div class="usage"><code>(create-flow-percent source dest prop percent)</code></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p>
|
||
</div></div><div class="src-link"><a href="https://github.com/simon-brooke/mw-engine/blob/master/src/cljc/mw_engine/flow.clj#L177">view source</a></div></div><div class="public anchor" id="var-create-flow-quantity"><h3>create-flow-quantity</h3><h4 class="type">macro</h4><div class="usage"><code>(create-flow-quantity source dest prop quantity)</code></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p>
|
||
</div></div><div class="src-link"><a href="https://github.com/simon-brooke/mw-engine/blob/master/src/cljc/mw_engine/flow.clj#L165">view source</a></div></div><div class="public anchor" id="var-create-location"><h3>create-location</h3><h4 class="type">macro</h4><div class="usage"><code>(create-location cell)</code></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p>
|
||
</div></div><div class="src-link"><a href="https://github.com/simon-brooke/mw-engine/blob/master/src/cljc/mw_engine/flow.clj#L161">view source</a></div></div><div class="public anchor" id="var-execute"><h3>execute</h3><div class="usage"><code>(execute world flow)</code></div><div class="doc"><div class="markdown"><p>Return a world like this <code>world</code>, except with the quantity of the property described in this <code>flow</code> object transferred from the source of that flow to its destination.</p>
|
||
</div></div><div class="src-link"><a href="https://github.com/simon-brooke/mw-engine/blob/master/src/cljc/mw_engine/flow.clj#L90">view source</a></div></div><div class="public anchor" id="var-execute-flows"><h3>execute-flows</h3><div class="usage"><code>(execute-flows world flows)</code></div><div class="doc"><div class="markdown"><p>Return a world like this <code>world</code>, but with each of these flows executed.</p>
|
||
</div></div><div class="src-link"><a href="https://github.com/simon-brooke/mw-engine/blob/master/src/cljc/mw_engine/flow.clj#L123">view source</a></div></div><div class="public anchor" id="var-flow-world"><h3>flow-world</h3><div class="usage"><code>(flow-world world rules)</code></div><div class="doc"><div class="markdown"><p>Return a world derived from this <code>world</code> by applying the flow rules found among these <code>rules</code> to each cell, and executing all the flows planned.</p>
|
||
</div></div><div class="src-link"><a href="https://github.com/simon-brooke/mw-engine/blob/master/src/cljc/mw_engine/flow.clj#L152">view source</a></div></div><div class="public anchor" id="var-flow.3F"><h3>flow?</h3><div class="usage"><code>(flow? o world)</code></div><div class="doc"><div class="markdown"><p>Return <code>true</code> if this object <code>o</code> is a flow as defined above with respect to this <code>world</code>, else <code>false</code>. Assumes square worlds.</p>
|
||
</div></div><div class="src-link"><a href="https://github.com/simon-brooke/mw-engine/blob/master/src/cljc/mw_engine/flow.clj#L76">view source</a></div></div><div class="public anchor" id="var-location.3F"><h3>location?</h3><div class="usage"><code>(location? o world)</code></div><div class="doc"><div class="markdown"><p>Return <code>true</code> if this object <code>o</code> is a location as defined above with respect to this <code>world</code>, else <code>false</code>.</p>
|
||
</div></div><div class="src-link"><a href="https://github.com/simon-brooke/mw-engine/blob/master/src/cljc/mw_engine/flow.clj#L63">view source</a></div></div><div class="public anchor" id="var-plan-flows"><h3>plan-flows</h3><div class="usage"><code>(plan-flows world rules)</code></div><div class="doc"><div class="markdown"><p>Plan, but do not execute, all the flows in this <code>world</code> implied by those of these <code>rules</code> (which are expected to be pre-compiled) which are flow rules. Return the list of plans, as flow objects.</p>
|
||
</div></div><div class="src-link"><a href="https://github.com/simon-brooke/mw-engine/blob/master/src/cljc/mw_engine/flow.clj#L140">view source</a></div></div></div></body></html> |