clojush.translate

delete-prev-paren-pair

(delete-prev-paren-pair prog)

Deletes the last closed paren pair from prog, which may be a partial program.

population-translate-plush-to-push

(population-translate-plush-to-push pop-agents {:keys [use-single-thread], :as argmap})

Converts the population of Plush genomes into Push programs.

translate-plush-genome-to-push-program

(translate-plush-genome-to-push-program {:keys [genome program]} {:keys [max-points], :as argmap})

Takes as input an individual (or map) containing a Plush genome (:genome) and translates it to the correct Push program with balanced parens. The linear Plush genome is made up of a list of instruction maps, each including an :instruction key as well as other epigenetic marker keys. As the linear Plush genome is traversed, each instruction that requires parens will push :close and/or :close-open onto the paren-stack, and will also put an open paren after it in the program. For example, an instruction that requires 3 paren groupings will push :close, then :close-open, then :close-open. When a positive number is encountered in the :close key of the instruction map, it is set to num-parens-here during the next recur. This indicates the number of parens to put here, if need is indicated on the paren-stack. If the top item of the paren-stack is :close, a close paren will be inserted. If the top item is :close-open, a close paren followed by an open paren will be inserted. If the end of the program is reached but parens are still needed (as indicated by the paren-stack), parens are added until the paren-stack is empty. Instruction maps that have :silence set to true will be ignored entirely.