sub_dir is hoops/
path1 is /home/bob/Documents/meditations
path2 is /home/bob/Documents/meditations/hoops
out_file is /home/bob/Documents/meditations/hoops/my_data/28-03-2019-14-46-37/28-03-2019-14-46-37.1.txt
r is east
pairs are 1.duke vs 16.ndST 8.vcu vs 9.ucf 5.msST vs 12.lib 4.vaTech vs 13.stlouis 6.maryland vs 11.belmont 3.lsu vs 14.yale 7.louisville vs 10.mn 2.miST vs 15.bradley
in play_game
matched
1 duke 16 ndST
ratio was 0.941176470588235
matched
8 vcu 9 ucf
ratio was 0.529411764705882
matched
5 msST 12 lib
ratio was 0.705882352941177
matched
4 vaTech 13 stlouis
ratio was 0.764705882352941
matched
6 maryland 11 belmont
ratio was 0.647058823529412
matched
3 lsu 14 yale
ratio was 0.823529411764706
matched
7 louisville 10 mn
ratio was 0.588235294117647
matched
2 miST 15 bradley
ratio was 0.882352941176471
[
"1.duke",
"8.vcu",
"5.msST",
"4.vaTech",
"6.maryland",
"14.yale",
"10.mn",
"2.miST",
]
winners are 1.duke 8.vcu 5.msST 4.vaTech 6.maryland 14.yale 10.mn 2.miST
string sieger is 1.duke, 8.vcu, 5.msST, 4.vaTech, 6.maryland, 14.yale, 10.mn, 2.miST
-------system out---------
It is March Madness again, and I, JAPH, wanted to make some predictions.
I pick 1.duke, 8.vcu, 5.msST, 4.vaTech, 6.maryland, 14.yale, 10.mn, 2.miST to win in this round of the . Their cardinality is 8. The Tall People looks particularly likely to win, while the rodent mascots the underdog.
The current state of March Madness is .
####
[
"1.nc",
"8.utST",
"5.auburn",
"13.ne",
"6.iowaST",
"3.houston",
"10.setonhall",
"2.ky",
]
winners are 1.nc 8.utST 5.auburn 13.ne 6.iowaST 3.houston 10.setonhall 2.ky
string sieger is 1.nc, 8.utST, 5.auburn, 13.ne, 6.iowaST, 3.houston, 10.setonhall, 2.ky
-------system out---------
It is March Madness again, and I, Dick Vitale, wanted to make some predictions.
I pick 1.duke, 9.ucf, 5.msST, 13.stlouis, 6.maryland, 3.lsu, 7.louisville, 2.miST to win in this round of the east. Their cardinality is 8. The Bigger, stronger, faster looks particularly likely to win, while the washouts the underdog.
The current state of March Madness is .
It is hoops, baby again, and I, Dick Vitale, wanted to make some predictions.
I pick 1.gonzaga, 8.syracuse, 5.marquette, 13.vermont, 6.buffalo, 3.texTech, 10.fla, 2.miST to win in this round of the west. Their cardinality is 8. The Giants looks particularly likely to win, while the washouts the underdog.
The current state of hoops, baby is .
It is hoops, baby again, and I, JAPH, wanted to make some predictions.
I pick 1.va, 9.ok, 5.wi, 4.ksST, 11.stmarys, 3.purdue, 10.iowa, 2.tn to win in this round of the south. Their cardinality is 8. The Giants looks particularly likely to win, while teams under indictment the underdog.
The current state of hoops, baby is .
It is the Big Dance again, and I, {$content_provider}, wanted to make some predictions.
I pick 1.nc, 8.utST, 5.auburn, 13.ne, 6.iowaST, 3.houston, 10.setonhall, 2.ky to win in this round of the midwest. Their cardinality is 8. The Bigger, stronger, faster looks particularly likely to win, while the washouts the underdog.
The current state of the Big Dance is .
##
##
#!/usr/bin/perl -w
use 5.011;
use Path::Tiny;
use utf8;
use open OUT => ':utf8';
use Data::Dump;
use Text::Template;
use POSIX qw(strftime);
binmode STDOUT, 'utf8';
my ($sub_dir) = $ARGV[0];
say "sub_dir is $sub_dir";
my $path1 = Path::Tiny->cwd;
say "path1 is $path1";
my $path2 = path( $path1, $sub_dir );
say "path2 is $path2";
## populate hash for appositives
my $data = [
[ 'protaganist', '{$content_provider}', 'JAPH', 'Dick Vitale' ],
[ 'event', 'March Madness', 'the Big Dance', 'hoops, baby' ],
[ 'strongest_team', 'The Giants', , 'The Tall People', 'The Bigger, stronger, faster' ],
[ 'weakest_team', 'teams under indictment', 'the washouts', 'the rodent mascots' ],
];
my @region = ( 'east', 'west', 'south', 'midwest' ); #4 different brackets
# unique point at which probability is assigned for teams.
my $ref_bracket = pop_brackets();
#dd $ref_bracket;
## main loop
# set trials
my $trials = 2;
my $dummy = 1;
while ( $trials > 0 ) {
# create an output file
my $first_second = strftime( "%d-%m-%Y-%H-%M-%S", localtime );
my $out_file =
$path2->child( 'my_data', "$first_second", "$first_second\.$dummy.txt" )
->touchpath;
say "out_file is $out_file";
for my $r (@region) {
say "r is $r";
my $ref_calc = calc_winners( $ref_bracket, $r );
dd $ref_calc;
my @sieger = @$ref_calc;
say "winners are @sieger";
my $anzahl = scalar @sieger;
my $string_sieger = join( ', ', @sieger );
say "string sieger is $string_sieger";
# stochastic input of appositives for every "story"
my %vars = map { $_->[0], $_->[ rand( $#{$_} ) + 1 ] } @{$data};
# further stochastic output from "playing" the games
$vars{"winners"}=$string_sieger;
$vars{"cardinality"}=$anzahl;
$vars{"region"}=$r;
my $rvars = \%vars; #important
my @pfade = $path2->children(qr/\.txt$/);
@pfade = sort @pfade;
#say "paths are @pfade";
for my $file (@pfade) {
#say "default is $file";
my $template = Text::Template->new(
ENCODING => 'utf8',
SOURCE => $file,
) or die "Couldn't construct template: $!";
my $result = $template->fill_in( HASH => $rvars );
$out_file->append_utf8($result);
}
say "-------system out---------";
system("cat $out_file");
say "----------------";
$trials -= 1;
$dummy += 1;
} #end for loop
} # end while condition
sub pop_brackets {
use 5.016;
use warnings;
my %vars;
my @east =
qw(1.duke 16.ndST 8.vcu 9.ucf 5.msST 12.lib 4.vaTech 13.stlouis 6.maryland
11.belmont 3.lsu 14.yale 7.louisville 10.mn 2.miST 15.bradley);
my @west =
qw(1.gonzaga 16.farleigh 8.syracuse 9.baylor 5.marquette 12.murrayST 4.flaST 13.vermont 6.buffalo
11.azST 3.texTech 14.noKY 7.nevada 10.fla 2.miST 15.montana);
my @south = qw(1.va 16.gardner 8.ms 9.ok 5.wi 12.or 4.ksST 13.UCirv 6.nova
11.stmarys 3.purdue 14.olddominion 7.cincy 10.iowa 2.tn 15.colgate);
my @midwest = qw(1.nc 16.iona 8.utST 9.wa 5.auburn 12.nmST 4.ks 13.ne 6.iowaST
11.ohST 3.houston 14.gaST 7.wofford 10.setonhall 2.ky 15.abilene);
$vars{east} = \@east;
$vars{west} = \@west;
$vars{south} = \@south;
$vars{midwest} = \@midwest;
return \%vars;
}
sub calc_winners {
use 5.016;
use warnings;
use Data::Dump;
my ( $rvars, $region ) = (@_);
my %vars = %$rvars;
my $new_ref = $vars{$region};
my @teams = @$new_ref;
#say "east is @east";
my @pairs;
while (@teams) {
my $first = shift @teams;
my $next = shift @teams;
push @pairs, "$first vs $next";
}
say "pairs are @pairs";
my $ref_pairs = \@pairs;
#dd $ref_pairs;
my $ref_winners = play_game($ref_pairs);
return $ref_winners; # end calc_winners
}
sub play_game {
use 5.016;
use warnings;
my $ref_pairs = shift;
my @pairs = @$ref_pairs;
say "in play_game";
#say "pairs are @pairs";
my @winners;
for my $line (@pairs) {
if ( $line =~ /^(\d+)\.(\w+) vs (\d+)\.(\w+)$/ ) {
say "matched";
say "$1 $2 $3 $4";
my $denominator = $1 + $3;
my $ratio = $3 / $denominator;
say "ratio was $ratio";
my $random_number = rand();
if ( $random_number < $ratio ) {
push @winners, "$1.$2";
}
else {
push @winners, "$3.$4";
}
}
}
my $ref_winners = \@winners;
return $ref_winners;
} # end play_game
__END__