   (assert is-color? color)
   (assert is-board? board)
   (let [ opponent-king-piece (if (= color :white) "k" "K")
-        _ (println "1")
+        debug false
         king-location (some #(if (= opponent-king-piece (second %)) 
                                (first %))
                             board)
-        _ (println "1")
-        ]
+        ]
+    (when debug
+      (println "in checkmated?")
+        (println (moves board color)))
     (some #(when (= (second %) king-location) true) (moves board color))
 
     ))
 
 ;;;;;;;;;;;;;; TESTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defn test-rook-captures2[]
+  (is (= 
+       #{[[1 0] [0 0]]} 
+        (rook-captures (string->board (str "BR\n"
+                                           "kR")) [1 0])))
+  )
+;; (test-rook-captures2)
+(defn test-rook-moves[]
+  (let [board (string->board (join "\n" 
+                                   ["  "
+                                    " R"
+                                    "  "]))
+        ]
+    (println (rook-non-captures board [1 1])))
+  )
 (defn test-checkmated[]
+  ;; white checkmates black
   (assert (not (checkmated? (string->board "BR\nkR") :white)))
   (assert (checkmated? (string->board "BR\n k") :white))
   )

    (map #(move->algebraic-notation board %) 
         (moves starting-board :black))))
(defn run-tests[]
  (test-rook-moves)
  (test-pawn-moves)
  (test-checkmated)
  (test-rook-captures)
(test-board->string)
  (test-starting-moves)

          (recur  (next locs-to-test))))
      )))

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

(defn bishop-captures[board location]
  (ranging-captures board location bishop-rules)
)

;; (test-rook-moves)

;; (test-rook-captures)

;; z will range from 1 to infinity


(defn look-for-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 
  ;; 1. off board 
  ;; 2. piece found 
  ;; Returns set of zero or more moves found
  ;;
  (when debug 
    (println "entering look-for-capture-in-direction, direction-fn is" direction-fn))
  (let [[x y] location
        color (get-color (get board location))
        ]
    (when debug
      (println x y)
     (println (board->string board))
    (println location))
    (loop [locs-to-test (for [z (drop 1(range))]  ;; lazy seq of locations to test
                          (direction-fn x y z))
           accum []
           ]
      (let [loc-to-test (first locs-to-test)]
        (when false
          (println "processing " loc-to-test))
        (cond 
          (off-board? loc-to-test)
          accum
          (occupied? board loc-to-test)
           accum
          true  ;; location is empty
          (recur  (next locs-to-test) (conj accum loc-to-test) )))
      )))

;; (f a b) -> a


;; Pieces with a long range


(defn ranging-non-captures[board location rules]
  {:pre  [(vector? rules)]
   :post [(set? %)]
   }
  "return set of locations for moves that the piece can make according to the rules which is an array of functions"
  (assert (is-ranging? (get board location)))
  (assert (is-board? board))
  (assert (valid-location? location))
  (let [color (get-color (get board location))
        [x y] location
        ]
    (set (remove nil?
                 (map
                   (partial ranging-capture-in-direction board location)
                   rules 
                   )))))


(defn rook-captures[board location]
  {:pre  []
   :post [(set? %)]
   }
  (ranging-captures board location rook-rules))

(defn rook-non-captures[board location]
  {:pre  []
   :post [(set? %)]
   }
  (ranging-non-captures board location rook-rules))


; (test-bishop-captures)
(defn test-bishop-captures[]
  (let [board (string->board (join "\n" 

                                   ["       "
                                    "     p"
                                    "  p   "
                                    "   B   b"
                                    "  pnQ  "
                                    "          "]))
        ]
    (when debug
      (println (board->string board))
      )
    (is (= 
          #{[2 1] [5 4] [2 3]}
          (bishop-captures board [3 2])))
    ))
;;(def debug false)
(defn test-rook-non-captures[]
  (let [board (string->board (join "\n" 
                                   ["   p    "
                                    "  pR   b"
                                    "  pQ    "
                                    "        "]))
        ]
    (when debug
     (println (board->string board))
      )
    (is (= 
          #{[2 2] [3 3] [7 2]}
          (rook-non-captures board [3 2])))
    ))
(test-rook-non-captures)
(defn test-rook-captures[]
  (let [board (string->board (join "\n" 
                                   ["   p  "
