     (black-piece? piece)
     ))
 
+(def debug false)
+;;(println (checkmated? starting-board :white))
 (defn moves[board white-or-black]
-  (remove nil? (mapcat (fn[[loc piece :as z]]
-                         (case piece
-                           ("p" "P")
+  (when debug
+    (println "entering moves")
+    (println "board is" board)
+    (println "white-or-black" white-or-black)
+    )
+  (mapcat 
+                 (fn[[loc piece :as z]]
+                   (let [
+                         debug true
+                         piece-info (get pieces-info 
+                                         (keyword (clojure.string/lower-case piece)))]
+                     (when debug
+                       (println "piece-info is" piece-info)
+                       (println "piece is" piece))
+                     (assert piece-info)
+                     (cond (:ranging piece-info)
+                           (ranging-moves board loc) 
+                           (is-pawn? piece)
                            (pawn-moves board loc) 
-                           ("b" "B")
-                           (bishop-moves board loc)
-                           nil 
-                           )) (filter (fn[[_ piece]]
-                                        (is-color?  piece white-or-black)) board)
-                       ))) 
-
+                           true
+                          nil 
+                           ))) (filter (fn[[_ piece]]
+                                         (is-color?  piece white-or-black)) board)
+          ))
+;;(use 'clojure.stacktrace)
+;; (print-stack-trace *e)
 
 (defn -main
   "I don't do a whole lot ... yet."


(defn bishop-sw[x y z] [ (- x z) (- y z)])

(def bishop-rules [bishop-ne bishop-nw bishop-se bishop-sw])
(def rook-rules [rook-right rook-left rook-up rook-down])


(def is-ranging? #{"q" "Q" "b" "B" "r" "R"})



(defn ranging-captures[board location rules]
  {:pre  []
   }
  "return set of locations for captures that the rook or bishop at location can make"
  (when true (println "entering ranging-captures"))
  (assert (is-ranging? (get board location)))
  (assert (is-board? board))
  (assert (valid-location? location))
  (let [color (get-color (get board location))
        [x y] location
        ]
    (map (fn[loc2] (vector location loc2))
         (remove nil?
      (map (fn[loc-to-capture] (vector location loc-to-capture))
           (remove nil?
                   (map
                     (partial ranging-capture-in-direction board location)
                     rules 
                     )))))))


;; z will range from 1 to infinity


(defn ranging-non-capture-in-direction[board location direction-fn]
  ;; location is the location of the friendly piece in question 
  ;; direction-fn generate locations to test using a function applied to the range 1..infinity
  ;; Finished when 
