Just my 2 cents: sometimes these algorithms are easier to implement by constructing an infinite lazy trees of all the game, and then independently writing a few strategy to explore the tree.
John Hughes gives an example of that in Section 5 of "Why functional programming matters", that can be found on the internet. If it can be done that way, this is nice has it separates the tree construction, which is about the rule of the game, from the evaluation/exploration part. On Fri, Aug 20, 2010 at 9:47 PM, Ben Mabey <b...@benmabey.com> wrote: > On 8/20/10 12:21 PM, Alan wrote: >> >> Thanks, I'll look into it. I know minimax ought to be easy to do but >> it's a bit of a weak spot of mine - I can never seem to get it right, >> and the poorish debug support in clojure, even with slime/swank, >> doesn't make it easier. >> >> I'm reasonably confident minimax/alpha-beta is right for me, since >> it's not really an AI - I'm writing a "solution finder" which works >> with perfect knowledge and has all the time it needs (though obviously >> faster is better) to find the optimal solution. If anyone's >> interested, it's specifically a double-dummy solver for the card game >> bridge. > > I stumbled across this implementation of alpha-beta in clojure on github: > > http://github.com/rcrr/reversi/blob/master/strategies.clj#L251-282 > > It is a re-write of PAIP's CL version. (I didn't write it- just found it.) > > -Ben > >> On Aug 16, 3:08 am, Mike Anderson<mike.r.anderson...@gmail.com> >> wrote: >>> >>> On Aug 13, 5:33 pm, Alan<a...@malloys.org> wrote: >>> >>>> Funny you should mention this - I was about to post a question about >>>> my own game when I saw your article. My issue is, I assume someone has >>>> written minimax and/or alpha-beta pruning in Clojure (or a java >>>> library that's easy to interop with). My case is slightly different in >>>> that the turn order is not fixes - sometimes player X goes twice in a >>>> row - but it ought to be pretty simple to plug into a standard AI >>>> library. Does anyone know where I can find such a thing? >>> >>> I don't actually use alpha-beta: I opted to spend the effort to >>> develop >>> a decent evaluation function and then do some simple local >>> optimisation >>> on the gradient of said function. >>> >>> My reasoning was that alpha-beta usually works best when the >>> branching >>> factor is low and the evaluation function pretty cheap to calculate, >>> sadly my situation was pretty much the reverse :-) >>> >>> For your case it may be different. Two turns in a row works fine for >>> minimax or alpha-beta with a little tweaking (although it is likely >>> to >>> cut your search depth). >>> >>> Be warned though - my experience is that it's rather hard to find an >>> AI library that will just "plug in" nicely to your code. Most of the >>> challenge in AI tends to be around special cases, embedding "expert" >>> knowledge and heuristics, plumbing in the right data representations >>> etc. >>> The search algorithm itself is usually the easy bit.... >>> >>> If you're after resources, there's a decent free online book on AI in >>> Java that might be useful, has lots of code examples that should be >>> pretty easy to convert to Clojure: >>> >>> http://www.scribd.com/doc/6995538/Practical-AI-in-Java > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en