[Haskell-beginners] nim
Deniz Dogan
deniz.a.m.dogan at gmail.com
Tue Oct 27 08:49:10 EDT 2009
2009/10/27 John Moore <john.moore54 at gmail.com>:
> Hi getting there with nimprogram well have it working in different areas.
>
> initNim :: IO [Int]
> initNim = replicateM 3 $ randomRIO (1,10)--- This get the random numbers
> data PileName = A | B | C deriving (Show, Eq, Read)
>
> main = do
> putStrLn "Which pile A, B, or C ?"
> x <- readLn
> putStrLn "How many stones?"
> y <- readLn
> let z = typeOfMove (x,y) [9,9,9]-- cannot get the random numbers here
> putStrLn . show $ z
If I understand this part of your problem correctly, try this:
main = do
putStrLn "Which pile A, B, or C ?"
x <- readLn
putStrLn "How many stones?"
y <- readLn
nums <- initNim -- Get the three random numbers
let z = typeOfMove (x,y) nums -- Pass them along
putStrLn . show $ z
The same effect can be achieved in a number of different ways, but
this should be fairly clear. (I haven't tested this by the way, so
excuse any typos and bugs.)
--
Deniz Dogan
More information about the Beginners
mailing list