   [piece x y board]
   (every? #(coord-fits? % x y board) (:coords piece)))
 
+(defn get-drop-pos
+  "Get the future drop position of the given piece."
+  [piece x y board]
+  (let [collide? (fn [cy] (not (piece-fits? piece x cy board)))
+        cy (first (filter collide? (iterate inc y)))]
+    (dec cy)))
+
 ;;------------------------------------------------------------
 ;; PAINTING (for showing the game on a canvas)
 ;;------------------------------------------------------------

           (= code (:down key-codes))  (do (try-move!  0  1) (.preventDefault e))
           (= code (:left key-codes))  (do (try-move! -1  0) (.preventDefault e))
           (= code (:right key-codes)) (do (try-move!  1  0) (.preventDefault e))
           (= code (:up key-codes))    (do (try-rotate!)     (.preventDefault e)))))))

;;------------------------------------------------------------

    (if (piece-fits? new-piece x y board)
      (swap! state assoc :piece new-piece))))

(defn hard-drop!
  "Hard drop the current piece."
  []
  (let [[x y] (:position @state)
        piece (:piece @state)
        board (:board @state)
        ny (get-drop-pos piece x y board)]
    (swap! state assoc :position [x ny])
    (lock-piece!)))

(defn add-key-events
  "Add all the key inputs."
  []
