Greetings ! 

I'm attempting to implement Othello in Clojure and I've run into a problem 
when actually running my game loop. On the first run through, everything 
works as expected, the black player can make their move, the board is 
updated and everything is awesome. However when the program loops and it is 
the white players turn, after they have entered their move the program 
crashes with the stacktrace at the bottom of this message.. 

I seem to be having a brain fuzz moment because I can't see how much 
application would complete happily the first time through without error, 
then when the nearly identical steps are taken for turn two, I seem to have 
a type error. The code is 
here: 
https://github.com/mankyKitty/clojure-othello/blob/master/src/othello/core.clj 
. I know it's not great, work in progress! :)

>From what I can tell from the ST the error is from my "squares-to-flip" 
function but I'm unable to reproduce the results in the repl, and I've yet 
to reach the point where I'm adding a print on every second line (though 
I'm close). 

I had originally deduced it was the 'merge' call on the times I would have 
an empty second argument, hence the 'if' in there but that doesn't appear 
to have helped at all.

I assume it's something I've not anticipated or accounted for with respect 
to my loop, but I'm not quite sure.. 

Thanks in advance !

--- STACKTRACE ---

Exception in thread "main" java.lang.ClassCastException: 
clojure.lang.PersistentHashMap cannot be cast to java.util.Map$Entry
at clojure.lang.APersistentMap.cons(APersistentMap.java:42)
at clojure.lang.RT.conj(RT.java:562)
at clojure.core$conj.invoke(core.clj:83)
at clojure.core$merge$fn__4275.invoke(core.clj:2684)
at clojure.core$reduce1.invoke(core.clj:896)
at clojure.core$reduce1.invoke(core.clj:887)
at clojure.core$merge.doInvoke(core.clj:2684)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at othello.core$squares_to_flip.invoke(core.clj:186)
at othello.core$game_loop.invoke(core.clj:213)
at othello.core$_main.doInvoke(core.clj:225)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.Var.invoke(Var.java:411)
at user$eval5$fn__7.invoke(form-init5981136443637675542.clj:1)
at user$eval5.invoke(form-init5981136443637675542.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6619)
at clojure.lang.Compiler.eval(Compiler.java:6609)
at clojure.lang.Compiler.load(Compiler.java:7064)
at clojure.lang.Compiler.loadFile(Compiler.java:7020)
at clojure.main$load_script.invoke(main.clj:294)
at clojure.main$init_opt.invoke(main.clj:299)
at clojure.main$initialize.invoke(main.clj:327)
at clojure.main$null_opt.invoke(main.clj:362)
at clojure.main$main.doInvoke(main.clj:440)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:419)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to