Always make probability of close equal to probability that instruction set adds an open
This commit is contained in:
parent
126b358643
commit
f0424979b5
@ -51,21 +51,16 @@
|
|||||||
"Returns a random instruction from a supplied pool of instructions, evaluating
|
"Returns a random instruction from a supplied pool of instructions, evaluating
|
||||||
ERC-producing functions to a constant literal."
|
ERC-producing functions to a constant literal."
|
||||||
[instructions argmap]
|
[instructions argmap]
|
||||||
(if (:auto-close argmap)
|
(let [instructions (remove #(= % 'close) instructions)
|
||||||
(let [instructions (remove #(= % 'close) instructions)
|
p (/ (apply + (filter identity
|
||||||
p (/ (apply + (filter identity
|
(map #(get parentheses/opens %) instructions)))
|
||||||
(map #(get parentheses/opens %) instructions)))
|
(count instructions))]
|
||||||
(count instructions))]
|
(if (< (rand) p)
|
||||||
(if (< (rand) p)
|
'close
|
||||||
'close
|
(let [instruction (rand-nth instructions)]
|
||||||
(let [instruction (rand-nth instructions)]
|
(if (fn? instruction)
|
||||||
(if (fn? instruction)
|
(instruction)
|
||||||
(instruction)
|
instruction)))))
|
||||||
instruction))))
|
|
||||||
(let [instruction (rand-nth instructions)]
|
|
||||||
(if (fn? instruction)
|
|
||||||
(instruction)
|
|
||||||
instruction))))
|
|
||||||
|
|
||||||
(defn count-points
|
(defn count-points
|
||||||
"Returns the number of points in tree, where each atom and each pair of parentheses
|
"Returns the number of points in tree, where each atom and each pair of parentheses
|
||||||
|
Loading…
x
Reference in New Issue
Block a user