Skip to content

Instantly share code, notes, and snippets.

@beala
Created March 24, 2023 06:56
Show Gist options
  • Save beala/02029db2d50adee897919034802ab348 to your computer and use it in GitHub Desktop.
Save beala/02029db2d50adee897919034802ab348 to your computer and use it in GitHub Desktop.
ChatGPT Plugins Monty Fall Monte Carlo
{
"input": "
(* Define a function to simulate one round of the game *)
simulateRound[] := Module[{doors, carPosition, initialChoice, revealedDoor, switchChoice},
doors = {\"Goat\", \"Goat\", \"Goat\"};
carPosition = RandomInteger[{1, 3}];
doors[[carPosition]] = \"Car\";
initialChoice = RandomInteger[{1, 3}];
revealedDoor = RandomChoice[DeleteCases[Range[3], {initialChoice, carPosition}]];
switchChoice = DeleteCases[Range[3], {initialChoice, revealedDoor}][[1]];
{doors[[initialChoice]], doors[[switchChoice]]}
];
(* Simulate 10000 rounds of the game *)
numRounds = 10000;
results = Table[simulateRound[], {numRounds}];
(* Calculate the win rates for staying and switching *)
stayWinRate = N[Count[results, {\"Car\", _}]/numRounds];
switchWinRate = N[Count[results, {_, \"Car\"}]/numRounds];
{stayWinRate, switchWinRate}
"
}
@beala
Copy link
Author

beala commented Mar 24, 2023

The model appears to consistently produce code that uses DeleteCases[Range[3], {initialChoice, carPosition}] incorrectly. I believe it should be DeleteCases[Range[3], initialChoice|carPosition]. The original code does not delete any of the cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment