Minimax in Clojure part 1

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.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s