   (let [[negamax-value move] (negamax-inner state Double/NEGATIVE_INFINITY Double/POSITIVE_INFINITY timeout is-first-player 1 grid-width grid-height)]
     (if is-first-player
       move
-      (second (negamax-inner state)))))
+      (second (negamax-inner state Double/NEGATIVE_INFINITY Double/POSITIVE_INFINITY timeout is-first-player 1 grid-width grid-height)))))
 
 (defn -getNextMove
   "Gets the next best move"

    [(get-value-for-state state) []]
    (if (= max-depth 0)
      [(heuristic grid-width grid-height is-first-player state) []]
      (let [best Double/NEGATIVE_INFINITY]
        (loop [successor-states (generate-successor-states state grid-width grid-height is-first-player)
               new-alpha alpha
               new-beta beta]
          (if (empty? successor-states)
            (if (empty? (state true))
              [best [(long (/ grid-width 2)) (long (/ grid-height 2))]]
              [best []])
            (let [[successor-state _] (first successor-states)
                  [v-temp _] (negamax-inner successor-state (- new-beta) (- new-alpha) timeout (not is-first-player) (- max-depth 1) grid-width grid-height)
                  v (- v-temp)]
              (if (> v best)
                (let [new-best v]
                  (if (> new-best new-alpha)
                    (let [ret-alpha best]
                      (if (>= ret-alpha new-beta)
                        [new-best (first (clojure.set/difference successor-state state))]
                        (recur (rest successor-states) ret-alpha new-beta)))
                    (recur (rest successor-states) new-alpha new-beta)))
                (recur (rest successor-states) new-alpha new-beta)))))))))

(defn negamax
  ""

  ""
  [state grid-width grid-height is-first-player]
  (let [possible-moves (gen-children-points state grid-width grid-height)
        possible-states (set (map #(generate-world-from-position state % is-first-player) possible-moves))]
    (reduce #(assoc %1 %2 (heuristic grid-width grid-height is-first-player %2))
            (clojure.data.priority-map/priority-map)
            possible-states)))
