   (case msg
     :new-game (swap! app-state assoc-in [:games] (new-game))
     :restart (swap! app-state update-in [:games] #(take-last 1 %))
-    :undo (swap! app-state update-in [:games] cancel-last-move #{:red :green})))
+    :undo (swap! app-state update-in [:games] cancel-last-move is-ai?)))
 
 (defn start-game-loop
   "Manage transitions between player moves, ai moves, and generic game events"

(def board (reaction (turn/get-board @game)))
(def scores (reaction (turn/get-scores @game)))
(def current-player (reaction (turn/current-player @game)))
(def ai-players (reaction (get-in @game [:ai-players])))

(defn is-ai? [player] (contains? @ai-players player))


;; -----------------------------------------
;; GAME LOOP
;; -----------------------------------------

(def ai-move-delay 1000)

(defn play-game-turn! [move]
  (swap! app-state update-in [:games] play-turn move))

(defn- handle-ai! []
  (let [ai-algo (get @ai-players @current-player)
        move (ai-algo @game @current-player)]
    (play-game-turn! move)))

(defn- handle-game-event!



;; -----------------------------------------
;; GAME STATE
;; -----------------------------------------

(defn new-game []
  (list (turn/new-init-turn)))

(defn get-turn
  [game-turns]
