Always make probability of close equal to probability that instruction set adds an open

This commit is contained in:
Lee Spector 2024-01-06 16:39:11 -05:00
parent 126b358643
commit f0424979b5

View File

@ -51,7 +51,6 @@
"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)))
@ -61,11 +60,7 @@
(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