       (update-in [(:active state)] #(conj % move))
       (assoc :active (if (= :p1 (:active state)) :p2 :p1))))
 
-
-(defn add-node [move state]
-  (if-let [result (check-terminal state)]
-    {:state state :terminal true :visited 0 :score 0 :result result}
-    {:state state :unvisited (set (valid-moves state)) :action move :visited 0 :score 0 :children {}})
-  )
-
-(add-node nil (init))
-
-(def tree {:visited 0
-           :score 0
-           :moves #{}
-           :children {:move
-                       {:visited 0 :score 0 :children {}}}})
-
 (defn uct [node parent-visits]
   (if (zero? (:visited node))
     Long/MAX_VALUE

(defn update-node [root path result]
  (-> root
      (update-in [path :visited] inc)
      (update-in [path :score] #(+ % result))))

(defn backprop [root path result]
  (if-not (empty? path)
    (recur (update-node root path result)
           (subvec path 0 (dec (count path)))
           result)
    (update-node root [] result)))

(subvec [1 2 3] 0 (dec (count [1 2 3])))


      :else (let [child-path (best-child mtcs path)]
              (recur mtcs child-path)))))

(time (loop [root {[] {:visited 0 :score 0 :player 1 :state (init)}}]
   (process root [])))

(defn simulate [state]
