             clojure.set
             clojure.data.priority-map
             [clojure.math.combinatorics :as combo])
-  (:gen-class))
-
-(def width-heuristic-calculation 5)
+  (:gen-class)
+  (:import (java.util.concurrent TimeoutException)))
+
+
 (def directors {:h  (map #(do [%1 0]) (range -5 6))
                 :v  (map #(do [0 %1]) (range -5 6))
                 :d1 (map #(do [%1 %1]) (range -5 6))
                 :d2 (map #(do [%1 (- %1)]) (range -5 6))})
-
-(defn gen-heuristic-dictionary
-  "Generate the dictionnary of heuristics values"
-  [depth]
-  (apply merge (for [x '(:min :max :wall :empty)]           ;
-                 (if (= depth 0)
-                   {x 0}
-                   {x (gen-heuristic-dictionary (dec depth))}))))
-
-(defn calc-positive-heuristic
-  ""
-  [list-to-check player opponent]
-
-  (if
-      (and
-        (= (.indexOf list-to-check opponent) -1)
-        (= (.indexOf list-to-check :wall) -1))
-    (let [count-in-list (reduce #(+ %1 (if (= %2 player) 1 0)) 0 list-to-check)]
-      (if (< count-in-list 3)
-        (Math/pow 2 count-in-list)
-        1000))
-    0))
-
-(defn calc-heuristic
-  ""
-  [list-to-check player opponent]
-
-  (+
-    (calc-positive-heuristic list-to-check player opponent))
-
-
-  (- (calc-positive-heuristic list-to-check player opponent)
-     (calc-positive-heuristic (reverse list-to-check) opponent player)))
-
-(defn fill-heuristics-dict
-  ""
-  []
-  (reduce #(assoc-in %1 %2 (calc-heuristic %2 :max :min))
-          (gen-heuristic-dictionary width-heuristic-calculation)
-          (apply clojure.math.combinatorics/cartesian-product
-                 (for [_ (range width-heuristic-calculation)] [:min :max :wall :empty]))))
-
-(defn generate-valid-keys
-  ""
-  [depth]
-  (let [half-keys (filter
-                    #(loop [keys %
-                            wall-done false]
-                      (if (empty? keys)
-                        true
-                        (if (and (not wall-done) (not (= (first keys) :wall)))
-                          (recur (rest keys) true)
-                          (if (and wall-done (= (first keys) :wall))
-                            false
-                            (recur (rest keys) wall-done)))))
-                    (combo/selections [:min :max :empty :wall] (/ depth 2)))]
-    (for [k1 half-keys k2 half-keys] (concat k1 (reverse k2)))))
-
-(def heuristic-dict (fill-heuristics-dict))
-
-(defn assoc-in!
-  "Associates a value in a nested associative structure, where ks is a
-  sequence of keys and v is the new value and returns a new nested structure.
-  If any levels do not exist, hash-maps will be created."
-  {:added  "1.0"
-   :static true}
-  [m [k & ks] v]
-  (if ks
-    (assoc! m k (assoc-in! (get m k) ks v))
-    (assoc! m k v)))
 
 (defn compute-path-value
   [path]


    ; Block on the timeout channel
    (async/<!! timeout-chan)

    (let [{decision :best-move} (async/<!! ret-chan)]
      (swap! got-time? (fn [lastval] false))
      (prn "sent:" decision)
      (into [] decision))))
          (and prev-left-is-dead prev-right-is-dead))
      (if (not= prev-left-streak-type prev-right-streak-type)
        ; Types differents

          (+
              (cond
                (not= :max prev-left-streak-type) 0
                (= 4 prev-left-direct-streak) Double/POSITIVE_INFINITY
                (and
                  (= 3 prev-left-direct-streak)
