Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- genBoardSpec :: Int -> Rand BoardSpec
- genBoardSpec b = return (nub (createFirstBoard b))
- createFirstBoard :: Int -> BoardSpec
- createFirstBoard i = createBoardFromPoints xs ys bs
- where (xs, ys) = splitAt (i * i) (createRandomPoints i)
- bs = createRandomBools i
- createBoardFromPoints :: [Int] -> [Int] -> [Bool] -> BoardSpec
- createBoardFromPoints (x:xs) (y:ys) (b:bs) = ((x, y), b) : (createBoardFromPoints xs ys bs)
- createBoardFromPoints [] [] [] = []
- createRandomPoints a = runRand 1 (replicateM (2 * (a * a)) (uniform [0..(a - 1)]))
- createRandomBools a = convertToBool (runRand 1 (replicateM (a * a) (uniform [0..1])))
- convertToBool :: [Int] -> [Bool]
- convertToBool (x:xs)
- | x == 1 = True : convertToBool xs
- | x == 0 = False : convertToBool xs
- convertToBool [] = []
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement