Using the "Febuary 2000" version of Hugs, the following program

        import Random

        rollDie :: IO Int
        rollDie = randomRIO (1, 6)

        rollTwoDice :: IO (Int, Int)
        rollTwoDice = do
                r1 <- rollDie
                r2 <- rollDie
                return (r1, r2)

        main = do
                print "Sum of two dice: "
                (r1, r2) <- rollTwoDice
                print (r1 + r2)

when run with `runhugs' always outputs `12'.  That's not very random!
Hugs ought to initialize the random number generator with an unpredictable
value, e.g. by using the time of day (or something even less predictable).

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.

Reply via email to