Regenerated documentation

This commit is contained in:
Simon Brooke 2014-07-19 13:24:46 +01:00
parent 18233ca0f5
commit 707f93d7a3
2 changed files with 42 additions and 11 deletions

View file

@ -3029,7 +3029,7 @@ net.brehaut.ClojureTools = (function (SH) {
}; };
})(SyntaxHighlighter); })(SyntaxHighlighter);
</script><title>mw-engine -- Marginalia</title></head><body><table><tr><td class="docs"><div class="header"><h1 class="project-name">mw-engine</h1><h2 class="project-version">0.1.0-SNAPSHOT</h2><br /><p>Cellular automaton world builder.</p> </script><title>mw-engine -- Marginalia</title></head><body><table><tr><td class="docs"><div class="header"><h1 class="project-name">mw-engine</h1><h2 class="project-version">0.1.0-SNAPSHOT</h2><br /><p>Cellular automaton world builder.</p>
</div><div class="dependencies"><h3>dependencies</h3><table><tr><td class="dep-name">org.clojure/clojure</td><td class="dotted"><hr /></td><td class="dep-version">1.5.1</td></tr><tr><td class="dep-name">org.clojure/math.combinatorics</td><td class="dotted"><hr /></td><td class="dep-version">0.0.7</td></tr><tr><td class="dep-name">net.mikera/imagez</td><td class="dotted"><hr /></td><td class="dep-version">0.3.1</td></tr><tr><td class="dep-name">fivetonine/collage</td><td class="dotted"><hr /></td><td class="dep-version">0.2.0</td></tr></table></div></td><td class="codes" style="text-align: center; vertical-align: middle;color: #666;padding-right:20px"><br /><br /><br />(this space intentionally left almost blank)</td></tr><tr><td class="docs"><div class="toc"><a name="toc"><h3>namespaces</h3></a><ul><li><a href="#mw-engine.core">mw-engine.core</a></li><li><a href="#mw-engine.heightmap">mw-engine.heightmap</a></li><li><a href="#mw-engine.natural-rules">mw-engine.natural-rules</a></li><li><a href="#mw-engine.utils">mw-engine.utils</a></li><li><a href="#mw-engine.world">mw-engine.world</a></li></ul></div></td><td class="codes">&nbsp;</td></tr><tr><td class="docs"><div class="docs-header"><a class="anchor" href="#mw-engine.core" name="mw-engine.core"><h1 class="project-name">mw-engine.core</h1><a class="toc-link" href="#toc">toc</a></a></div></td><td class="codes" /></tr><tr><td class="docs"><p>Functions to transform a world and run rules.</p> </div><div class="dependencies"><h3>dependencies</h3><table><tr><td class="dep-name">org.clojure/clojure</td><td class="dotted"><hr /></td><td class="dep-version">1.5.1</td></tr><tr><td class="dep-name">org.clojure/math.combinatorics</td><td class="dotted"><hr /></td><td class="dep-version">0.0.7</td></tr><tr><td class="dep-name">org.clojure/tools.trace</td><td class="dotted"><hr /></td><td class="dep-version">0.7.8</td></tr><tr><td class="dep-name">net.mikera/imagez</td><td class="dotted"><hr /></td><td class="dep-version">0.3.1</td></tr><tr><td class="dep-name">fivetonine/collage</td><td class="dotted"><hr /></td><td class="dep-version">0.2.0</td></tr></table></div></td><td class="codes" style="text-align: center; vertical-align: middle;color: #666;padding-right:20px"><br /><br /><br />(this space intentionally left almost blank)</td></tr><tr><td class="docs"><div class="toc"><a name="toc"><h3>namespaces</h3></a><ul><li><a href="#mw-engine.core">mw-engine.core</a></li><li><a href="#mw-engine.heightmap">mw-engine.heightmap</a></li><li><a href="#mw-engine.natural-rules">mw-engine.natural-rules</a></li><li><a href="#mw-engine.utils">mw-engine.utils</a></li><li><a href="#mw-engine.world">mw-engine.world</a></li></ul></div></td><td class="codes">&nbsp;</td></tr><tr><td class="docs"><div class="docs-header"><a class="anchor" href="#mw-engine.core" name="mw-engine.core"><h1 class="project-name">mw-engine.core</h1><a class="toc-link" href="#toc">toc</a></a></div></td><td class="codes" /></tr><tr><td class="docs"><p>Functions to transform a world and run rules.</p>
</td><td class="codes"></td></tr><tr><td class="docs"> </td><td class="codes"></td></tr><tr><td class="docs">
</td><td class="codes"><pre class="brush: clojure">(ns mw-engine.core </td><td class="codes"><pre class="brush: clojure">(ns mw-engine.core
(:require [mw-engine.world :as world] (:require [mw-engine.world :as world]
@ -3054,11 +3054,34 @@ See <code>world.clj</code>.</p>
<p>Each time the world is transformed (see <code>transform-world</code>, for each cell, <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 rules are applied in turn until one matches. Once one rule has matched no
further rules can be applied.</p> further rules can be applied.</p>
</td><td class="codes"></td></tr><tr><td class="docs"><p>Derive a cell from this cell of this world by applying these rules.</p> </td><td class="codes"></td></tr><tr><td class="docs"><p>Apply a single rule to a cell. 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. So a rule may be either
an ifn, or a list (ifn source-text). This function deals with despatching
on those two possibilities.</p>
</td><td class="codes"><pre class="brush: clojure">(defn apply-rule
([cell world rule]
(cond
(ifn? rule) (apply-rule cell world rule nil)
(seq? rule) (let [[afn src] rule] (apply-rule cell world afn src))))
;; {:afn afn :src src})))
;; (apply-rule cell world (first rule) (first (rest rule)))))
([cell world rule source]
(try
(let [result (apply rule (list cell world))]
(cond
(and result source) (merge result {:rule source})
true result))
(catch Exception e
(merge cell {:error (format &quot;%s at generation %d when in state %s&quot;
(.getMessage e)
(:generation cell)
(:state cell))
:error-rule source})))))</pre></td></tr><tr><td class="docs"><p>Derive a cell from this cell of this world by applying these rules.</p>
</td><td class="codes"><pre class="brush: clojure">(defn- apply-rules </td><td class="codes"><pre class="brush: clojure">(defn- apply-rules
[cell world rules] [cell world rules]
(cond (empty? rules) cell (cond (empty? rules) cell
true (let [result (apply (eval (first rules)) (list cell world))] true (let [result (apply-rule cell world (first rules))]
(cond result result (cond result result
true (apply-rules cell world (rest rules))))))</pre></td></tr><tr><td class="docs"><p>Derive a cell from this cell of this world by applying these rules. If an true (apply-rules cell world (rest rules))))))</pre></td></tr><tr><td class="docs"><p>Derive a cell from this cell of this world by applying these rules. If an
exception is thrown, cache its message on the cell and set state to error</p> exception is thrown, cache its message on the cell and set state to error</p>

View file

@ -3053,7 +3053,7 @@ objective is to parse rules out of a block of text from a textarea</p>
function, and return the sequence of such functions.</p> function, and return the sequence of such functions.</p>
</td><td class="codes"><pre class="brush: clojure">(defn compile-string </td><td class="codes"><pre class="brush: clojure">(defn compile-string
[string] [string]
(map compile-rule (remove comment? (split string #&quot;\n&quot;))))</pre></td></tr><tr><td class="docs"><p>Compile each non-comment line of the file indicated by this <code>filename</code> into (map #(compile-rule % true) (remove comment? (split string #&quot;\n&quot;))))</pre></td></tr><tr><td class="docs"><p>Compile each non-comment line of the file indicated by this <code>filename</code> into
an executable anonymous function, and return the sequence of such functions.</p> an executable anonymous function, and return the sequence of such functions.</p>
</td><td class="codes"><pre class="brush: clojure">(defn compile-file </td><td class="codes"><pre class="brush: clojure">(defn compile-file
[filename] [filename]
@ -3393,18 +3393,26 @@ front of the sequence of tokens it returns nil.</p>
true true
(let [[left remainder] (parse-left-hand-side line) (let [[left remainder] (parse-left-hand-side line)
[right junk] (parse-right-hand-side remainder)] [right junk] (parse-right-hand-side remainder)]
;; TODO: there shouldn't be any junk (should be null)
(cond (cond
(and left right (nil? junk)) ;; there should be a valide left hand side and a valid right hand side
;; there shouldn't be anything left over (junk should be empty)
(and left right (empty? junk))
(list 'fn ['cell 'world] (list 'if left right))))))</pre></td></tr><tr><td class="docs"><p>Parse this <code>rule-text</code>, a string conforming to the grammar of MicroWorld rules, (list 'fn ['cell 'world] (list 'if left right))))))</pre></td></tr><tr><td class="docs"><p>Parse this <code>rule-text</code>, a string conforming to the grammar of MicroWorld rules,
into Clojure source, and then compile it into an anonymous into Clojure source, and then compile it into an anonymous
function object, getting round the problem of binding mw-engine.utils in function object, getting round the problem of binding mw-engine.utils in
the compiling environment.</p> the compiling environment. If <code>return-tuple?</code> is present and true, return
a list comprising the anonymous function compiled, and the function from
which it was compiled.</p>
<p> Throws an exception if parsing fails.</p> <p> Throws an exception if parsing fails.</p>
</td><td class="codes"><pre class="brush: clojure">(defn compile-rule </td><td class="codes"><pre class="brush: clojure">(defn compile-rule
[rule-text] ([rule-text return-tuple?]
(do (do
(use 'mw-engine.utils) (use 'mw-engine.utils)
(eval (parse-rule rule-text)))) </pre></td></tr><tr><td class="spacer docs">&nbsp;</td><td class="codes" /></tr></table><div class="footer">Generated by <a href="https://github.com/fogus/marginalia">Marginalia</a>.&nbsp;&nbsp;Syntax highlighting provided by Alex Gorbatchev's <a href="http://alexgorbatchev.com/SyntaxHighlighter/">SyntaxHighlighter</a></div><script type="text/javascript">SyntaxHighlighter.defaults['gutter'] = false; (let [afn (eval (parse-rule rule-text))]
(cond
(and afn return-tuple?)(list afn rule-text)
true afn))))
([rule-text]
(compile-rule rule-text false)))</pre></td></tr><tr><td class="spacer docs">&nbsp;</td><td class="codes" /></tr></table><div class="footer">Generated by <a href="https://github.com/fogus/marginalia">Marginalia</a>.&nbsp;&nbsp;Syntax highlighting provided by Alex Gorbatchev's <a href="http://alexgorbatchev.com/SyntaxHighlighter/">SyntaxHighlighter</a></div><script type="text/javascript">SyntaxHighlighter.defaults['gutter'] = false;
SyntaxHighlighter.all()</script></body></html> SyntaxHighlighter.all()</script></body></html>