2 static int choice1, choice2;
4 static int trials[3], points[3];
7 static void init_doors(void)
12 for (i=0;i<3;i++) doors[i] = 0;
17 static void choose1(void)
19 choice1 = random() % 3;
22 static void reveal(void)
25 revealed = random() % 3;
26 } while (revealed == choice1 || doors[revealed] == 1);
29 static void choose2(void)
36 for (choice2 = 0; choice2 < 3; choice2++) {
37 if (choice2 != choice1 && choice2 != revealed) break;
42 choice2 = random() % 3;
43 } while (revealed == choice2);
48 static void score(void)
51 points[strategy] += doors[choice2];
54 int main(int argc, char *argv[])
60 while (trials[0] < 100000) {
61 strategy = random() % 3;
72 printf("strategy %d scored %d%%\n", i, (int)(0.5 + 100*points[i]/trials[i]));