On 10/03/13 12:32, Gary Verhaegen wrote:
Not all of your application can be purely functional, because it
inevitably needs to interact with the outside world at some point.
yes that is true...however, I often find that my first impression of what the functional boundaries are, is not necessarily the correct one...for example, when I started writing my board-game engine, I was pretty sure that when the time comes to code chess I'd need side-effects to achieve castling and en-passant moves (because they depend on other pieces and their state). At the time I was pretty happy introducing limited side effects.

Having finished my engine ,and after having coded fully functional implementations of chess, checkers and tic-tac-toe I can confirm that I did not need side effects anywhere other than showing stuff on screen and talking to the disk (for saving-loading games). Absolutely nothing! Both castling and en-passant can be coded with the help of meta-data and a specialised mover (a higher order fn) for such occasions...nothing more - nothing less! it wasn't immediately apparent how - but it was indeed possible and in fact very elegant!

of course, now you will ask : 'how is performance in such a purely functional and cpu-intensive game?' Well, I don't have a good answer for that until I manage to add pruning to my parallel minimax. at the moment and after numerous optimizations, I can do an exhaustive search down to level 4 usually in less than 8sec with an average branching factor of 26. In the best case, pruning can cut this down in half which sounds pretty impressive if I ever manage it!

Jim

--
--
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