Lab 4 generate minefield minesweeper

46 views
Skip to first unread message

Johan Tobin

unread,
Dec 11, 2015, 11:01:51 AM12/11/15
to 2015 Functional Programming TDA452/ DIT 142
Hello, 
We are currently doing a minesweeper in the course TDA452 and we have a question, since we ran into trouble. 

The question is can you generate a field which you then play on during the game? We can generate a field, but we dont know how to use it after the generation. 

This is how we generate the field.

instance Arbitrary Minefield where
  arbitrary =
    do rows <- sequence [ sequence [ cell | j <- [1..10] ] | i <- [1..10] ]
       return (initField (Minefield rows))

Thanks in advance

Grégoire Détrez

unread,
Dec 14, 2015, 3:14:05 AM12/14/15
to chalmer...@googlegroups.com
Hello Johan,

You can use generate :: Gen a -> IO a to generate an arbitrary value.
http://hackage.haskell.org/package/QuickCheck-2.8.1/docs/Test-QuickCheck.html#v:generate

Grégoire
> --
> You received this message because you are subscribed to the Google Groups "2015 Functional Programming TDA452/ DIT 142" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to chalmers-fp-1...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


--
Grégoire Détrez
signature.asc
Reply all
Reply to author
Forward
0 new messages