 
 ;; -----------------------------------------
 
-(defn- min-max-step
+(defn- minimax-step
+  "One stage of the minimax algorithm:
+   * Apply the maximizing or mininizing step to all transitions of the turn
+   * Evaluate the lower level using the on-transition function"
   [ai turn on-transition
    & {:keys [max-fn min-fn]
       :or {max-fn max, min-fn min}}]

;; -----------------------------------------

(defn- leaf-score
  [ai {:keys [scores] :as turn}]
  (min-max-step ai turn
    (fn [_ transition]
      (eval-score ai (scores/update-scores scores transition))
      )))

(defn- tree-score
  [ai turn depth]
  (if (zero? depth)
    (leaf-score ai turn)
    (min-max-step ai turn
      (fn [_ transition]
        (tree-score ai
          (turn/next-turn turn transition)

      )))

(defn- focus-human-player?
  "High level AI to decude whether the AI ally against the human player"
  [{:keys [blue red green] :as scores}]
  (let [human-score (* 1.1 blue)]
    (and (< red human-score) (< green human-score))))
