 (s/def ::x ::within-board-size)
 (s/def ::y ::within-board-size)
 (s/def ::direction directions)
-(s/def ::position (s/tuple ::within-board-size ::within-board-size))
+(s/def ::position (s/keys :req [::x ::y]))
 (s/def ::value (s/with-gen pos-int? (fn [] (s/gen (s/and pos-int? #(< 0 % 10))))))
 (s/def ::tile (s/keys :req [::position ::value]))
 

(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 %))))
