I am trying to make a version of the Voltorb game from Pokemon Gold and Silver in Haskell. Now for generation of the board, I want to have a list of (l,r,v) triplets where l is the line, r is the row and v is the value of the field.
Values l and r are implemented with list comprehension since they should be the same every time. As for v though I can't find an option to implement it so that it is 0,1,2 or 3 "randomly" (I know that Haskell is purely functional and there is no true randomness, that's part of the reason why I struggle with this).
If anyone could help with this I'd be very grateful. If you could also maybe give a short explanation as to why that solution works, that would help me a lot.
My current implementation of l and r:
field n = [(l,r,v) | l <- [0..n], r <- [0..n]]
Aucun commentaire:
Enregistrer un commentaire