by Richard Reiner
In the interest of scupulous fairness and utterly demented fun, I herewith submit the Perl program which shall be used to generate the teams for our paintball games this coming Sunday, for the review of the astute staff of FSC.
The intended application of the program is as follows:
The careful reader will notice that, although the program generates teams randomly, it does NOT ensure that the two teams will be of equal size. This is in the interest of maximizing the quantity of demented fun -- the occasional 12 player vs. 2 player match might be quite entertaining.
The program is also utterly uncommented, as this will certainly add to your enjoyment in reading it :-), and because it is written in the most simpleminded Perl possible.
Enjoy.
-- cut here --
#!/usr/local/bin/perl
$len = 0;
$t = 0;
$alen = 0;
$blen = 0;
$acap = 0;
$bcap = 0;
while ( <> ) {
chomp;
if (length( $_ ) > 0) {
$names[$len] = $_;
$len++;
}
}
for ( $t = 0; $t < $len; $t++ ) {
if (rand(1) < 0.5) {
$anames[$alen] = $names[$t];
$alen++;
} else {
$bnames[$blen] = $names[$t];
$blen++;
}
}
$acap = int(rand($alen));
$bcap = int(rand($blen));
print "-- Team A --\n";
print "Captain = " . $anames[$acap] . "\n";
for ( $t = 0; $t < $alen; $t++ ) {
if ($t != $acap) {
print $anames[$t] . "\n";
}
}
print "\n";
print "-- Team B --\n";
print "Captain = " . $bnames[$bcap] . "\n";
for ( $t = 0; $t < $blen; $t++ ) {
if ($t != $bcap) {
print $bnames[$t] . "\n";
}
}