I'd like break out of the below loop and return the best-min-move when line 10 evaluates to true. I've looked at the output with print statements and when line 10 does evaluate to true, it finds the data that I'm looking for but continues to recur. In Clojure is there a way to stop the loop when a statement evaluates to true? Or should I be using something other than a loop recur?
(defn minimax [board max-mark min-mark depth best-score]
(loop [board board
max-mark max-mark
min-mark min-mark
depth depth
best-score best-score]
(if (= best-score (best-min-score board max-mark min-mark depth))
(best-max-move board max-mark min-mark depth)
(do
(if (= best-score (best-min-score board min-mark max-mark depth))
(best-min-move board min-mark max-mark depth)
(recur
(b/make-move-on board (remaining-scores board max-mark min-mark depth) max-mark)
min-mark
max-mark
(inc depth)
(dec best-score)))))))
ifdoesn't work as it should? If your condition is true, yourifevaluates to the first s-expression of the two. If that is the code you're executing, it can't recur unless the condition is false.make-move-oncallminimax? Is it possible that what you're taking to be looping within one instance ofminimaxinvolves a different call tominimax? It would be a good idea to double-check thatbest-min-scoreis working correctly, too. I sometimes discover that I reversed a Boolean test by accident. (Also, it wouldn't hurt to simplify the code--maybe that would make it easier to see what's going wrong. You don't need thedo, and you could pullmin-markandmax-markout of theloopparameters by adding aletat the top of the definition ofminimax. Maybe usecond.)