From b666540ac9fa32337422ad3ddec7b04d9bab4263 Mon Sep 17 00:00:00 2001
From: Simon Brooke
(defn- transform-cell
[cell world rules]
(try
- (apply-rules cell world rules)
- (catch Exception e (merge {:state :error :error (.getMessage e)} cell)))) Return a row derived from this row of this world by applying these rules to each cell.
+ (merge + (apply-rules cell world rules) + {:generation (+ (or (:generation cell) 0) 1)}) + (catch Exception e + (merge cell {:error + (format "%s at generation %d when in state %s" + (.getMessage e) + (:generation cell) + (:state cell))}))))Return a row derived from this row of this world by applying these rules to each cell.
(defn- transform-world-row [row world rules] (map #(transform-cell % world rules) row))
Return a world derived from this world by applying these rules to each cell.
@@ -3287,7 +3294,7 @@ ignored). Darker shades are higher. (fn [cell world] (cond (and (= (:state cell) :new) (> (get-int cell :altitude) snowline)) (merge cell {:state :snow}))) ;; in between, we have a wasteland. - (fn [cell world] (cond (= (:state cell) :new) (merge cell {:state :waste})))))(def natural-rules (flatten
(list
vegetation-rules
@@ -3373,12 +3380,15 @@ ignored). Darker shades are higher.
* `cell` a cell within that world;
* `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
+* `property` a keyword representing a property of the neighbours;
+* `value` a value of that property;
+* `op` a comparator function to use in place of `=`.
+
+It gets messy.
(defn get-neighbours-with-property-value
- ([world x y depth property value comparator]
- (filter #(apply comparator (list (get % property) value)) (get-neighbours world x y depth)))
+ ([world x y depth property value op]
+ (filter #(eval (list op (get % 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 0c68227..7032d5b 100644
--- a/resources/public/docs/mw-parser/uberdoc.html
+++ b/resources/public/docs/mw-parser/uberdoc.html
@@ -3226,9 +3226,9 @@ front of the sequence of tokens it returns nil.
(cond (and (= comp1 "equal") (= comp2 "to"))
(gen-neighbours-condition comparator quantity property value remainder '=)
(and (= comp1 "more") (= comp2 "than"))
- (gen-neighbours-condition '> quantity property value remainder '>)
+ (gen-neighbours-condition comparator quantity property value remainder '>)
(and (= comp1 "less") (= comp2 "than"))
- (gen-neighbours-condition '< quantity property value remainder '<)))))))(defn parse-some-neighbours-condition
[[SOME NEIGHBOURS & rest]]
(cond
diff --git a/resources/public/docs/mw-ui/uberdoc.html b/resources/public/docs/mw-ui/uberdoc.html
index 4a5d41a..c2cde8a 100644
--- a/resources/public/docs/mw-ui/uberdoc.html
+++ b/resources/public/docs/mw-ui/uberdoc.html
@@ -3124,6 +3124,7 @@ net.brehaut.ClojureTools = (function (SH) {
[mw-engine.world :as world]
[mw-engine.heightmap :as heightmap]
[mw-engine.natural-rules :as rules]
+ [mw-parser.bulk :as compiler]
[hiccup.core :refer [html]]
[noir.session :as session]))(defn format-css-class [statekey]
@@ -3135,12 +3136,13 @@ net.brehaut.ClojureTools = (function (SH) {
[statekey]
(format "img/tiles/%s.png" (format-css-class statekey)))(defn format-mouseover [cell] - (str "State " (:state cell) "; altitude: " (:altitude cell) "; fertility: " (:fertility cell)))
Render this world cell as a Hiccup table cell.
+ (str cell))Render this world cell as a Hiccup table cell.
(defn render-cell
[cell]
(let [state (:state cell)]
[:td {:class (format-css-class state) :title (format-mouseover cell)}
- [:img {:alt (world/format-cell cell) :src (format-image-path state)}]]))Render this world row as a Hiccup table row.
+ [:a {:href (format "inspect?x=%d&y=%d" (:x cell) (:y cell))} + [:img {:alt (world/format-cell cell) :src (format-image-path state)}]]]))Render this world row as a Hiccup table row.
(defn render-world-row [row] (apply vector (cons :tr (map render-cell row))))
Render the world implied by the session as a complete HTML page.
@@ -3152,7 +3154,9 @@ net.brehaut.ClojureTools = (function (SH) { (world/make-world 20 20) "resources/public/img/20x20/hill.png") rules/init-rules)) - rules (or (session/get :rules) rules/natural-rules) + rules (or (session/get :rules) + (do (session/put! :rules (compiler/compile-file "resources/rulesets/basic.txt")) + (session/get :rules))) generation (+ (or (session/get :generation) 0) 1) w2 (engine/transform-world world rules) ] diff --git a/resources/public/img/tiles/camp.png b/resources/public/img/tiles/camp.png new file mode 100644 index 0000000000000000000000000000000000000000..c2ecf86bc01c4877959c8f10ff6ce3c0adcf8ec1 GIT binary patch literal 395 zcmV;60d)R}P)