I'm working on a project that I have thought about for a while and made some initial steps in haskell. I'd like to implement a monte carlo tree search algorithm for an ai to play the board game go. The algorithm involves updating a large tree with the results of random simulations from positions at the leaf nodes of the tree. An explaination is here: http://en.wikipedia.org/wiki/Monte-Carlo_tree_search
I've just learned about rose trees and zippers in haskell (zippers seem really cool), but I can't help but wonder if this would be easier in a language that allows mutation and doesn't involve passing around a random seed to do random numbers. I'm mostly doing exploratory programming to see if I can find a better algorithm. Is haskell good for this purpose or would something like common lisp be better? or maybe just plain c or c++ since speed may be a factor later?submitted by CajunJohn
[link] [11 comments]
So, I decided to do a school project in Haskell! It involves plotting, as school projects often do (in engineering and physics, anyways). And now I feel stupid. Not for wanting to use Haskell - doing the actual simulation to get the data I want to plot was ridiculously easy! Thanks Haskell! But now, to plot it...
At first, I tried using Chart. But I can't understand how to use that... are the examples on the wiki current? Because those just give me errors. I would need a full, working example to understand how to do it, because the documentation is just confusing me.
Then, I installed gnuplot and the gnuplot bindings for Haskell. What I'm trying to do now is:>import Graphics.Gnuplot.Simple >plotList  [(2,10),(3,15),(4,14),(5,19)]
Obviously doing this in ghci. This brings up two problems:
The plotList command seems to be recognized and all (yay), and ghci swallows it up. It then does nothing. No window is opened or anything.
This is not an expression - would I put this in do notation in my source file? I don't get it.
Help, /r/haskell! I'm feeling dumb. I might be dumb. But I also like Haskell, and it would feel like defeat to call python to plot the thing...
EDIT: yeeesh, now Chart isn't producing errors anymore. It's not producing anything, similar to gnuplot. I used the example https://github.com/timbod7/haskell-chart/wiki/example%202submitted by Krexington_III
[link] [14 comments]
I'm trying to write code to get the standard deviation of a set of numbers in ghci. Here's what I've got so far:squared x = x*x let mean nums = (sum nums) / (length nums) offsets nums = [(x - mean nums) | x <- nums] sum_of_offsets nums = nums //Placeholder std_dev nums = sqrt (sum_of_offsets nums / (length nums - 1))
Here's what GHCi gives:parse error (possibly incorrect indentation or mismatched brackets)
I think it has to do with the way I'm iterating through that list of "nums". Can anyone give me a hand?submitted by PoisonRain
[link] [16 comments]