Fix linting issues
This commit is contained in:
		
							parent
							
								
									630309719e
								
							
						
					
					
						commit
						67a43279f6
					
				|  | @ -1,10 +1,7 @@ | ||||||
| (ns ^{:doc "Functions to transform a world and run rules." | (ns ^{:doc "Functions to transform a world and run rules." | ||||||
|       :author "Simon Brooke"} |       :author "Simon Brooke"} | ||||||
|   mw-engine.core |   mw-engine.core | ||||||
|   (:require [clojure.core.reducers :as r] |   (:require [mw-engine.utils :refer [get-int-or-zero map-world]] | ||||||
|             [clojure.string :refer [join]] |  | ||||||
|             [mw-engine.world :as world] |  | ||||||
|             [mw-engine.utils :refer [get-int-or-zero map-world]] |  | ||||||
|             [taoensso.timbre :as l])) |             [taoensso.timbre :as l])) | ||||||
| 
 | 
 | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
|  | @ -68,16 +65,16 @@ | ||||||
|     (let [result (apply rule (list cell world))] |     (let [result (apply rule (list cell world))] | ||||||
|       (cond |       (cond | ||||||
|         (and result source) (merge result {:rule source}) |         (and result source) (merge result {:rule source}) | ||||||
|         true result)))) |         :else result)))) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| (defn- apply-rules | (defn- apply-rules | ||||||
|   "Derive a cell from this `cell` of this `world` by applying these `rules`." |   "Derive a cell from this `cell` of this `world` by applying these `rules`." | ||||||
|   [world cell rules] |   [world cell rules] | ||||||
|   (cond (empty? rules) cell |   (cond (empty? rules) cell | ||||||
|     true (let [result (apply-rule world cell (first rules))] |     :else (let [result (apply-rule world cell (first rules))] | ||||||
|            (cond result result |            (cond result result | ||||||
|              true (apply-rules world cell (rest rules)))))) |              :else (apply-rules world cell (rest rules)))))) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| (defn- transform-cell | (defn- transform-cell | ||||||
|  | @ -104,16 +101,6 @@ | ||||||
|   (map-world world transform-cell (list rules))) |   (map-world world transform-cell (list rules))) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| (defn- transform-world-state |  | ||||||
|   "Consider this single argument as a map of `:world` and `:rules`; apply the rules |  | ||||||
|    to transform the world, and return a map of the new, transformed `:world` and |  | ||||||
|    these `:rules`. As a side effect, print the world." |  | ||||||
|   [state] |  | ||||||
|   (let [world (transform-world (:world state) (:rules state))] |  | ||||||
|     ;;(world/print-world world) |  | ||||||
|     {:world world :rules (:rules state)})) |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| (defn run-world | (defn run-world | ||||||
|   "Run this world with these rules for this number of generations. |   "Run this world with these rules for this number of generations. | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,9 +1,6 @@ | ||||||
| (ns ^{:doc "Simple functions to allow a world to be visualised." | (ns ^{:doc "Simple functions to allow a world to be visualised." | ||||||
|       :author "Simon Brooke"} |       :author "Simon Brooke"} | ||||||
|   mw-engine.display |   mw-engine.display) | ||||||
|   (:require [hiccup.core :refer [html]] |  | ||||||
|             mw-engine.utils |  | ||||||
|             mw-engine.world)) |  | ||||||
| 
 | 
 | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
| ;;;; | ;;;; | ||||||
|  | @ -32,9 +29,10 @@ | ||||||
|   "Base url (i.e., url of directory) from which to load tile images." |   "Base url (i.e., url of directory) from which to load tile images." | ||||||
|   "img/tiles") |   "img/tiles") | ||||||
| 
 | 
 | ||||||
| (defn format-css-class [state] | (defn format-css-class  | ||||||
|   "Format this `state`, assumed to be a keyword indicating a state in the |   "Format this `state`, assumed to be a keyword indicating a state in the | ||||||
|    world, into a CSS class" |    world, into a CSS class" | ||||||
|  |   [state] | ||||||
|   (subs (str state) 1)) |   (subs (str state) 1)) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -145,7 +145,7 @@ | ||||||
|    if applied sequentially from the highest altitude to the lowest, see |    if applied sequentially from the highest altitude to the lowest, see | ||||||
|    `flow-world-nr`." |    `flow-world-nr`." | ||||||
|   [cell world] |   [cell world] | ||||||
|   (if (= (- max-altitude (get-int-or-zero cell :generation)) |   (when (= (- max-altitude (get-int-or-zero cell :generation)) | ||||||
|          (get-int-or-zero cell :altitude)) |          (get-int-or-zero cell :altitude)) | ||||||
|     (merge cell |     (merge cell | ||||||
|            {:flow (reduce + |            {:flow (reduce + | ||||||
|  | @ -167,7 +167,7 @@ | ||||||
|      (cond |      (cond | ||||||
|       (not (nil? (:flow cell))) cell |       (not (nil? (:flow cell))) cell | ||||||
|       (<= (or (:altitude cell) 0) *sealevel*) cell |       (<= (or (:altitude cell) 0) *sealevel*) cell | ||||||
|       true |       :else | ||||||
|       (merge cell |       (merge cell | ||||||
|              {:flow (+ (:rainfall cell) |              {:flow (+ (:rainfall cell) | ||||||
|                        (apply + |                        (apply + | ||||||
|  | @ -200,8 +200,8 @@ | ||||||
|     ;; if it's already tagged as a lake, it's a lake |     ;; if it's already tagged as a lake, it's a lake | ||||||
|     (:lake cell) cell |     (:lake cell) cell | ||||||
|     (let |     (let | ||||||
|       [outflow (min (map :altitude (get-neighbours world cell)))] |       [outflow (apply min (map :altitude (get-neighbours world cell)))] | ||||||
|       (if-not |       (when-not | ||||||
|         (> (:altitude cell) outflow) |         (> (:altitude cell) outflow) | ||||||
|         (assoc cell :lake true))))) |         (assoc cell :lake true))))) | ||||||
| 
 | 
 | ||||||
|  | @ -211,7 +211,7 @@ | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
| (defn run-drainage | (defn run-drainage | ||||||
|   [hmap] |  | ||||||
|   "Create a world from the heightmap `hmap`, rain on it, and then compute river |   "Create a world from the heightmap `hmap`, rain on it, and then compute river | ||||||
|    flows." |    flows." | ||||||
|  |   [hmap] | ||||||
|   (flow-world (rain-world (flood-hollows (heightmap/apply-heightmap hmap))))) |   (flow-world (rain-world (flood-hollows (heightmap/apply-heightmap hmap))))) | ||||||
|  |  | ||||||
|  | @ -1,8 +1,7 @@ | ||||||
| (ns ^{:doc "A set of MicroWorld rules describing a simplified natural ecosystem." | (ns ^{:doc "A set of MicroWorld rules describing a simplified natural ecosystem." | ||||||
|        :author "Simon Brooke"} |        :author "Simon Brooke"} | ||||||
|   mw-engine.natural-rules |   mw-engine.natural-rules | ||||||
|   (:require [mw-engine.utils :refer :all] |   (:require [mw-engine.utils :refer [get-int get-neighbours get-neighbours-with-state member?]])) | ||||||
|         [mw-engine.world :refer :all])) |  | ||||||
| 
 | 
 | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
| ;;;; | ;;;; | ||||||
|  |  | ||||||
|  | @ -137,7 +137,7 @@ | ||||||
|   * `x` a number which may or may not be a valid x coordinate within that world; |   * `x` a number which may or may not be a valid x coordinate within that world; | ||||||
|   * `y` a number which may or may not be a valid y coordinate within that world." |   * `y` a number which may or may not be a valid y coordinate within that world." | ||||||
|   [world x y] |   [world x y] | ||||||
|   (when (in-bounds world x y) |   (when (in-bounds? world x y) | ||||||
|     (nth (nth world y) x))) |     (nth (nth world y) x))) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -150,7 +150,7 @@ | ||||||
|   (if (map? map) |   (if (map? map) | ||||||
|     (let [v (map key)] |     (let [v (map key)] | ||||||
|       (cond (and v (integer? v)) v |       (cond (and v (integer? v)) v | ||||||
|             true 0)) |             :else 0)) | ||||||
|     (throw (Exception. "No map passed?")))) |     (throw (Exception. "No map passed?")))) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -308,7 +308,7 @@ | ||||||
|   "Return a world like this `world`, but merge the values from this `cell` with |   "Return a world like this `world`, but merge the values from this `cell` with | ||||||
|    those from the cell in the world with the same co-ordinates" |    those from the cell in the world with the same co-ordinates" | ||||||
|   [world cell] |   [world cell] | ||||||
|   (if (in-bounds world (:x cell) (:y cell)) |   (if (in-bounds? world (:x cell) (:y cell)) | ||||||
|     (map-world world |     (map-world world | ||||||
|                #(if |                #(if | ||||||
|                   (and |                   (and | ||||||
|  |  | ||||||
|  | @ -56,7 +56,7 @@ | ||||||
|   * `height` y coordinate of the next cell to be created." |   * `height` y coordinate of the next cell to be created." | ||||||
|   [index width height] |   [index width height] | ||||||
|   (cond (= index width) nil |   (cond (= index width) nil | ||||||
|     true (cons (make-cell index height) |     :else (cons (make-cell index height) | ||||||
|                (make-world-row (inc index) width height)))) |                (make-world-row (inc index) width height)))) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -69,7 +69,7 @@ | ||||||
|   * `height` total height of the matrix, in cells." |   * `height` total height of the matrix, in cells." | ||||||
|   [index width height] |   [index width height] | ||||||
|   (cond (= index height) nil |   (cond (= index height) nil | ||||||
|     true (cons (apply vector (make-world-row 0 width index)) |     :else (cons (apply vector (make-world-row 0 width index)) | ||||||
|                (make-world-rows (inc index) width height)))) |                (make-world-rows (inc index) width height)))) | ||||||
| 
 | 
 | ||||||
| (defn make-world | (defn make-world | ||||||
|  | @ -87,7 +87,7 @@ | ||||||
|   [cell limit] |   [cell limit] | ||||||
|   (let [s (:state cell)] |   (let [s (:state cell)] | ||||||
|     (cond (> (count (str s)) limit) (subs s 0 limit) |     (cond (> (count (str s)) limit) (subs s 0 limit) | ||||||
|       true s))) |       :else s))) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| (defn format-cell | (defn format-cell | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue