 ;; -----------------------------------------
 
 (defn- handle-ai []
-  (let [ai-algo (get players-ai-algorithms @current-player)
+  (let [ai-algo (get @ai-players @current-player)
         move (ai-algo @app-state @current-player)]
     (swap! app-state play-move move)))
 

(def board (reagent/cursor app-state [:board]))
(def scores (reagent/cursor app-state [:scores]))
(def current-player (reagent/cursor app-state [:player]))
(def end-of-game (reaction (nil? @current-player)))

(def players-ai-algorithms
  {:red best-move
   :green best-move})

(defn is-human?
  [player]
  (not (contains? players-ai-algorithms player)))


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

   * The immediate gain
   * The worse immediate lost afterwards"
  {:pre [(player? player)]}
  [cells-strength game player]
  (let [moves (get-in game [:moves player])
        others (remove #{player} players)]
    (first
      (fast-max-key
        (fn [[m converted :as move]]
          (let [new-game (play-move game m)
                diff-score (move-strength cells-strength identity move)
                losses (map #(worst-immediate-loss cells-strength new-game % player) others)]
            (- diff-score (apply max losses))))
        moves))
    ))
