私が読んだ確率によると、ドアを切り替えると、正しいドアを選択する可能性が最大 66% になるはずです。以下のこのコードは私が思いついたものであり、私が期待している 66% ではなく、約 50% の勝利を吐き出します。ここで私が間違っている場所についての助けをいただければ幸いです。
for (int count = 0; count < 10000; count++)
{
// Chooses which door contains DAT GRAND PRIZE YO.
wDoor = rand() % 3 + 1;
// AI Contestants Door choice
aiDoor = rand() % 3 + 1;
// Using oldChoice to ensure same door isn't picked.
oldChoice = aiDoor;
// Used in determining what door to open.
openedDoor = aiDoor;
// "Open" a door that is not the winning door and not the door chosen by player.
do
{
openedDoor = rand() % 3 + 1;
}while (openedDoor != wDoor && openedDoor != aiDoor);
// Select new door between the remaining two.
do
{
aiDoor = rand() % 3 + 1;
}while (aiDoor != oldChoice && aiDoor != openedDoor);
// Increment win counter if new door is correct.
if (aiDoor == wDoor)
{
chooseAgain++;
}
}