Skip to content
Permalink
Browse files

Random directions from a seed

  • Loading branch information...
magopian committed Aug 8, 2019
1 parent 5d3630d commit e2ef1bf8d5356371735546fafdf42e88d7781aaa
Showing with 9 additions and 3 deletions.
  1. +9 −3 src/Main.elm
@@ -18,6 +18,7 @@ type alias Model =
, leftPaddleMovement : PaddleMovement
, gameStatus : GameStatus
, score : Score
, seed : Random.Seed
}


@@ -96,6 +97,7 @@ init _ =
{ rightPlayerScore = 0
, leftPlayerScore = 0
}
, seed = Random.initialSeed 42
}
, Cmd.none
)
@@ -165,12 +167,16 @@ update msg model =
Process.sleep 500
|> Task.perform alwaysRestartGame

( randomDirection, _ ) =
Random.initialSeed 42
( randomDirection, newSeed ) =
model.seed
|> Random.step (Random.int 0 100)
|> Debug.log "Random direction: "
in
( { model | gameStatus = Winner player, score = updatedScore }
( { model
| gameStatus = Winner player
, score = updatedScore
, seed = newSeed
}
, sleepCmd
)

0 comments on commit e2ef1bf

Please sign in to comment.
You can’t perform that action at this time.