mw-engine/docs/codox/mw-engine.flow.html

27 lines
9.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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.2.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.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.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></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 doesnt 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 theres a planning stage, in which all the flows to be executed are computed without changing the world, and then an execution stage, where theyre 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#L51">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#L134">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#L139">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#L127">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#L123">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#L89">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#L116">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#L75">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#L62">view source</a></div></div></div></body></html>