Skip to content

Commit

Permalink
Merge pull request #1 from julianoks/patch-2
Browse files Browse the repository at this point in the history
If exceeds max points, translates to empty program
  • Loading branch information
julianoks committed Jun 20, 2016
2 parents 845d71f + 72466de commit 2e0b45b
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/clojush/translate.clj
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,9 @@
(rest gn)
(get (first gn) :close 0) ; The number of close parens to put after this instruction; if :close isn't in instruction map, default to zero
new-paren-stack)))))]
(if (<= (count-points translated-program) max-points)
translated-program
(do
(println "WARNING: A translated program was bigger than max-points. Recuring translation after removing the last instruction in genome.")
(println " genome length:" (count genome))
(println " points in program:" (count-points translated-program))
(println " :max-points:" max-points)
(recur {:genome (butlast genome)}
argmap))))))
(if (> (count-points translated-program) max-points)
'() ; Translates to an empty programs if program exceeds max-points
translated-program))))

(defn population-translate-plush-to-push
"Converts the population of Plush genomes into Push programs."
Expand Down

0 comments on commit 2e0b45b

Please sign in to comment.