diff --git a/src/mw_parser/declarative.clj b/src/mw_parser/declarative.clj index 410b247..81325fd 100644 --- a/src/mw_parser/declarative.clj +++ b/src/mw_parser/declarative.clj @@ -112,13 +112,3 @@ ([rule-text] (compile-rule rule-text false))) - -(ps/simplify - (parse-rule - "if more than 2 neighbours have altitude equal to 11 then state should be beach")) - -(pg/generate - (ps/simplify - (parse-rule - "if more than 2 neighbours have altitude equal to 11 then state should be beach"))) - diff --git a/src/mw_parser/simplify.clj b/src/mw_parser/simplify.clj index 1a5e8c6..843ed80 100644 --- a/src/mw_parser/simplify.clj +++ b/src/mw_parser/simplify.clj @@ -59,23 +59,18 @@ (if (coll? tree) (case (first tree) - ;; 'all' isn't actually the same as 'eight', because cells at the edges of the world have - ;; fewer than eight neighbours; but it's a simplifying (ha!) assumption for now." - ;; TODO: fix this so it actually works. - :ALL [:COMPARATIVE '= 8] :ACTION (simplify-second-of-two tree) - :ACTIONS (simplify-second-of-two tree) + :ACTIONS (cons (first tree) (simplify (rest tree))) + :CHANCE-IN nil :COMPARATIVE (simplify-second-of-two tree) :CONDITION (simplify-second-of-two tree) :CONDITIONS (simplify-second-of-two tree) :EXPRESSION (simplify-second-of-two tree) - :NONE [:COMPARATIVE '= 0] - :NUMBER tree :PROPERTY (simplify-second-of-two tree) - :QUALIFIER (simplify-qualifier tree) - :QUANTIFIER (simplify-quantifier tree) - :SOME [:COMPARATIVE '> 0] + :PROPERTY-CONDITION-OR-EXPRESSION (simplify-second-of-two tree) :SPACE nil + :THEN nil + :AND nil :VALUE (simplify-second-of-two tree) (remove nil? (map simplify tree))) tree))