CS计算机代考程序代写 choose(s::Switch, d::Doors) = otherdoor(revealed(d), chosen(d))

choose(s::Switch, d::Doors) = otherdoor(revealed(d), chosen(d))
choose(s::Stay, d::Doors) = chosen(d)
choose(s::DoesntMatter, d::Doors) = rand( (chosen(d), otherdoor( revealed(d), chosen(d))) )

function reveal(d::Doors)
(prize(d) != chosen(d)) ? otherdoor(prize(d), chosen(d)) : otherdoor(chosen(d))
end

update!(sim::MonteHall, state, event::Choice1) = ( state.chosen = randomdoor() )
update!(sim::MonteHall, state, event::Reveal) = ( state.revealed = reveal(state) )
update!(sim::MonteHall, state, event::Choice2) = ( state.chosen = choose( strategy(sim), state) )