Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #
- # Simulate a baseball or softball game
- #
- # Change Out percentage by changing this line:
- # if(int(rand(10)) >= 7){ print "OUT $batter\n"; $out++; $batter++;}
- #
- #
- $out = 0;
- $inning = 1;
- $batter = 1;
- $totalbatters = 13;
- for($sim = 0; $sim <= $ARGV[0]; $sim++)
- {
- $inning = 1;
- $batter = 1;
- for(; $inning < 7; $inning++)
- {
- $out = 0;
- print "Inning: $inning\n";
- while($out < 3)
- {
- if(int(rand(10)) >= 7){ print "OUT $batter\n"; $out++; $batter++;}
- else
- {
- print "Safe:$batter\n";
- $batter++;
- }
- if($batter == ($totalbatters + 1))
- { $batter = 1;}
- }
- }
- $finalbatter = ($batter - 1);
- $tots[$finalbatter] = $tots[$finalbatter] + 1;
- print "Final Batter: $finalbatter\n";
- }
- for($batt = 0; $batt < 13; $batt++)
- {
- $realbatt = $batt +1;
- print "Outs: $realbatt: $tots[$batt]\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement