-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
109 lines (97 loc) · 3.39 KB
/
main.py
File metadata and controls
109 lines (97 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import random
def configure_simulation():
# you can configure the simulation here:
# you can pick door 1,2,3
picked_door=1
# you can use the mode "stay" if you want to keep your choice
# or you can choose "change" if you want to change your choice after the door is opened
mode="stay"
# you can difine, how many rounds should be simulated
rounds = 1000
simulation_round(picked_door,mode,rounds)
def simulation_round(picked_door,mode,rounds):
correct = 0
times_door_1_was_correct = 0
times_door_2_was_correct = 0
times_door_3_was_correct = 0
for i in range(rounds):
doors = [1, 2, 3]
correct_door = random.choice(doors)
if correct_door == 1:
times_door_1_was_correct = times_door_1_was_correct+1
if correct_door == 2:
times_door_2_was_correct = times_door_2_was_correct + 1
if correct_door == 3:
times_door_3_was_correct = times_door_3_was_correct+1
if picked_door == 1:
if correct_door == 1:
possible_doors =[2, 3]
open_door = random.choice(possible_doors)
if mode == "stay":
correct = correct+1
else:
pass
if correct_door == 2:
open_door = 3
if mode == "change":
correct = correct+1
else:
pass
if correct_door == 3:
open_door = 2
if mode == "change":
correct = correct+1
if picked_door == 2:
if correct_door == 2:
possible_doors =[1, 3]
open_door = random.choice(possible_doors)
if mode == "stay":
correct = correct+1
else:
pass
if correct_door == 1:
open_door = 3
if mode == "change":
correct = correct+1
else:
pass
if correct_door == 3:
open_door = 1
if mode == "change":
correct = correct+1
if picked_door == 3:
if correct_door == 3:
possible_doors =[1, 2]
open_door = random.choice(possible_doors)
if mode == "stay":
correct = correct+1
else:
pass
if correct_door == 1:
open_door = 2
if mode == "change":
correct = correct+1
else:
pass
if correct_door == 2:
open_door = 1
if mode == "change":
correct = correct+1
print("original picked door:", picked_door)
print("correct door:", correct_door)
print("mode:", mode)
print("opened door:", open_door)
print("correct guesses:", correct)
print("\n \n")
print("statistics:")
print("rounds:", rounds)
print("correct guesses:",correct)
print("mode:", mode)
print("correct doors:")
print("door 1 was correct:", times_door_1_was_correct)
print("door 2 was correct:", times_door_2_was_correct)
print("door 3 was correct:", times_door_3_was_correct)
def MHsimulation():
configure_simulation();
if __name__ == '__main__':
MHsimulation();