Hi Nicolas,
as you can see I couldn't sleep without trying out your snippet! :-)
Unfortunately, your code gives me a:
NullPointerException
clojure.lang.Numbers.ops (Numbers.java:942)
clojure.lang.Numbers.gt (Numbers.java:227)
clojure.core/max-key (core.clj:4434)
clojure.core/max-key (core.clj:4436)
clojure.core/apply (core.clj:604)
Clondie24.lib.search3/best-move (search3.clj:67)
Clondie24.lib.search3/test-speed (search3.clj:70)
Clondie24.games.chess/-main (chess.clj:150)
Clondie24.games.chess/eval16482 (NO_SOURCE_FILE:1)
clojure.lang.Compiler.eval (Compiler.java:6512)
clojure.lang.Compiler.eval (Compiler.java:6478)
clojure.core/eval (core.clj:2801)
The only thing I did was to plug in some real functions for evaluation
(returns a number) and generation of next-boards (returnsa seq of
MoveAndBoard) and also propagate an extra parameter (direction) ,which
I'm negating after each level, so I know who I'm scoring at the bottom!
Did you have any of this when you run yours?
Jim
On 19/08/12 21:32, nicolas.o...@gmail.com wrote:
A correction for the wrong part:
(defn my-max ([x y] (if (nil? x) y
(if (nil? y) x
(max x y))))
([] nil))
(defn tree-value ^double [tree evaluate ^long depth]
(let [children (:children tree)]
(if (or (zero? depth))
(evaluate (:board tree))
(let [^double res
(r/reduce my-max
(r/map
#(- (tree-value (:tree %) evaluate (dec depth)))
children))]
(if (nil? res) (evaluate (:board tree))
res)))))
--
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