Mars rover kata in Clojure

Last month, while in a Barcelona Software Craftmanship meetup, we went through the famous Mars Rover Kata. We started to code it in Javascript, which I have not worked with for ages so I added to my task list to try it in Clojure.

Now that is more or less finished, I am happy with it. Especially, since it forced me to think in a TDD way which I don’t find always easy. Getting more familiar with speclj was also a good byproduct of the time spent.

The code is in this github repo and a REPL session using it can be seen below:

(require 
  '[marsrover.grid :as grid] 
  '[marsrover.robot :as robot] 
  '[marsrover.core :refer :all])

;; 10x10 grid with obstacle at 1,1. Robot moves beside it.
(let [grid (grid/make-grid [10 10] [[1 1]]) 
      robot (robot/make-robot [0 0] \n grid)] 
  (tell-robot robot "fffrf"))
;;{:robot {:pos [1 3], :dir \e, :grid {:dim [10 10], :obstacles {[1 1] true}}}, :status :ok}

;; 10x10 grid with obstacle at 1,1. Robot impacts ith it.
(let [grid (grid/make-grid [10 10] [[1 1]]) 
      robot (robot/make-robot [0 0] \n grid)] 
  (tell-robot robot "rflfff"))
;;{:robot {:pos [1 0], :dir \n, :grid {:dim [10 10], :obstacles {[1 1] true}}}, :status :obstacle-found, :where [1 1]}