              @*phaser-border*)
   (pc-ai-put-piece @*border* @*phaser-border*)
   (let [no-put-piece-ai-and-player?
-        (show-possible-grid-on-pborder @*border* @*phaser-border*)]
-    (when (or (rcore/end-game? @*border*) (nil? no-put-piece-ai-and-player?))
+        (nil? (show-possible-grid-on-pborder @*border* @*phaser-border*))]
+    (when (or (rcore/end-game? @*border*) no-put-piece-ai-and-player?)
       (let [winner (rcore/who-win? @*border*)]
         (if (= winner *default-player-use-piece*)
           (js/alert "you are winner!")
           (js/alert "you are loser!")))))
-
   (let [result-count (rcore/grid-count @*border*)]
-    (set! (.-text (.-pieceCountText game))
+    (set! (.-text (.-pieceCountText *game*))
           (str "black-piece: " (result-count rcore/*black-piece*)
                "\nwhite-piece: " (result-count rcore/*white-piece*)
-               )
-          )
-    )
-  )
+               ))))
 
 (defn create-pieces [piece-name game]
   (let [piece-color (grid-name->rcore-grid piece-name)]

    (.image loader "possible-grid" "assets/gray-grid.png")
    (.image loader "restart-button" "assets/restart-button.png")))


;; (defn update [game]
;;   )


(def ^export game (js/Phaser.Game. 905 605 js/Phaser.AUTO "game_div"))

(defn ^export start []
  (.add (.-state game) "main"
        (clj->js {:preload preload
                  :create create

                  }))
  (.start (.-state game) "main"))

(start *game*)
