| 1 | package Baseball::Simulation; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.008; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | our @EXPORT_OK = ( ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | our @EXPORT = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | our $VERSION = '0.10'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | #The Global Parameters that are the arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | my %arg; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | my $TeamBattingFile = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | my $TeamPitchingFile = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | my $NumOfSeasons = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | #Global variables used by various arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | my @Lineup; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | my @PitchingLineup; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # new | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # Parameters: An argument list containing: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # BattingFile - The batters file stats | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # PitchingFile - The batters file stats | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # Seasons - the number of seasons to simulate | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # (default 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # Description: Creates an object and checks if the parameters are | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # correct.. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # Returns: Return itself unless there is a parameter error, in which | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # it dies | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | %arg = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | $TeamBattingFile = $arg{'BattingFile'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | $TeamPitchingFile = $arg{'PitchingFile'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | ▶ | $NumOfSeasons = $arg{'Seasons'} || 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$arg{'Seasons'} || 1
MC/DC0%0/1
$arg{'Seasons'} || 1
$arg{'Seasons'}
Truth table50%1/2
A
A= $arg{'Seasons'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | unless (-e $TeamBattingFile) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | die "Cannot open the batting file: $TeamBattingFile"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | unless (-e $TeamPitchingFile) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | die "Cannot open the pitching file: $TeamPitchingFile"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | @Lineup = CreateBatterArray(CreateNewLineup($TeamBattingFile)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | @PitchingLineup= CreateBatterArray(CreateNewLineup($TeamPitchingFile)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | return bless{}, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # Round | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # Parameters: un unrounded number | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # Description: Rounds a number | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # Returns: The rounded number | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub Round($) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Round: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $Float = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $Float += 0.5; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | return int($Float); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # StripLine | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # Parameters: A line with white surrounding white space and comments | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # Description: Removes surrounding white space and comments | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # Returns: A cleaned up line | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 16 | ▶ | sub StripLine($) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
StripLine: called CC=4 SCAR=14.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 16 | my $LineToBeParsed = $_[0]; # The text to be stripped | |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 16 | chomp $LineToBeParsed; # Get rid of line feed | |||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # Delete leading spaces; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 16 | ▶ | if ( $LineToBeParsed =~ /^\s+/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $LineToBeParsed = $'; #' | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # Check for comment characters | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 16 | ▶ | if ( $LineToBeParsed =~ /#/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 6 | $LineToBeParsed = $`; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # Delete the ending spaces | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 16 | ▶ | if ( $LineToBeParsed =~ /\s+$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $LineToBeParsed = $`; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 16 | return $LineToBeParsed; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # CreateBatter | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # Paramenters: The array consisting the cumalitve totals for: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # At-Bats | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # Walks | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # Singles | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # Doubles | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # Triples | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # Homers | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # StolenBases | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # Description: Calculates the averages for the batting statistics | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # Returns: The array consisting the cumalitve averages for: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # WalkChance - The percentage for a walk | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # SingleChance - The percentage that a single can be hit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # DoubleChance - The percentage that a single can be hit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # TripleChance - The percentage that a single can be hit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # HomerChance - The percentage that a single can be hit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # SacChance - The percentage that a sacrifice occurs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # StolenBaseChance - The percentage that a stolen base occurs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 2 | ▶ | sub CreateBatterArray(@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CreateBatterArray: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | my ($AtBats, $Hits, $Doubles, $Triples, $Homers, $Walks, $Steals) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | my $TotalAtBats = $AtBats + $Walks; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | my $Singles = $Hits - $Doubles - $Triples - $Homers; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | my $WalkChance = int (($Walks / $TotalAtBats) * 1000); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 2 | my $SinglesChance = int (($Singles / $TotalAtBats) * 1000); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | my $DoublesChance = int (($Doubles / $TotalAtBats) * 1000); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | my $TriplesChance = int (($Triples / $TotalAtBats) * 1000); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 2 | my $HomersChance = int (($Homers / $TotalAtBats) * 1000); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | my $StealsChance = int ($Steals / ($Walks + $Singles)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 2 | my $SacrificeChance = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 2 | return ($WalkChance, $SinglesChance, $DoublesChance, $TriplesChance, $HomersChance, $SacrificeChance, $StealsChance); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # CreateNewLineup | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # Parameters: The file of user list | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # Description: Reads the stats from a file, adding the additions | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # and subtracting the subtractions | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # Returns: The array consisting the cumalitve totals for: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # At-Bats | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # Walks | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # Singles | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # Doubles | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # Triples | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # Homers | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # StolenBases | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 2 | ▶ | sub CreateNewLineup($) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CreateNewLineup: called CC=20 SCAR=31.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | my $File = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | my @TotalStats = (0,0,0,0,0,0,0);; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 2 | my @PlayerStats = (0,0,0,0,0,0,0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 2 | my $Line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | ▶ | open(INFILE, "$File") || die "Cannot open $File"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | my @FileLines = <INFILE>; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | close(INFILE); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | my $MaxLine = @FileLines; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | ▶ | while (($Line = $FileLines[$i++]) && ($i <= $MaxLine)){ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Line = $FileLines[$i++] and $i <= $MaxLine
MC/DC0%0/2
$Line = $FileLines[$i++] and $i <= $MaxLine
$Line = $FileLines[$i++]
$i <= $MaxLine
Truth table33%1/3
A and B
A= $Line = $FileLines[$i++]B= $i <= $MaxLine
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | $Line = StripLine($Line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | ▶ | next unless ($Line); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | @TotalStats = split /\:/, $Line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 2 | ▶ | if ($#TotalStats + 1 != 7) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | die "The following line does not contain 7 double colon seperated values: $Line"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | ▶ | while (($Line = $FileLines[$i++]) && ($i <= $MaxLine)){ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$Line = $FileLines[$i++] and $i <= $MaxLine
MC/DC50%1/2
$Line = $FileLines[$i++] and $i <= $MaxLine
$Line = $FileLines[$i++]
$i <= $MaxLine
Truth table66%2/3
A and B
A= $Line = $FileLines[$i++]B= $i <= $MaxLine
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | $Line = StripLine($Line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | ▶ | last if ($Line =~ /additions/i); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | my $l = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | ▶ | while (($Line = $FileLines[$i++]) && ($i <= $MaxLine)){ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$Line = $FileLines[$i++] and $i <= $MaxLine
MC/DC50%1/2
$Line = $FileLines[$i++] and $i <= $MaxLine
$Line = $FileLines[$i++]
$i <= $MaxLine
Truth table66%2/3
A and B
A= $Line = $FileLines[$i++]B= $i <= $MaxLine
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 5 | $Line = StripLine($Line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 5 | ▶ | last if ($Line =~ /sub/i); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | ▶ | if ($Line) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | my $j = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 2 | @PlayerStats = split /\:/, $Line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | ▶ | if ($#PlayerStats + 1 != 7) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | die "The following line does not contain 7 double colon seperated values: $Line"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 2 | ▶ | for ($l = 0; $l < 7; $l++) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 14 | $TotalStats[$l] += $PlayerStats[$l]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | ▶ | while (($Line = $FileLines[$i++]) && ($i <= $MaxLine)){ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$Line = $FileLines[$i++] and $i <= $MaxLine
MC/DC50%1/2
$Line = $FileLines[$i++] and $i <= $MaxLine
$Line = $FileLines[$i++]
$i <= $MaxLine
Truth table66%2/3
A and B
A= $Line = $FileLines[$i++]B= $i <= $MaxLine
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 8 | $Line = StripLine($Line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 8 | ▶ | if ($Line) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 4 | @PlayerStats = split /\:/, $Line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 4 | ▶ | if ($#PlayerStats + 1 != 7) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | die "The following line does not contain 7 double colon seperated values: $Line"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 4 | ▶ | for ($l = 0; $l < 7; $l++) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 28 | $TotalStats[$l] -= $PlayerStats[$l]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 2 | return @TotalStats; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # AtBat | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # Parameters: WalkChance - The percentage for a walk | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | # SingleChance - The percentage that a single can be hit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # DoubleChance - The percentage that a single can be hit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # TripleChance - The percentage that a single can be hit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # HomerChance - The percentage that a single can be hit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # SacChance - The percentage that a single can be hit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | # StolenBaseChance - The percentage that a single can be hit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # Description: Simulates an at-bat | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # Returns: The result - -1 = walk | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | # 0 = out | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | # 1 = single | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # 2 = double | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # 3 = triple | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # 4 = home run | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | #ignore double plays and sacrifices for now | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 263284 | ▶ | sub AtBat(@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AtBat: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 263284 | my $WalkChance = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 263284 | my $SingleChance = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 263284 | my $DoubleChance = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 263284 | my $TripleChance = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 263284 | my $HomerChance = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 263284 | my $SacChance = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 263284 | my $StolenBaseChance = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 263284 | my $Random2 = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 263284 | ($WalkChance, $SingleChance, $DoubleChance, $TripleChance, $HomerChance, $SacChance, $StolenBaseChance) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 263284 | $Random2 = (((int (rand(10000))) + (int (rand(2000)))) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | % 1000); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 263284 | ▶ | if ($Random2 < $WalkChance) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 20705 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } elsif ($Random2 < ($SingleChance + $WalkChance)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 41586 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } elsif ($Random2 < ($SingleChance + $WalkChance + $DoubleChance)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 12611 | return 2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } elsif ($Random2 < ($SingleChance + $WalkChance + $DoubleChance + $TripleChance)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1458 | return 3; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } elsif ($Random2 < ($SingleChance + $WalkChance + $DoubleChance + $TripleChance + $HomerChance)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 8364 | return 4; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 178560 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | # AdvanceRunner | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | # Parameters: Result - the result of the at bat | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | # PlayerStealChance - the player's chance of stealing | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # FirstBase - whether someone is on first | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # FirstBaseStealChance - the guys on first's chance of stealing | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | # SecondBase - whether someone is on second | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # SecondBaseStealChance - the guys on third's chance of stealing | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | # ThirdBase - whether someone is on third | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | # Score - The score so far | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | # Description: Advances runners after an at-bat | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # Returns: Updated values for: $FirstBase, $FirstBaseStealChance, $ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # SecondBase, $SecondBaseStealChance, $ThirdBase, $Score | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 203764 | ▶ | sub AdvanceRunner($$$$$$$$) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AdvanceRunner: called CC=28 SCAR=33.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 203764 | my ($Result, $PlayerStealChance, $FirstBase, $FirstBaseStealChance, $SecondBase, $SecondBaseStealChance, $ThirdBase, $Score) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 203764 | ▶ | if ($Result == -1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 20705 | ▶ | if ($FirstBase && $SecondBase && $ThirdBase) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%6/6
$FirstBase and $SecondBase and $ThirdBase
$FirstBase and $SecondBase
MC/DC100%3/3
$FirstBase and $SecondBase and $ThirdBase
$FirstBase
$SecondBase
$ThirdBase
Truth table100%4/4
A and B and C
A= $FirstBaseB= $SecondBaseC= $ThirdBase
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | #Advance all one | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 245 | $Score++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 245 | $SecondBaseStealChance = $FirstBaseStealChance; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | ▶ | } elsif ($FirstBase && $SecondBase) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$FirstBase and $SecondBase
MC/DC100%2/2
$FirstBase and $SecondBase
$FirstBase
$SecondBase
Truth table100%3/3
A and B
A= $FirstBaseB= $SecondBase
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | #Advance the first two one | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 1154 | $SecondBaseStealChance = $FirstBaseStealChance; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 1154 | $ThirdBase = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } elsif ($FirstBase) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | #Advance the first base | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 5825 | $SecondBaseStealChance = $FirstBaseStealChance; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 5825 | $SecondBase = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 20705 | $FirstBase = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 20705 | $FirstBaseStealChance = $PlayerStealChance; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } elsif ($Result == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | #ThirdBase always scores | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 41586 | ▶ | if ($ThirdBase) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 3513 | $Score++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 3513 | $ThirdBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 41586 | ▶ | if ($SecondBase) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 6998 | $SecondBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | #There is a 70% chance the guy from second score | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 6998 | ▶ | if (rand (10) < 7) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 4908 | $Score++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 2090 | $ThirdBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } elsif ($FirstBase) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | #There is a 70% chance the guy from second score | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 11527 | ▶ | if (rand (10) < 7) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 8001 | $ThirdBase = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 3526 | $SecondBase = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 3526 | $SecondBaseStealChance = $FirstBaseStealChance; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 41586 | $FirstBaseStealChance = $PlayerStealChance; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 41586 | $FirstBase = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } elsif ($Result == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 12611 | $Score = $Score + $SecondBase + $ThirdBase; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 12611 | $ThirdBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 12611 | $SecondBase = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | #There is a 70% chance the guy from first scores | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 12611 | ▶ | if ($FirstBase) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 4342 | ▶ | if (rand (10) < 7) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 3026 | $Score += $FirstBase; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 3026 | $ThirdBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 1316 | $ThirdBase = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 12611 | $FirstBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 12611 | $SecondBaseStealChance = $PlayerStealChance; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } elsif ($Result == 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 1458 | $Score = $Score + $FirstBase + $SecondBase + $ThirdBase; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 1458 | $FirstBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 1458 | $SecondBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 1458 | $ThirdBase = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } elsif ($Result == 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 8364 | $Score = $Score + $FirstBase + $SecondBase + $ThirdBase + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 8364 | $FirstBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 8364 | $SecondBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 8364 | $ThirdBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } elsif ($Result == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 119040 | ▶ | if ($ThirdBase) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | #Sacrifice for third | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 7231 | ▶ | if (rand (10) < 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 2899 | $Score++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 2899 | $ThirdBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | ▶ | } elsif($SecondBase && !$ThirdBase) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$SecondBase and not $ThirdBase
MC/DC50%1/2
$SecondBase and not $ThirdBase
$SecondBase
not $ThirdBase
Truth table66%2/3
A and not(B)
A= $SecondBaseB= not $ThirdBase
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 13698 | ▶ | if (rand (10) < 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 4171 | $ThirdBase = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 4171 | $SecondBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | ▶ | } elsif($FirstBase && !$SecondBase) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$FirstBase and not $SecondBase
MC/DC50%1/2
$FirstBase and not $SecondBase
$FirstBase
not $SecondBase
Truth table66%2/3
A and not(B)
A= $FirstBaseB= not $SecondBase
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 25446 | ▶ | if (rand (10) < 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 7509 | $SecondBase = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 7509 | $FirstBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 7509 | $SecondBaseStealChance = $FirstBaseStealChance; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 203764 | return ($FirstBase, $FirstBaseStealChance, $SecondBase, $SecondBaseStealChance, $ThirdBase, $Score); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | # Inning | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | # Parameters: Who is batting - 1 if the team is batting | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | # - 0 if the other team is batting | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | # Description: Simulates an inning | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | # Returns: Returns the score from that inning | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 59520 | ▶ | sub Inning($) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Inning: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 59520 | my $Who = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 59520 | my $Outs = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 59520 | my $FirstBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 59520 | my $FirstBaseStealChance = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 59520 | my $SecondBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 59520 | my $SecondBaseStealChance = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 59520 | my $ThirdBase = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 59520 | my $Score = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 59520 | my $Result = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 59520 | my @Player = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 59520 | ▶ | if ($Who) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 29760 | @Player = @Lineup; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 29760 | @Player = @PitchingLineup; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 59520 | ▶ | while ($Outs < 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 263284 | $Result = AtBat(@Player); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 263284 | ▶ | if (!$Result) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 178560 | $Outs++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 263284 | ▶ | } if ($Outs < 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 203764 | ($FirstBase, $FirstBaseStealChance, $SecondBase, $SecondBaseStealChance, $ThirdBase, $Score) = AdvanceRunner($Result, $Player[6], $FirstBase, $FirstBaseStealChance, $SecondBase, $SecondBaseStealChance, $ThirdBase, $Score); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 59520 | return $Score; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | # Simulate | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | # Parameters: None | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | # Description: Simulates the season | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | # Returns: Average victories per season | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | # Average defeats per season | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | # Average runs scored per season | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # Average runs allowed per season | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 1 | ▶ | sub Simulate() { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Simulate: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 1 | my $TotalVictories = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 1 | my $TotalDefeats = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 1 | my $SingleOtherScore = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 1 | my $TotalScore = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 1 | my $TotalOtherScore = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 1 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 1 | my $k = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 1 | ▶ | for ($k = 0; $k < $NumOfSeasons; $k++) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 20 | my $Victories = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 20 | my $Defeats = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 20 | my $SingleScore = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 20 | my $j = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 20 | ▶ | for ($j = 0; $j < 162; $j++) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 3240 | $SingleScore = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 3240 | ▶ | for ($i = 1; $i <= 9; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 29160 | $SingleScore += Inning(1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | #The opposing team | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 3240 | $SingleOtherScore = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 3240 | ▶ | for ($i = 1; $i <= 9; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 29160 | $SingleOtherScore += Inning(0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 3240 | ▶ | while ($SingleScore == $SingleOtherScore) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 600 | $SingleScore +=Inning(1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 600 | $SingleOtherScore +=Inning(0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 3240 | ▶ | if ($SingleScore > $SingleOtherScore) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 1423 | $Victories++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | } elsif ($SingleScore < $SingleOtherScore) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 1817 | $Defeats++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 3240 | $TotalScore +=$SingleScore; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 3240 | $TotalOtherScore +=$SingleOtherScore; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 20 | $TotalVictories += $Victories; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 20 | $TotalDefeats += $Defeats; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 1 | return ($TotalVictories/$NumOfSeasons, $TotalDefeats/$NumOfSeasons, $TotalScore/$NumOfSeasons, $TotalOtherScore/$NumOfSeasons); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||