From 29d9c2e549e634e55448bb219a8ddbbdf666f3bb Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Sat, 4 May 2024 14:36:19 +0100 Subject: [PATCH] Allow zero coordinates in cells (d'oh!) --- src/cljc/mw_engine/world.clj | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cljc/mw_engine/world.clj b/src/cljc/mw_engine/world.clj index 00b4024..e21a316 100644 --- a/src/cljc/mw_engine/world.clj +++ b/src/cljc/mw_engine/world.clj @@ -38,19 +38,20 @@ (defn cell? "Return `true` if `obj` is a cell, as understood by MicroWorld, else `false`." [obj] - (and (map? obj) ;; it's a map... + (let [x (:x obj) + y (:y obj)] + (and (map? obj) ;; it's a map... ;; TODO: it's worth checking (and this does not) that cells have the ;; right co-ordinates! - (pos-int? (:x obj)) ;; with an x co-ordinate... - (pos-int? (:y obj)) ;; and a y co-ordinate... - (keyword? (:state obj)))) ;; and a state which is a keyword. + (or (zero? x)(pos-int? x)) ;; with an x co-ordinate... + (or (zero? y)(pos-int? y)) ;; and a y co-ordinate... + (keyword? (:state obj))))) ;; and a state which is a keyword. (defn world? "Return `true` if `obj` is a world, as understood by MicroWorld, else `false`." [obj] (and (coll? obj) ;; it's a collection... (every? coll? obj) ;; of collections... - (= 1 (count (set (map count obj)))) ;; all of which are the same length... (every? cell? (flatten obj)))) ;; and every element of each of those is a cell. (defmacro make-cell