Fixing bugs in generated flow rules.
This commit is contained in:
parent
3829bd97a9
commit
74fbd2efe9
|
@ -32,6 +32,6 @@
|
||||||
"RANGE := WITHIN SPACE VALUE;"
|
"RANGE := WITHIN SPACE VALUE;"
|
||||||
"STATE := SYMBOL;"
|
"STATE := SYMBOL;"
|
||||||
"TARGET := STATE | STATE SPACE RANGE;"
|
"TARGET := STATE | STATE SPACE RANGE;"
|
||||||
"TO-HOW := TO | TO-EACH | TO-FIRST;"
|
"TO-HOW := TO | TO-EACH | TO-FIRST;" ;; SHARED BETWEEN
|
||||||
"TO-EACH := TO SPACE EACH | TO SPACE ALL;"
|
"TO-EACH := TO SPACE EACH | TO SPACE ALL;"
|
||||||
"TO-FIRST := TO SPACE FIRST"]))
|
"TO-FIRST := TO SPACE FIRST"]))
|
||||||
|
|
|
@ -302,7 +302,11 @@
|
||||||
;; macros are in scope here.
|
;; macros are in scope here.
|
||||||
(macroexpand
|
(macroexpand
|
||||||
(list 'fn ['cell 'world]
|
(list 'fn ['cell 'world]
|
||||||
(list 'when (list 'and source (list 'pos? (list 'cell property)))
|
(list 'when
|
||||||
|
(list 'and
|
||||||
|
source
|
||||||
|
(list 'pos?
|
||||||
|
(list 'mw-engine.utils/get-num 'cell property)))
|
||||||
(list 'map
|
(list 'map
|
||||||
(list 'fn ['d]
|
(list 'fn ['d]
|
||||||
{:source (list 'select-keys 'cell [:x :y])
|
{:source (list 'select-keys 'cell [:x :y])
|
||||||
|
@ -322,14 +326,18 @@
|
||||||
;; TODO :EXPRESSION still needed
|
;; TODO :EXPRESSION still needed
|
||||||
:NUMBER (generate q-clause)
|
:NUMBER (generate q-clause)
|
||||||
:PERCENTAGE (let [multiplier (/ (generate (second q-clause)) 100)]
|
:PERCENTAGE (let [multiplier (/ (generate (second q-clause)) 100)]
|
||||||
(list '* multiplier (list property 'cell)))
|
(list '* multiplier
|
||||||
|
(list 'mw-engine.utils/get-num 'cell property)))
|
||||||
:SIMPLE-EXPRESSION (if (= (count q-clause) 2)
|
:SIMPLE-EXPRESSION (if (= (count q-clause) 2)
|
||||||
(generate-quantity-accessor (second q-clause) property)
|
(generate-quantity-accessor (second q-clause)
|
||||||
|
property)
|
||||||
(throw (ex-info
|
(throw (ex-info
|
||||||
(format "Cannot yet handle q-clause of form: `%s`" q-clause)
|
(format
|
||||||
|
"Cannot yet handle q-clause of form: `%s`"
|
||||||
|
q-clause)
|
||||||
{:clause q-clause
|
{:clause q-clause
|
||||||
:property property})))
|
:property property})))
|
||||||
:SOME (list 'rand (list property 'cell))
|
:SOME (list 'rand (list 'mw-engine.utils/get-num 'cell property))
|
||||||
(throw (ex-info
|
(throw (ex-info
|
||||||
(format "Unexpected QUANTITY type: `%s`" (first q-clause))
|
(format "Unexpected QUANTITY type: `%s`" (first q-clause))
|
||||||
{:clause q-clause
|
{:clause q-clause
|
||||||
|
@ -353,14 +361,19 @@
|
||||||
(list 'let ['candidates
|
(list 'let ['candidates
|
||||||
(generate-target-state-filter
|
(generate-target-state-filter
|
||||||
clause
|
clause
|
||||||
(list 'mw-engine.utils/get-neighbours 'world 'cell distance))]
|
(list 'mw-engine.utils/get-neighbours
|
||||||
|
'world 'cell distance))]
|
||||||
(if dc
|
(if dc
|
||||||
(list 'list
|
(list 'list
|
||||||
(let [determiner (first (second (search-tree dc :DETERMINER)))
|
(let [determiner (first
|
||||||
|
(second
|
||||||
|
(search-tree dc :DETERMINER)))
|
||||||
prop (generate (nth dc 2))]
|
prop (generate (nth dc 2))]
|
||||||
(case determiner
|
(case determiner
|
||||||
:LEAST (list 'mw-engine.utils/get-least-cell 'candidates prop)
|
:LEAST (list 'mw-engine.utils/get-least-cell
|
||||||
:MOST (list 'mw-engine.utils/get-most-cell 'candidates prop))))
|
'candidates prop)
|
||||||
|
:MOST (list 'mw-engine.utils/get-most-cell
|
||||||
|
'candidates prop))))
|
||||||
'candidates))))
|
'candidates))))
|
||||||
|
|
||||||
(defn generate-flow
|
(defn generate-flow
|
||||||
|
|
Loading…
Reference in a new issue