my_course_of_action=:switch games_to_play=100000 success=0 games_to_play.times do doors=[0,0,0] doors[rand(3)]=1 my_choice=rand(3) monty_possible_doors=[0,1,2]-[my_choice]-[doors.index(1)] monty_choice=monty_possible_doors[rand(monty_possible_doors.length)] remaining_choice=3-my_choice-monty_choice case (my_course_of_action) when :switch: new_choice=remaining_choice when :stay: new_choice=my_choice when :random: new_choice=(rand(2)==0) ? (my_choice) : (remaining_choice) end success+=1 if doors[new_choice]==1 end puts "Win/Play ratio for course of action of #{my_course_of_action}: #{success.to_f / games_to_play}"