Okay, I admit. I was over confident in saying to my mentor that implementing minimax in Clojure would be straightforward, perhaps naively I thought that the language was well suited for minimax.
Unsurprisingly, minimax in Clojure is challenging.
I spent yesterday trying to break it down into it’s smallest parts. I began firstly by test driving the score method. As this was a component of the Minimax that I could test drive and what I most understood.
(defn score [board player] (let [winner (board-logic/winner board)] (if (= winner player) 10 (if (board-logic/game-drawn? board) 0 -10))))
The next part wasn’t so easy, I’m not sure if I’m missing something or if I am still thinking in a OOP style way to solving this problem. Maybe it is a really easy if you think in a functional way, maybe not.
I’m going to carry on working on it tomorrow, hopefully gain some insight.