Use
http://package.elm-lang.org/packages/elm-community/random-extra/1.0.0/Random-Array#shuffle
Use something like:
type Msg = ReplaceCards (List IndexedCard) | ...
init : List IndexedCard -> (Model, Cmd Msg)
init cards =
([], Random.generate ReplaceCards (Random.Array.shuffle cards))
On Wed, Jun 22, 2016 at 6:35 AM, Juan Martin Buireo <[email protected]>
wrote:
> Hi, I have developed a memotest in Elm 0.17.
>
> My Model is the following:
> type alias Model = List IndexedCard
> type alias IndexedCard = { id : Int, model : Card.Model }
>
> where Card.Model is a module where I modeled a single card.
>
> So now the game is working but the cards of the memotest always appear in
> the same order.
>
> I initialize each card:
> card1 = IndexedCard 1 (Card.init "images/blastoise.jpg")
> card2 = IndexedCard 2 (Card.init "images/charmeleon.jpg")
> card3 = IndexedCard 3 (Card.init "images/raichu.jpg")
> card4 = IndexedCard 4 (Card.init "images/diglett.jpg")
> card5 = IndexedCard 5 (Card.init "images/venusaur.jpg")
> card6 = IndexedCard 6 (Card.init "images/mewto.jpg")
>
> and then cards = [card1, card2, card3, card4, card5, card6]
>
> So i pass this to the init in the App.program.
>
> My question is, how do I create this list random so that the cards appear
> in different order each time?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
There is NO FATE, we are the creators.
blog: http://damoc.ro/
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.