 (defn build-all-lines-from-state
   [state grid-w grid-h is-first-player]
 
-    {:max (gen-lines (state is-first-player) grid-w grid-h)
-    :min (gen-lines (state (not is-first-player)) grid-w grid-h)}
+  {:max (gen-lines (state is-first-player) grid-w grid-h)
+   :min (gen-lines (state (not is-first-player)) grid-w grid-h)}
 
   ;{:max (gen-lines (state true) grid-w grid-h)
   ; :min (gen-lines (state false) grid-w grid-h)}
 
-;
+  ;
   )
 
 (defn get-value-for-point

          ;(prn prev-left-direct-streak prev-left-streak-type prev-right-streak-type prev-right-direct-streak)
          ;(prn prev-left-is-dead prev-right-is-dead)
          (empty? left-part)
            (and prev-left-is-dead prev-right-is-dead))
      (if (and (not= prev-left-streak-type prev-right-streak-type)
               (not= prev-left-streak-type :wall)
               (not= prev-right-streak-type :wall))
        ; Types differents
        (let [opl (if (= :min prev-left-streak-type) + +)
              opr (if (= :min prev-right-streak-type) + +)]
        (+
          (opl
            (cond
             ;(prn prev-left-partial-streak-count prev-right-partial-streak-count) -3332
             (or (= :wall prev-left-streak-type) (= :empty prev-left-streak-type)) 0

             (= 4 prev-left-direct-streak) Double/POSITIVE_INFINITY
             (and
               (= 3 prev-left-direct-streak)
               (< 0 prev-left-partial-streak-count)
               (< 0 prev-right-partial-streak-count)
               (= 0 prev-right-direct-streak)) 50000

             ;(and
             ;  (= 3 prev-left-direct-streak)
             ;  (< 0 prev-left-partial-streak-count)
             ;  (or (= 0 prev-right-direct-streak)
             ;      (and (< 0 prev-right-direct-streak)
             ;           (not= prev-left-streak-type prev-right-streak-type)))) 50000

             (<= 4 (+ prev-left-streak-count prev-left-partial-streak-count)) (+ prev-left-direct-streak prev-left-streak-count)
             :else 0))

          (opr
            (cond
             ;(prn prev-left-partial-streak-count prev-right-partial-streak-count) -333
             (or (= :wall prev-right-streak-type) (= :empty prev-right-streak-type)) 0
             (= 4 prev-right-direct-streak) Double/POSITIVE_INFINITY
             (and
               (= 3 prev-right-direct-streak)
               (< 0 prev-right-partial-streak-count)
               (< 0 prev-left-partial-streak-count)
               (= 0 prev-left-direct-streak)) 50000

             ;(and
             ;  (= 3 prev-right-direct-streak)
             ;  (< 0 prev-right-partial-streak-count)
             ;  (or (= 0 prev-left-direct-streak)
             ;      (and (< 0 prev-left-direct-streak)
             ;           (not= prev-left-streak-type prev-right-streak-type)))) 50000 ;

             (<= 4 (+ prev-right-streak-count prev-right-partial-streak-count)) (+ prev-right-direct-streak prev-right-streak-count)
             :else 0))
           ))
        ; Types identiques ou mur
        (let [op (if (or (= :min prev-left-streak-type) (= :min prev-right-streak-type)) + +)]
          (op (cond
          (= :wall prev-left-streak-type prev-right-streak-type) 0;
          (= 4 (+ prev-left-direct-streak prev-right-direct-streak)) (if (or
                                                                           (= prev-left-streak-type :max)
                                                                           (= prev-left-streak-type :min)
                                                                           (= prev-right-streak-type :max)
                                                                           (= prev-right-streak-type :min))
                                                                       Double/POSITIVE_INFINITY
                                                                       0);
          (and (= 3 (+ prev-left-direct-streak prev-right-direct-streak))
               (>= prev-right-partial-streak-count 1)
               (>= prev-left-partial-streak-count 1);
          )
          50000
          (<= 5 (+ prev-left-direct-streak prev-right-direct-streak)) 0

          :else (+ prev-left-direct-streak
                   prev-left-streak-count
                   prev-right-direct-streak
                   prev-right-streak-count)))))

      (let [left (first left-part)
            right (first right-part)

                (if (and (= (best :best-value) Double/POSITIVE_INFINITY)
                         (< child-best-value (best :best-value)))
                  best
                  (if (> child-best-value (best :best-value))
                    (let [best {:best-value child-best-value :best-move child-best-move :who-win? who-win?}]
                      (if (> (best :best-value) alpha)
                        (let [alpha (best :best-value)]
                          (if (and (>= alpha beta)
                                   (or (not= child-best-value Double/POSITIVE_INFINITY)
                                       (not= who-win? nil)))
                            best
                            (recur (rest sucessors) best alpha)))
                        (recur (rest sucessors) best alpha)))
                    (recur (rest sucessors) best alpha)))))))))))

(defn negamax
  ""
