Permalink
Browse files

IO randomness

  • Loading branch information...
1 parent fc3cd5d commit 9694b6f15acd395542ad41c2e07fb4bc61fe42e0 Mihai Maruseac committed May 16, 2011
Showing with 4 additions and 2 deletions.
  1. +4 −2 Maze/GUI.hs
View
@@ -8,7 +8,7 @@ import Control.Monad.State (when, runState, foldM_)
import Data.IORef (IORef, readIORef, writeIORef, newIORef)
import Data.List ((\\), elemIndex, sort)
import Data.Maybe (fromJust)
-import System.Random (randomR, StdGen, mkStdGen)
+import System.Random (randomR, StdGen, mkStdGen, newStdGen, randomIO)
import Graphics.Rendering.Cairo
import Graphics.UI.Gtk hiding (Point)
@@ -470,7 +470,9 @@ onNew ref dw gl csl fl = do
-- 1. Present config dialog and get options
(popSize, mRate, mSize) <- showConfigDialog
-- 2. Get maze
- let (maze, g) = runState (genMaze (mSize, mSize)) (mkStdGen 42)
+ gen <- newStdGen
+ seed <- randomIO
+ let (maze, g) = runState (genMaze (mSize, mSize)) (mkStdGen seed)
-- 3. Fill ListStore from IORef
r <- readIORef ref
fillListStore (model r) popSize

0 comments on commit 9694b6f

Please sign in to comment.