                      (s/coll-of ::tile :max-count (* board-size board-size))
                      #(apply distinct? (map ::position %))))
 
+(def default-board-gen (gen/such-that #(< 0 (count %) board-size) (s/gen ::game-board)))
+
 (s/def ::app-db (s/keys :req [::game-board]))
 
 (defn initial-state
   []
-  (gen/generate (s/gen ::app-db)))
+  {::game-board (gen/generate default-board-gen)})
+
 
 (defonce app-db (reagent/atom (initial-state)))
 

(defn tile-comparator
  [direction]
  (fn [tile1 tile2]
    (let [[x1 y1] (::position tile1)
          [x2 y2] (::position tile2)]
      (case direction
        ::up (compare y1 y2)
        ::down (compare y2 y1)

        :args (s/cat :direction ::direction :board ::game-board)
        :ret ::tiles-to-move)

(defn- vertical?
  [direction]
  #{::up ::down})

(defn- horizontal?
  [direction]
  #{::left ::right})

(defn group-by-direction
  [direction board]
  (cond
    (vertical? direction) (group-by  #(-> % ::position ::x) board)
    (horizontal? direction) (group-by #(-> % ::position ::y) board)))

(s/fdef join-first
        :args (s/cat :tiles (s/and (s/coll-of ::tile) #(< 0 (count %))))
