Data update

This commit is contained in:
Ingy dot Net 2024-04-19 16:56:29 -07:00
parent 0df55f9f24
commit aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions

View file

@ -1,8 +1,8 @@
def Games = 10000; \number of games simulated
int Game, Wins;
def NGames = 10000; \number of games simulated
int Game, NWins;
include c:\cxpl\codes;
proc Play(Switch); \Play one game
func int IsGameWon(Switch); \Play one game
int Switch;
int Car, Player, Player0, Monty;
[Car:= Ran(3); \randomly place car behind a door
@ -13,19 +13,21 @@ if Switch then \player switches to remaining door
repeat Player:= Ran(3);
until Player # Player0 and Player # Monty
else Player:= Player0; \player sticks with original door
if Player = Car then Wins:= Wins+1;
return Player = Car;
];
[Format(2,1);
Text(0, "Not switching doors wins car in ");
Wins:= 0;
for Game:= 0 to Games-1 do Play(false);
RlOut(0, float(Wins)/float(Games)*100.0);
Text(0, "NOT switching doors wins car in ");
NWins:= 0;
for Game:= 0 to NGames-1 do
if IsGameWon(false) then NWins:= NWins+1;
RlOut(0, float(NWins)/float(NGames)*100.0);
Text(0, "% of games.^M^J");
Text(0, "But switching doors wins car in ");
Wins:= 0;
for Game:= 0 to Games-1 do Play(true);
RlOut(0, float(Wins)/float(Games)*100.0);
NWins:= 0;
for Game:= 0 to NGames-1 do
if IsGameWon(true) then NWins:= NWins+1;
RlOut(0, float(NWins)/float(NGames)*100.0);
Text(0, "% of games.^M^J");
]