 (ns search.graphs.push
   "Adds the ability to use the push interpreter to evaluate your programs."
   (:require [plumbing.graph :as g]
-            [plumbing.core :refer [fnk]]
+            [plumbing.core :refer [fnk defnk]]
             [push.core :as push]
             [schema.core :as s]
             [push.interpreter.templates.one-with-everything :refer [make-everything-interpreter]]

            [search.utils :refer [defnk-fn] :as utils]
            [search.graphs.seq :as seq]))

(defnk-fn ->instruction :- s/Any
  "Returns a random push instruction from those defined in the `push-interpreter`
   and the bindings names.`"
  [interpreter]
  []
  (let [bindings (push/binding-names interpreter)]
    (-> {(push/known-instructions interpreter) 5
         bindings (if (empty? bindings) 0 1)}
      clojure.data.generators/weighted
      clojure.data.generators/rand-nth)))

   push instruction. It also provides `:push-evaluate`."
  (g/graph
    :step-limit (utils/v->fnk 500)
    :interpreter interpreter
    :instructions instructions
    :push-evaluate evaluate
    :->gene ->instruction
    seq/graph))
