From f0424979b50b08fe8a7dd8990ef2fa95cdb78b68 Mon Sep 17 00:00:00 2001 From: Lee Spector Date: Sat, 6 Jan 2024 16:39:11 -0500 Subject: [PATCH] Always make probability of close equal to probability that instruction set adds an open --- src/propeller/utils.cljc | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/propeller/utils.cljc b/src/propeller/utils.cljc index 181f4cd..332079c 100755 --- a/src/propeller/utils.cljc +++ b/src/propeller/utils.cljc @@ -51,21 +51,16 @@ "Returns a random instruction from a supplied pool of instructions, evaluating ERC-producing functions to a constant literal." [instructions argmap] - (if (:auto-close argmap) - (let [instructions (remove #(= % 'close) instructions) - p (/ (apply + (filter identity - (map #(get parentheses/opens %) instructions))) - (count instructions))] - (if (< (rand) p) - 'close - (let [instruction (rand-nth instructions)] - (if (fn? instruction) - (instruction) - instruction)))) - (let [instruction (rand-nth instructions)] - (if (fn? instruction) - (instruction) - instruction)))) + (let [instructions (remove #(= % 'close) instructions) + p (/ (apply + (filter identity + (map #(get parentheses/opens %) instructions))) + (count instructions))] + (if (< (rand) p) + 'close + (let [instruction (rand-nth instructions)] + (if (fn? instruction) + (instruction) + instruction))))) (defn count-points "Returns the number of points in tree, where each atom and each pair of parentheses