From 4a48acee20f10bf9c985844349d8dc9df3b8c6af Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Sun, 20 Jul 2014 15:17:09 +0100 Subject: [PATCH] Added settlement ruleset --- resources/public/docs/mw-engine/uberdoc.html | 11 ++++++++--- resources/public/docs/mw-parser/uberdoc.html | 11 ++--------- resources/public/docs/mw-ui/uberdoc.html | 6 +++--- resources/rulesets/settlement.txt | 12 ++++++++---- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/resources/public/docs/mw-engine/uberdoc.html b/resources/public/docs/mw-engine/uberdoc.html index f4ba5b6..a2c9acf 100644 --- a/resources/public/docs/mw-engine/uberdoc.html +++ b/resources/public/docs/mw-engine/uberdoc.html @@ -3366,7 +3366,7 @@ important.

(defn get-int
   [map key]
-  (cond map
+  (cond (map? map)
     (let [v (map key)]
       (cond (and v (integer? v)) v
             true 0))
@@ -3415,14 +3415,19 @@ important.

* `depth` an integer representing the distance from [x,y] that should be searched; * `property` a keyword representing a property of the neighbours; -* `value` a value of that property; +* `value` a value of that property (or, possibly, the name of another); * `op` a comparator function to use in place of `=`.

It gets messy.

(defn get-neighbours-with-property-value
   ([world x y depth property value op]
-    (filter #(eval (list op (get % property) value)) (get-neighbours world x y depth)))
+    (filter 
+      #(eval 
+         (list op 
+               (or (get % property) (get-int % property)) 
+               value)) 
+      (get-neighbours world x y depth)))
   ([world x y depth property value]
     (get-neighbours-with-property-value world x y depth property value =))
   ([world cell depth property value]
diff --git a/resources/public/docs/mw-parser/uberdoc.html b/resources/public/docs/mw-parser/uberdoc.html
index 9a00606..90e8d17 100644
--- a/resources/public/docs/mw-parser/uberdoc.html
+++ b/resources/public/docs/mw-parser/uberdoc.html
@@ -3053,18 +3053,11 @@ objective is to parse rules out of a block of text from a textarea

function, and return the sequence of such functions.

(defn compile-string
   [string]
-  (map #(compile-rule % true) (remove comment? (split string #"\n"))))

Compile each non-comment line of the file indicated by this filename into + (map #(compile-rule % true) (remove comment? (trim (split string #"\n")))))

Compile each non-comment line of the file indicated by this filename into an executable anonymous function, and return the sequence of such functions.

(defn compile-file 
   [filename]
-  (compile-string (slurp filename)))

(let [lines - (doall (with-open [rdr (reader filename)] (line-seq rdr)))] - (map parse-line lines)))

-

(defn parse-string - "Parse rules from successive lines in this string" - [string] - (parse-from-reader (BufferedReader. (StringReader. string))))

mw-parser.core

toc

A very simple parser which parses production rules of the following forms:

+ (compile-string (slurp filename))) 

mw-parser.core

toc

A very simple parser which parses production rules of the following forms: