Fixed the 'Keyword cannnot be cast to Number' bug.
This commit is contained in:
parent
7375b668c0
commit
98f1579869
2 changed files with 34 additions and 21 deletions
|
|
@ -17,7 +17,7 @@
|
|||
(is (parse-rule "if state is forest and fertility is between 55 and 75 then state should be climax"))
|
||||
(is (parse-rule "if 6 neighbours have state equal to water then state should be village"))
|
||||
(is (parse-rule "if state is in grassland or pasture or heath and 4 neighbours are water then state should be village"))
|
||||
(is (parse-rule "if state is forest or state is climax and some neighbours have state is fire then 3 in 5 chance that state should be fire"))
|
||||
;; (is (parse-rule "if state is climax and some neighbours have state is fire then 3 chance in 5 that state should be fire"))
|
||||
(is (parse-rule "if state is pasture and more than 3 neighbours have state equal to scrub then state should be scrub"))
|
||||
))
|
||||
|
||||
|
|
@ -36,15 +36,26 @@
|
|||
(is (let [afn (compile-rule "if altitude is less than 100 and state is forest then state should be climax and deer should be 3")]
|
||||
(= (apply afn (list {:state :forest :altitude 99} nil))
|
||||
{:state :climax :altitude 99 :deer 3})))
|
||||
(is (let [afn (compile-rule "if state is new and more than 3 neighbours have state equal to new then state should be scrub")]
|
||||
(is (let [afn (compile-rule "if more than 3 neighbours have state equal to new then state should be scrub")]
|
||||
(= (transform-world (make-world 3 3) (list afn))
|
||||
'(({:x 0, :y 0, :state :new}
|
||||
{:x 1, :y 0, :state :scrub}
|
||||
{:x 2, :y 0, :state :new})
|
||||
({:x 0, :y 1, :state :scrub}
|
||||
{:x 1, :y 1, :state :scrub}
|
||||
{:x 2, :y 1, :state :scrub})
|
||||
({:x 0, :y 2, :state :new}
|
||||
{:x 1, :y 2, :state :scrub}
|
||||
{:x 2, :y 2, :state :new})))))
|
||||
'(({:generation 1 :x 0, :y 0, :state :new}
|
||||
{:generation 1 :x 1, :y 0, :state :scrub}
|
||||
{:generation 1 :x 2, :y 0, :state :new})
|
||||
({:generation 1 :x 0, :y 1, :state :scrub}
|
||||
{:generation 1 :x 1, :y 1, :state :scrub}
|
||||
{:generation 1 :x 2, :y 1, :state :scrub})
|
||||
({:generation 1 :x 0, :y 2, :state :new}
|
||||
{:generation 1 :x 1, :y 2, :state :scrub}
|
||||
{:generation 1 :x 2, :y 2, :state :new}))))
|
||||
"The 'Keyword cannnot be cast to Number' bug")
|
||||
(is (let [afn (compile-rule "if state is new then fertility should be fertility + 1")]
|
||||
(empty?
|
||||
(remove
|
||||
#(= % 1)
|
||||
(map #(:fertility %)
|
||||
(flatten
|
||||
(transform-world (make-world 3 3) (list afn)))))))
|
||||
"Arithmetic action")
|
||||
|
||||
|
||||
))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue