mw-engine/docs/codox/mw-engine.core.html
Simon Brooke c739dd7094 Drainage is now *mostly* working...
not sure about rivers flowing out of lakes.
2024-04-06 16:54:10 +01:00

22 lines
7.9 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.core 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 current"><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"><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.core.html#var-*with-history*"><div class="inner"><span>*with-history*</span></div></a></li><li class="depth-1"><a href="mw-engine.core.html#var-apply-rule"><div class="inner"><span>apply-rule</span></div></a></li><li class="depth-1"><a href="mw-engine.core.html#var-known-rule-types"><div class="inner"><span>known-rule-types</span></div></a></li><li class="depth-1"><a href="mw-engine.core.html#var-run-world"><div class="inner"><span>run-world</span></div></a></li><li class="depth-1"><a href="mw-engine.core.html#var-transform-world"><div class="inner"><span>transform-world</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">mw-engine.core</h1><div class="doc"><div class="markdown"><p>Functions to transform a world and run rules.</p>
<p>Every rule is a function of two arguments, a cell and a world. If the rule fires, it returns a new cell, which should have the same values for <code>:x</code> and <code>:y</code> as the old cell. Anything else can be modified.</p>
<p>While any function of two arguments can be used as a rule, a special high level rule language is provided by the <code>mw-parser</code> package, which compiles rules expressed in a subset of English rules into suitable functions.</p>
<p>A cell is a map containing at least values for the keys :x, :y, and :state; a transformation should not alter the values of :x or :y, and should not return a cell without a keyword as the value of :state. Anything else is legal.</p>
<p>A world is a two dimensional matrix (sequence of sequences) of cells, such that every cells <code>:x</code> and <code>:y</code> properties reflect its place in the matrix. See <code>world.clj</code>.</p>
<p>Each time the world is transformed (see <code>transform-world</code>), for each cell, rules are applied in turn until one matches. Once one rule has matched no further rules can be applied to that cell.</p>
</div></div><div class="public anchor" id="var-*with-history*"><h3>*with-history*</h3><h4 class="dynamic">dynamic</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>I suspect that caching history on the cells is greatly worsening the memory problems. Make it optional, but by default false.</p>
</div></div><div class="src-link"><a href="https://github.com/simon-brooke/mw-engine/blob/master/src/cljc/mw_engine/core.clj#L53">view source</a></div></div><div class="public anchor" id="var-apply-rule"><h3>apply-rule</h3><div class="usage"><code>(apply-rule world cell rule)</code></div><div class="doc"><div class="markdown"><p>Apply a single <code>rule</code> to a <code>cell</code>. What this is about is that I want to be able, for debugging purposes, to tag a cell with the rule text of the rule which fired (and especially so when an exception is thrown).</p>
</div></div><div class="src-link"><a href="https://github.com/simon-brooke/mw-engine/blob/master/src/cljc/mw_engine/core.clj#L62">view source</a></div></div><div class="public anchor" id="var-known-rule-types"><h3>known-rule-types</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>Types of rules we know about.</p>
</div></div><div class="src-link"><a href="https://github.com/simon-brooke/mw-engine/blob/master/src/cljc/mw_engine/core.clj#L58">view source</a></div></div><div class="public anchor" id="var-run-world"><h3>run-world</h3><div class="usage"><code>(run-world world rules generations)</code><code>(run-world world init-rules rules generations)</code></div><div class="doc"><div class="markdown"><p>Run this <code>world</code> with these <code>rules</code> for this number of <code>generations</code>.</p>
<ul>
<li><code>world</code> a world as discussed above;</li>
<li><code>init-rules</code> a sequence of rules as defined above, to be run once to initialise the world;</li>
<li><code>rules</code> a sequence of rules as defined above, to be run iteratively for each generation;</li>
<li><code>generations</code> an (integer) number of generations.</li>
</ul>
<p><strong>NOTE THAT</strong> all rules <strong>must</strong> be tagged with <code>rule-type</code> metadata, or they <strong>will not</strong> be executed.</p>
<p>Return the final generation of the world.</p>
</div></div><div class="src-link"><a href="https://github.com/simon-brooke/mw-engine/blob/master/src/cljc/mw_engine/core.clj#L130">view source</a></div></div><div class="public anchor" id="var-transform-world"><h3>transform-world</h3><div class="usage"><code>(transform-world world rules)</code></div><div class="doc"><div class="markdown"><p>Return a world derived from this <code>world</code> by applying the production rules found among these <code>rules</code> to each cell.</p>
</div></div><div class="src-link"><a href="https://github.com/simon-brooke/mw-engine/blob/master/src/cljc/mw_engine/core.clj#L119">view source</a></div></div></div></body></html>