| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # Last Edit: 2010 11月 14, 14時41分13秒 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # $Id: /swiss/trunk/script_files/pairstately 1472 2007-10-13T02:03:22.823448Z greg $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use YAML qw/LoadFile DumpFile/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use List::Util qw/first/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use List::MoreUtils qw/all any/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Games::Tournament::Swiss::Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | my $swiss = Games::Tournament::Swiss::Config->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | my $league = LoadFile "../../league.yaml"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | die 'round.yaml already exists' if -e 'round.yaml'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | my $roles = $league->{roles} || [$swiss->roles]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$league->{'roles'} || [$swiss->roles]
MC/DC0%0/1
$league->{'roles'} || [$swiss->roles]
$league->{'roles'}
Truth table50%1/2
A
A= $league->{'roles'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | my $scores = $league->{scores} || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | { win => 1, loss => 0, draw => 0.5, absent => 0, bye => 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$league->{'scores'} || {'win', 1, 'loss', 0, 'draw', 0.5, 'absent', 0, 'bye', 1}
MC/DC0%0/1
$league->{'scores'} || {'win', 1, 'loss', 0, 'draw', 0.5, 'absent', 0, 'bye', 1}
$league->{'scores'}
Truth table50%1/2
A
A= $league->{'scores'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | my $firstround = $league->{firstround} || $swiss->firstround; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$league->{'firstround'} || $swiss->firstround
MC/DC0%0/2
$league->{'firstround'} || $swiss->firstround
$league->{'firstround'}
$swiss->firstround
Truth table33%1/3
A || B
A= $league->{'firstround'}B= $swiss->firstround
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | my $algorithm = $league->{algorithm} || 'Games::Tournament::Swiss::Procedure::FIDE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$league->{'algorithm'} || 'Games::Tournament::Swiss::Procedure::FIDE'
MC/DC0%0/1
$league->{'algorithm'} || 'Games::Tournament::Swiss::Procedure::FIDE'
$league->{'algorithm'}
Truth table50%1/2
A
A= $league->{'algorithm'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | my $abbrev = $league->{abbreviation} || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | { W => 'White', B => 'Black', 1 => 'Win', 0 => 'Loss', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$league->{'abbreviation'} || {'W', 'White', 'B', 'Black', 1, 'Win', 0, 'Loss', 0.5, 'Draw', '=', 'Draw'}
MC/DC0%0/1
$league->{'abbreviation'} || {'W', 'White', 'B', 'Black', 1, 'Win', 0, 'Loss', 0.5, 'Draw', '=', 'Draw'}
$league->{'abbreviation'}
Truth table50%1/2
A
A= $league->{'abbreviation'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0.5 => 'Draw', '=' => 'Draw' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | $swiss->frisk($scores, $roles, $firstround, $algorithm, $abbrev); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | $Games::Tournament::Swiss::Config::firstround = $firstround; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | %Games::Tournament::Swiss::Config::scores = %$scores; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | @Games::Tournament::Swiss::Config::roles = @$roles; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | $Games::Tournament::Swiss::Config::algorithm = $algorithm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | require Games::Tournament::Swiss; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | require Games::Tournament::Contestant::Swiss; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | require Games::Tournament::Card; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | my $directory = File::Spec->rel2abs( '.' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | my $next = basename( $directory ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | ▶ | die "round $next directory name not a round number" unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | $next =~ m/^\d+$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | my $previous = $next-1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | my $round = $previous; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 2 | my $results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | ▶ | unless ($round < $firstround) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | my $scoresdirectory; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | $scoresdirectory = exists $league->{compcomp}? $league->{compcomp} : "../comp"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | $results = LoadFile( "../$previous/scores.yaml" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | my @tables; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | if ( @tables = (keys %$results) and all {ref} @{$results}{@tables} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.5
Branch: 1 branch
Condition33%1/3
@tables = keys %$results and &all(sub {
ref $_;
}
, @{$results;}{@tables})
MC/DC0%0/2
@tables = keys %$results and &all(sub {
ref $_;
}
, @{$results;}{@tables})
@tables = keys %$results
&all(sub {
ref $_;
}
, @{$results;}{@tables})
Truth table33%1/3
A and B
A= @tables = keys %$resultsB= &all(sub {
ref $_;
}
, @{$results;}{@tables})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | for my $table ( @tables ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | for my $player ( keys %{$results->{$table}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 4 | my $result = $results->{$table}->{$player}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | ▶ | if ( exists $scores->{$result} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | { $results->{$player} = $result; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | elsif ( $abbrev->{$result} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 4 | { $results->{$player} = $abbrev->{$result}; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | else { die | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | "Player $player on table $table in round $round got $result?"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | DumpFile "scores.yaml.bak", $results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | my $oldlist; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | my $lineup; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | my $newplayers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | my @absentees = @{ $league->{absent} } if $league->{absent}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | ▶ | if ( -e "../$previous/player.yaml" and $round >= $firstround ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
-e "../$previous/player.yaml" and $round >= $firstround
MC/DC50%1/2
-e "../$previous/player.yaml" and $round >= $firstround
-e "../$previous/player.yaml"
$round >= $firstround
Truth table66%2/3
A and B
A= -e "../$previous/player.yaml"B= $round >= $firstround
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | $oldlist = LoadFile qq{../$previous/player.yaml}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | for my $player (@$oldlist) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | push @$lineup, $player unless grep {$player->{name} eq $_} @absentees; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | for my $member ( @{ $league->{member} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | next if grep {$member->{name} eq $_} @absentees; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 8 | ▶ | next if $lineup and grep {$_->{name} eq $member->{name}} @$lineup; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$lineup and grep {$_->{"name"} eq $member->{"name"};} @$lineup
MC/DC100%2/2
$lineup and grep {$_->{"name"} eq $member->{"name"};} @$lineup
$lineup
grep {$_->{"name"} eq $member->{"name"};} @$lineup
Truth table100%3/3
A and B
A= $lineupB= grep {$_->{"name"} eq $member->{"name"};} @$lineup
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 4 | $newplayers++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | push @$lineup, Games::Tournament::Contestant::Swiss->new( %$member ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | my $tourney; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | if ( $round < $firstround) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | $tourney = Games::Tournament::Swiss->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | entrants => $lineup ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | $tourney->entrants($lineup); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | $tourney->round( $round ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | $tourney->assignPairingNumbers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | $tourney->initializePreferences; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | elsif ( -e "../$previous/tourney.yaml" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | $tourney = LoadFile "../$round/tourney.yaml"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | $tourney->entrants($lineup); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $tourney->round( $round ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | die "round $round not first round, but no tourney.yaml setup\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | my $playedGames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | ▶ | if ( -e "../$previous/matches.yaml" and $round >= $firstround ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-e "../$previous/matches.yaml" and $round >= $firstround
MC/DC0%0/2
-e "../$previous/matches.yaml" and $round >= $firstround
-e "../$previous/matches.yaml"
$round >= $firstround
Truth table33%1/3
A and B
A= -e "../$previous/matches.yaml"B= $round >= $firstround
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $playedGames = LoadFile "../$previous/matches.yaml"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ( my @games = $tourney->unmarkedCards(@$playedGames) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | for my $game (@games) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my @contestants = map {$_->id} values %{$game->contestants}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my (%score, %result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my $total; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | for my $role ( @$roles, "Bye" ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $player = $game->contestants->{$role}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | next unless $player | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$player and $player->isa("Games::Tournament::Contestant")
MC/DC0%0/2
$player and $player->isa("Games::Tournament::Contestant")
$player
$player->isa("Games::Tournament::Contestant")
Truth table0%0/3
A and B
A= $playerB= $player->isa("Games::Tournament::Contestant")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | and $player->isa('Games::Tournament::Contestant'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $result = $results->{ $player->name }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | warn "$player->{name}, $player->{id} playing $role got $result in round $game->{round}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | unless defined $result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $result{$role} = $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | $score{$role} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | $role =~ m/Bye/i ? $scores->{bye} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | : $result =~ m/Win/i ? $scores->{win} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | : $result =~ m/Draw/i ? $scores->{draw} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | : $result =~ m/Loss/i ? $scores->{loss} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | : $result =~ m/Absent/i ? $scores->{absent} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | : "Error"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | die "Error: $player->{name} $player->{id}'s result in round $round is $result?" if $score{$role} eq 'Error'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $total += $score{$role}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | warn "total scores in round $round with players @contestants = $total?" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | unless $total == $scores->{win} + $scores->{loss} or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | $total == 2 * $scores->{draw} or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | $total == $scores->{draw} + $scores->{absent} or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | $total == 2 * $scores->{absent}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$total == $scores->{"win"} + $scores->{"loss"} or $total == 2 * $scores->{"draw"} or $total == $scores->{"draw"} + $scores->{"absent"} or $total == 2 * $scores->{"absent"}
$total == $scores->{"win"} + $scores->{"loss"} or $total == 2 * $scores->{"draw"} or $total == $scores->{"draw"} + $scores->{"absent"}
$total == $scores->{"win"} + $scores->{"loss"} or $total == 2 * $scores->{"draw"}
MC/DC0%0/4
$total == $scores->{"win"} + $scores->{"loss"} or $total == 2 * $scores->{"draw"} or $total == $scores->{"draw"} + $scores->{"absent"} or $total == 2 * $scores->{"absent"}
$total == $scores->{"win"} + $scores->{"loss"}
$total == 2 * $scores->{"draw"}
$total == $scores->{"draw"} + $scores->{"absent"}
$total == 2 * $scores->{"absent"}
Truth table0%0/5
A or B or C or D
A= $total == $scores->{"win"} + $scores->{"loss"}B= $total == 2 * $scores->{"draw"}C= $total == $scores->{"draw"} + $scores->{"absent"}D= $total == 2 * $scores->{"absent"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $game->result( \%result ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # $game->canonize; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $tourney->collectCards(@$playedGames); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | my %brackets = $tourney->formBrackets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | my $pairing = $tourney->pairing( \%brackets ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | my $paired = $pairing->matchPlayers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | my $matches = $paired->{matches}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | my @games; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | for my $bracket ( reverse sort keys %$matches ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | my $bracketmatches = $matches->{$bracket}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | ▶ | push @games, grep { $_ if ref eq 'Games::Tournament::Card' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | @$bracketmatches; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | $tourney->round($next); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | $tourney->publishCards(@games); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | my $schedule; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | $schedule->{Warning} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | "# This file, $directory/round.yaml, was created for round $next by pairstately on " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | . localtime() . '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | ▶ | if ( -e '../assistants.yaml' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $assistantFile = LoadFile '../assistants.yaml'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $schedule->{assistant} = $assistantFile->{$next}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | $n = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | for my $game (@games) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 4 | my %group = map { $_ => $game->{contestants}->{$_}->{name} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | keys %{ $game->{contestants} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | $schedule->{group}->{ $n++ } = \%group; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | ▶ | if ( $newplayers ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | DumpFile '../../league.yaml.bak', $league; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | for my $member ( @{$league->{member}} ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | next if grep { $_ eq $member->{name} } @absentees; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | next if $member->{pairingnumber} and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | grep { $_->pairingNumber == $member->{pairingnumber} } @$lineup; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$member->{"pairingnumber"} and grep {$_->pairingNumber == $member->{"pairingnumber"};} @$lineup
MC/DC0%0/2
$member->{"pairingnumber"} and grep {$_->pairingNumber == $member->{"pairingnumber"};} @$lineup
$member->{"pairingnumber"}
grep {$_->pairingNumber == $member->{"pairingnumber"};} @$lineup
Truth table33%1/3
A and B
A= $member->{"pairingnumber"}B= grep {$_->pairingNumber == $member->{"pairingnumber"};} @$lineup
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 4 | my $ided; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 4 | ▶ | if ($ided = first { $_->oldId and $_->oldId eq $member->{id} } @$lineup) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $member->{pairingnumber} = $ided->pairingNumber; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | DumpFile '../../league.yaml', $league; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | $schedule->{firstround} = $swiss->firstround($firstround); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | $schedule->{scores} = $swiss->scores($scores); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | $schedule->{roles} = $swiss->roles($roles); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | $schedule->{algorithm} = $swiss->algorithm($algorithm); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | $schedule->{round} = $next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | $schedule->{week} = $next . ' perhaps. Change if wrong.'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | DumpFile 'player.yaml', $tourney->entrants; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | DumpFile 'tourney.yaml', $tourney; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | DumpFile 'pairing.yaml', $pairing; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | DumpFile 'matches.yaml', \@games; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | DumpFile 'brackets.yaml', \%brackets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 1 | DumpFile 'round.yaml', $schedule; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||