type Door = Door of Prize
type Choice = Stay | Change
let rand = new Random(DateTime.UtcNow.Ticks |> int)
[| Door Car; Door Goat; Door Goat |]
|> Array.sortBy (fun _ -> rand.NextDouble())
let reveal (doors : Door[]) choice =
|> Seq.filter ((<>) choice)
|> Seq.filter (fun idx -> doors.[idx] = Door Goat)
let play strategy (doors : Door[]) =
let choice = rand.Next(doors.Length)
let revealed = reveal doors choice
match strategy choice revealed with
|> Seq.filter (fun idx ->
idx <> choice && idx <> revealed)
if doors.[choice] = Door Car then Win else Lose
let strategyB _ _ = Change
if rand.NextDouble() > 0.5 then Stay else Change
let getResults strategy =
newGame() |> play strategy |> ((=) Win))
let resultsA = getResults strategyA
let resultsB = getResults strategyB
let resultsC = getResults strategyC
printfn "Stay : %d/1000 wins | Change : %d/1000 wins | Random : %d/1000 wins"
resultsA resultsB resultsC