blib/lib/Games/Tournament/Swiss/Bracket.pm

filter: Statementstmt 85.0% 479 / 563 Branchbran 71.2% 161 / 226 Conditioncond 74.2% 78 / 105 MC/DCmcdc 36.5% 19 / 52 Subroutinesub 83.8% 52 / 62 Podpod 100% 37 / 37 totaltotal 79.0% 826 / 1045 CC 169 SCAR 25.5
CC
169
Cov
80%
_floatCheck
39.9
floatCheckWaive
28.0
__ANON__
12.0
CRAP 12.9
« blib/lib/Games/Tournament/Contestant.pm ↑ Summary blib/lib/Games/Tournament/Card.pm »
1 package Games::Tournament::Swiss::Bracket;
2 32 $Games::Tournament::Swiss::Bracket::VERSION = '0.21';
3 # Last Edit: 2016 Jan 01, 13:44:55
4 # $Id: $
5  
6 32 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 32 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 32 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 32 ▶use constant ROLES => @Games::Tournament::Swiss::Config::roles;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 32 ▶use base qw/Games::Tournament::Swiss/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 32 ▶use Games::Tournament::Contestant::Swiss;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 32 ▶use Games::Tournament::Card;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 32 ▶use List::Util qw/max min reduce sum/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 32 ▶use List::MoreUtils qw/any notall/;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 =head1 NAME
19  
20 Games::Tournament::Swiss::Bracket - Players with same/similar scores pairable with each other
21  
22 =cut
23  
24 =head1 SYNOPSIS
25  
26 $tourney = Games::Tournament::Swiss>new($rounds, \@entrants);
27 @rankedPlayers = $tourney->assignPairingNumbers;
28 @firstbrackets = $t->formBrackets;
29 ...
30 $tourney->collectCards(@games);
31 @scores = $tourney->updateScores($round);
32 @groups = $tourney->formBrackets;
33  
34 =head1 DESCRIPTION
35  
36 In a Swiss tournament, in each round contestants are paired with other players with the same, or similar, scores. These contestants are grouped into a score group (bracket) in the process of deciding who plays who.
37  
38 The concept of immigration control is applied to impose order on the players floating in and out of these score brackets. That is, floating is like flying.
39 I pulled back on this metaphor. It was probably overengineering.
40  
41 =head1 METHODS
42  
43 =head2 new
44  
45 $group = Games::Tournament::Swiss::Bracket->new( score => 7.5, members => [ $a, $b, $c ], remainderof => $largergroup )
46  
47 members is a reference to a list of Games::Tournament::Contestant::Swiss objects. The order is important. If the score group includes floaters, these members' scores will not be the same as $group->score. Such a heterogenous group is paired in two parts--first the downfloaters, and then the homogeneous remainder group. Remainder groups can be recognized by the existence of a 'remainderof' key that links them to the group they came from. Some members may also float down from a remainder group. Each bracket needs a score to determine the right order they will be paired in. The number, from 1 to the total number of brackets, reflects that order. A3
48  
49 =cut
50  
51 294 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod documented
52 294 my $self = shift;
53 294 my %args = @_;
54 294 my $score = $args{score};
55 294 ▶ die "Bracket has score of: $score?" unless defined $score;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $score 0 294 294
56 294 bless \%args, $self;
57 294 $args{floatCheck} = "None";
58 294 return \%args;
59 }
60  
61  
62 =head2 natives
63  
64 @floaters = $group->natives
65  
66 Returns those members who were in this bracket originally, as that was their birthright, their scores being all the same. One is a native of only one bracket, and you cannot change this status except XXX EVEN by naturalization.
67  
68 =cut
69  
70 0 ▶sub natives {
Subroutine natives: not called CC=2 SCAR=17.9
Pod documented
71 0 my $self = shift;
72 0 ▶ return () unless @{ $self->members };
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->members;} 0 0 0
73 0 my $members = $self->members;
74 0 my $foreigners = $self->immigrants;
75 my @natives = grep {
76 0 my $member = $_->pairingNumber;
77 0 not grep { $member == $_->pairingNumber } @$foreigners
78 } @$members;
79 0 return \@natives;
80 }
81  
82  
83 =head2 citizens
84  
85 @floaters = $group->citizens
86  
87 Returns those members who belong to this bracket. These members don't include those have just floated in, even though this floating status may be permanent. One is a citizen of only one bracket, and you cannot change this status except by naturalization.
88  
89 =cut
90  
91 0 ▶sub citizens {
Subroutine citizens: not called CC=2 SCAR=17.9
Pod documented
92 0 my $self = shift;
93 0 ▶ return () unless @{ $self->members };
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->members;} 0 0 0
94 0 my $members = $self->members;
95 0 my $foreigners = $self->immigrants;
96 my @natives = grep {
97 0 my $member = $_->pairingNumber;
98 0 not grep { $member == $_->pairingNumber } @$foreigners
99 } @$members;
100 0 return \@natives;
101 }
102  
103  
104 =head2 naturalize
105  
106 $citizen = $group->naturalize($foreigner)
107  
108 Gives members who are resident, but not citizens, ie immigrants, having been floated here from other brackets, the same status as natives, making them indistinguishable from them. This will fail if the player is not resident or not an immigrant. Returns the player with their new status.
109  
110 =cut
111  
112 6 ▶sub naturalize {
Subroutine naturalize: called CC=4 SCAR=14.5
Pod documented
113 6 my $self = shift;
114 6 my $foreigner = shift;
115 6 my $members = $self->residents;
116 return unless any
117 6 ▶ { $_->pairingNumber == $foreigner->pairingNumber } @$members;
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
unless &any(sub { $_->pairingNumber == $foreigner->pairingNumber; } , @$members) 0 6 6
118 6 my $direction = $foreigner->floating;
119 6 ▶ return unless $direction eq 'Up' or $direction eq 'Down';
Branch: 1 branch
BranchTrueFalseTotal
unless $direction eq "Up" or $direction eq "Down" 0 6 6
Condition33%1/3
$direction eq "Up" or $direction eq "Down"
l!l&&r!l&&!r
060
MC/DC0%0/2
$direction eq "Up" or $direction eq "Down"
$direction eq "Up" $direction eq "Down"
Truth table33%1/3
A or B
A= $direction eq "Up"B= $direction eq "Down"
ABresult
1X1
011
000
120 6 $foreigner->floating('');
121 6 return $foreigner;
122 }
123  
124  
125 =head2 immigrants
126  
127 @floaters = @{$group->immigrants}
128  
129 Returns those members who are foreigners, having been floated here from other brackets. At any one point a player may or may not be a foreigner. But if they are, they only can be a foreigner in one bracket.
130  
131 =cut
132  
133 0 ▶sub immigrants {
Subroutine immigrants: not called CC=2 SCAR=17.9
Pod documented
134 0 my $self = shift;
135 0 ▶ return () unless @{ $self->members };
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->members;} 0 0 0
136 0 my $members = $self->residents;
137 0 my @immigrants = grep { $_->floating } @$members;
138 0 return \@immigrants;
139 }
140  
141  
142 =head2 downFloaters
143  
144 @floaters = $group->downFloaters
145  
146 Returns those members downfloated here from higher brackets.
147  
148 =cut
149  
150 1 ▶sub downFloaters {
Subroutine downFloaters: called CC=5 SCAR=16.5
Pod documented
151 1 my $self = shift;
152 1 my $members = $self->members;
153 1 ▶ return () unless @$members and $self->trueHetero;
Branch: 1 branch
BranchTrueFalseTotal
unless @$members and $self->trueHetero 0 1 1
Condition33%1/3
@$members and $self->trueHetero
!ll&&!rl&&r
001
MC/DC0%0/2
@$members and $self->trueHetero
@$members $self->trueHetero
Truth table33%1/3
A and B
A= @$membersB= $self->trueHetero
ABresult
0X0
100
111
154 1 my %members;
155 1 for my $member ( @$members )
156 {
157 3 ▶ my $score = defined $member->score? $member->score: 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $member->score ? : 3 0 3
158 3 push @{$members{$score}}, $member;
159 }
160 1 my $min = min keys %members;
161 1 delete $members{$min};
162 1 my @floaters = map { @$_ } values %members;
163 1 return @floaters;
164 }
165  
166  
167 =head2 upFloaters
168  
169 @s1 = $group->upFloaters
170  
171 Returns those members upfloated from the next bracket.
172  
173 =cut
174  
175 57 ▶sub upFloaters {
Subroutine upFloaters: called CC=3 SCAR=11.0
Pod documented
176 57 my $self = shift;
177 57 ▶ return () unless @{ $self->members };
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->members;} 0 57 57
178 57 my @members = $self->residents;
179 57 ▶ grep { $_->floating and $_->floating =~ m/^Up/i } @{ $self->members };
Condition100%3/3
$_->floating && $_->floating =~ /^Up/i
!ll&&!rl&&r
1472828
MC/DC100%2/2
$_->floating && $_->floating =~ /^Up/i
$_->floating $_->floating =~ /^Up/i
Truth table100%3/3
A && B
A= $_->floatingB= $_->floating =~ /^Up/i
ABresult
0X0
100
111
180 }
181  
182  
183 =head2 residents
184  
185 $pairables = $bracket->residents
186  
187 Returns the members includeable in pairing procedures for this bracket because they haven't been floated out, or because they have been floated in. That is, they are not an emigrant. At any one point, a player is resident in one and only one bracket, unless they are in transit. At some other point, they may be a resident of another bracket.
188  
189 =cut
190  
191 2267 ▶sub residents {
Subroutine residents: called CC=3 SCAR=11.2
Pod documented
192 2267 my $self = shift;
193 2267 my $members = $self->members;
194 2267 my @residents;
195 2267 my $floated = $self->emigrants;
196 2267 for my $member (@$members) {
197 push @residents, $member
198 0 ▶ unless any { $member->pairingNumber == $_->pairingNumber } @$floated;
Subroutine __ANON__: not called CC=1 SCAR=1.2
Branch: 1 branch
BranchTrueFalseTotal
unless &any(sub { $member->pairingNumber == $_->pairingNumber; } , @$floated) 8796 0 8796
199 }
200 2267 return \@residents;
201 }
202  
203  
204 =head2 emigrants
205  
206 $bracket->emigrants($member)
207 $gone = $bracket->emigrants
208  
209 Sets whether this citizen will not be included in pairing of this bracket. That is whether they have been floated to another bracket for pairing there. Gets all such members. A player may or may not be an emigrant. They can only stop being an emigrant if they move back to their native bracket. To do this, they have to be processed by 'entry'.
210  
211 =cut
212  
213 2267 ▶sub emigrants {
Subroutine emigrants: called CC=2 SCAR=7.9
Pod documented
214 2267 my $self = shift;
215 2267 my $floater = shift;
216 0 ▶ if ($floater) { push @{ $self->{gone} }, $floater; }
Branch: 1 branch
BranchTrueFalseTotal
if ($floater) { } 0 2267 2267
217 2267 else { return $self->{gone}; }
218 }
219  
220  
221 =head2 exit
222  
223 $bracket->exit($player)
224  
225 Removes $player from the list of members of the bracket. They are now in the air. So make sure they enter another bracket.
226  
227 =cut
228  
229 575 ▶sub exit {
Subroutine exit: called CC=2 SCAR=6.9
Pod documented
230 575 my $self = shift;
231 575 my $members = $self->members;
232 575 my $exiter = shift;
233 575 my $myId = $exiter->pairingNumber;
234 575 my @stayers = grep { $_->pairingNumber != $myId } @$members;
235 575 my $number = $self->number;
236 575 ▶ croak "Player $myId did not exit Bracket $number" if @stayers == @$members;
Branch: 1 branch
BranchTrueFalseTotal
if @stayers == @$members 0 575 575
237 575 $self->members(\@stayers);
238 #my $immigrants = $self->immigrants;
239 #if ( grep { $_ == $member } @$immigrants ) {
240 # @{ $self->members } = grep { $_ != $member } @$members;
241 #}
242 #else {
243 # $self->emigrants($member);
244 #}
245 575 return;
246 }
247  
248  
249 =head2 entry
250  
251 $bracket->entry($native)
252 $bracket->entry($foreigner)
253  
254 Registers $foreigner as a resident (and was removing $native from the list of emigrants of this bracket, because they have returned from another bracket as in C12, 13).
255  
256 =cut
257  
258 575 ▶sub entry {
Subroutine entry: called CC=2 SCAR=6.9
Pod documented
259 575 my $self = shift;
260 575 my $members = $self->residents;
261 575 my $enterer = shift;
262 575 my $myId = $enterer->id;
263 575 my $number = $self->number;
264 croak "Player $myId cannot enter Bracket $number. Is already there." if
265 575 ▶ any { $_->{id} eq $myId } @$members;
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
if &any(sub { $_->{"id"} eq $myId; } , @$members) 0 575 575
266 575 unshift @$members, $enterer;
267 575 $self->members(\@$members);
268 575 return;
269 }
270  
271  
272 =head2 reentry
273  
274 $bracket->reentry($member)
275  
276 Removes this native (presumably) member from the list of emigrants of this bracket, because they have returned from another bracket as in C12, 13. Returns undef, if $member wasn't an emigrant. Otherwise returns the updated list of emigrants.
277  
278 =cut
279  
280 0 ▶sub reentry {
Subroutine reentry: not called CC=2 SCAR=17.9
Pod documented
281 0 my $self = shift;
282 0 my $returnee = shift;
283 0 my $emigrants = $self->emigrants;
284 0 ▶ if ( any { $_->pairingNumber == $returnee->pairingNumber } @$emigrants ) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (&any(sub { $_->pairingNumber == $returnee->pairingNumber; } , @$emigrants)) 0 0 0
285 my @nonreturnees = grep {
286 0 $_->pairingNumber != $returnee->pairingNumber } @$emigrants;
287 # @{ $self->{gone} } = @nonreturnees;
288 0 $self->{gone} = \@nonreturnees;
289 0 return @nonreturnees;
290 }
291 #my @updatedlist = grep { $_->id != $returnee->id } @$emigrants;
292 #$self->emigrants($_) for @updatedlist;
293 #return @updatedlist if grep { $_->id == $returnee->id } @$emigrants;
294 0 return;
295  
296 }
297  
298  
299 =head2 dissolved
300  
301 $group->dissolved(1)
302 $s1 = $group->s1($players)
303 $s1 = $group->s1
304  
305 Dissolve a bracket, so it is no longer independent, its affairs being controlled by some other group:
306  
307 =cut
308  
309 6949 ▶sub dissolved {
Subroutine dissolved: called CC=4 SCAR=13.9
Pod documented
310 6949 my $self = shift;
311 6949 my $flag = shift;
312 6949 ▶ if ( defined $flag )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $flag) { } 64 6885 6949
313 {
314 64 $self->{dissolved} = $flag;
315 64 ▶ return $flag? 1: 0;
Branch: 1 branch
BranchTrueFalseTotal
$flag ? : 64 0 64
316 }
317 else {
318 6885 ▶ return $self->{dissolved}? 1: 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'dissolved'} ? : 1802 5083 6885
319 }
320 }
321  
322  
323 =head2 s1
324  
325 $group->s1
326 $s1 = $group->s1($players)
327 $s1 = $group->s1
328  
329 Getter/setter of the p players in the top half of a homogeneous bracket, or the p downFloaters in a heterogeneous bracket, as an array. A6
330  
331 =cut
332  
333 7107 ▶sub s1 {
Subroutine s1: called CC=3 SCAR=11.0
Pod documented
334 7107 my $self = shift;
335 7107 my $s1 = shift;
336 7107 ▶ if ( defined $s1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $s1) { } 1988 5119 7107
elsif ($self->{'s1'}) { } 5111 8 5119
337 1988 $self->{s1} = $s1;
338 1988 return $s1;
339 }
340 5111 elsif ( $self->{s1} ) { return $self->{s1}; }
341 8 else { $self->resetS12; return $self->{s1}; }
342 }
343  
344  
345 =head2 s2
346  
347 $s2 = $group->s2
348  
349 Getter/Setter of the players in a homogeneous or a heterogeneous bracket who aren't in S1. A6
350  
351 =cut
352  
353 11695 ▶sub s2 {
Subroutine s2: called CC=3 SCAR=11.4
Pod documented
354 11695 my $self = shift;
355 11695 my $s2 = shift;
356 11695 ▶ if ( defined $s2 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $s2) { } 3237 8458 11695
elsif ($self->{'s2'}) { } 8458 0 8458
357 3237 $self->{s2} = $s2;
358 3237 return $s2;
359 }
360 8458 elsif ( $self->{s2} ) { return $self->{s2}; }
361 0 else { $self->resetS12; return $self->{s2}; }
362 }
363  
364  
365 =head2 resetS12
366  
367 $group->resetS12
368  
369 Resetter of S1 and S2 to the original members, ranked before exchanges in C8. A6
370  
371 =cut
372  
373 1188 ▶sub resetS12 {
Subroutine resetS12: called CC=6 SCAR=17.9
Pod documented
374 1188 my $self = shift;
375 1188 my $number = $self->number;
376 1188 my $members = $self->residents;
377 1188 ▶ return [] unless $#$members >= 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $members->$#* >= 1 0 1188 1188
378 1188 my (@s1, @s2);
379 32 ▶ use Games::Tournament;
Subroutine BEGIN: called CC=1 SCAR=0.0
380 1188 ▶ if ( $self->hetero ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->hetero) { } 149 1039 1188
381 149 my %scorers;
382 149 for my $member (@$members)
383 {
384 694 ▶ my $score = defined $member->score? $member->score: 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $member->score ? : 692 2 694
385 694 push @{ $scorers{$score} }, $member;
386 }
387 149 my @scores = reverse sort { $a <=> $b } keys %scorers;
388 #carp @scores . " different scores in Hetero Bracket $number"
389 # if @scores > 2;
390 149 @s2 = @{$scorers{$scores[-1]}};
391 149 my %s2 = map { $_->pairingNumber => $_ } @s2;
392 149 @s1 = grep { not exists $s2{$_->pairingNumber} } $self->rank(@$members);
393 }
394 else {
395 1039 my $p = $self->p;
396 1039 @s1 = ( $self->rank(@$members) )[ 0 .. $p - 1 ];
397 1039 @s2 = ( $self->rank(@$members) )[ $p .. $#$members ];
398 }
399 1188 $self->s1(\@s1);
400 1188 $self->s2(\@s2);
401 1188 my @lastS2ids = reverse map { $_->pairingNumber } @s2;
402 1188 $self->{lastS2ids} = \@lastS2ids;
403 1188 ▶ die "undef player in Bracket $number S1, S2" if any { not defined } @s1, @s2;
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
if &any(sub { not defined $_; } , @s1, @s2) 0 1188 1188
404 1188 return;
405 }
406  
407  
408 =head2 resetShuffler
409  
410 $previous->entry($_) for @returnees;
411 $previous->resetShuffler;
412 return C7;
413  
414 Take precautions to prevent transposing players who are no longer in the bracket in S2, or to make sure they ARE transposed, when finding a different pairing, before returning from C10,12,13 (C11?). Do this by resetting S1 and S2. Don't use this in the wrong place. We don't want to try the same pairing twice.
415  
416 =cut
417  
418 60 ▶sub resetShuffler {
Subroutine resetShuffler: called CC=4 SCAR=14.0
Pod documented
419 60 my $self = shift;
420 60 my $members = $self->members;
421 60 my $s1 = $self->s1;
422 60 my $s2 = $self->s2;
423 60 my %s1 = map { $_->pairingNumber => $_ } @$s1;
424 60 my %s2 = map { $_->pairingNumber => $_ } @$s2;
425 60 my %members = map { $_->pairingNumber => $_ } @$members;
426 # my %tally; @tally{keys %members} = (0) x keys %members;
427 65 ▶ my $memberChangeTest = ( (notall { exists $members{$_} } keys %s1) or
Subroutine __ANON__: called CC=1 SCAR=0.0
428 60 ▶ (notall { exists $members{$_} } keys %s2) or (@$s1 + @$s2 != @$members));
Subroutine __ANON__: called CC=1 SCAR=0.5
Condition50%3/6
&notall(sub { exists $members{$_}; } , keys %s1) || &notall(sub { exists $members{$_}; } , keys %s2) || @$s1 + @$s2 != @$members
l!l&&r!l&&!r
0159
&notall(sub { exists $members{$_}; } , keys %s1) or &notall(sub { exists $members{$_}; } , keys %s2)
l!l&&r!l&&!r
0060
MC/DC33%1/3
&notall(sub { exists $members{$_}; } , keys %s1) || &notall(sub { exists $members{$_}; } , keys %s2) || @$s1 + @$s2 != @$members
&notall(sub { exists $members{$_}; } , keys %s1) &notall(sub { exists $members{$_}; } , keys %s2) @$s1 + @$s2 != @$members
Truth table50%2/4
A or B || C
A= &notall(sub { exists $members{$_}; } , keys %s1)B= &notall(sub { exists $members{$_}; } , keys %s2)C= @$s1 + @$s2 != @$members
ABCresult
1XX1
01X1
0011
0000
429 60 ▶ $self->resetS12 if $memberChangeTest;
Branch: 1 branch
BranchTrueFalseTotal
if $memberChangeTest 1 59 60
430 }
431  
432  
433 =head2 p
434  
435 $tables = $group->p
436  
437 Half the number of players in a homogeneous bracket, rounded down to the next lowest integer. Or the number of down floaters in a heterogeneous bracket. Also the number of players in S1, and thus the number of pairings in the pair group. If there are more downfloaters than original members, half the number of players. (See A1,2)A6
438  
439 =cut
440  
441 3573 ▶sub p {
Subroutine p: called CC=7 SCAR=19.6
Pod documented
442 3573 my $self = shift;
443 3573 my $members = $self->members;
444 3573 my $n = @$members;
445 3573 ▶ return 0 unless $n >= 2;
Branch: 1 branch
BranchTrueFalseTotal
unless $n >= 2 0 3573 3573
446 3573 my $p;
447 3573 ▶ if ( $self->hetero ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->hetero) { } 378 3195 3573
448 378 my %scorers;
449 378 for my $member ( @$members ) {
450 1926 ▶ my $score = defined $member->score? $member->score: 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $member->score ? : 1921 5 1926
451 1926 $scorers{$score}++;
452 }
453 378 my $lowestScore = min keys %scorers;
454 378 ▶ return unless defined $lowestScore;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lowestScore 0 378 378
455 378 $p = $n - $scorers{$lowestScore};
456 378 ▶ $p = int( $n / 2 ) if $p > $n/2;
Branch: 1 branch
BranchTrueFalseTotal
if $p > $n / 2 0 378 378
457 }
458 else {
459 3195 $p = int( $n / 2 );
460 }
461 3573 return $p;
462 }
463  
464  
465 =head2 bigGroupP
466  
467 $tables = $group->bigGroupP
468  
469 Half the number of players in a big bracket (group), rounded down to the next lowest integer. Sometimes the number of pairs in a combined bracket, particularly, a heterogeneous bracket and its remainder group is needed. In such cases, p will be just the number of downfloated players, which is not what we want. In a non-heterogeneous bracket, bigGroupP will be the same as p. See C11
470  
471 =cut
472  
473 29 ▶sub bigGroupP {
Subroutine bigGroupP: called CC=4 SCAR=14.4
Pod documented
474 29 my $self = shift;
475 29 my $members = $self->members;
476 29 my $n = @$members;
477 29 ▶ if ( $self->{remainderof} )
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'remainderof'}) { } 17 12 29
elsif ($self->{'remaindered'}) { } 0 12 12
478 {
479 17 my $remaindered = $self->{remainderof}->members;
480 17 $n += @$remaindered;
481 }
482 elsif ( $self->{remaindered} ) {
483 0 my $heteroMembers = $self->{remainder}->members;
484 0 $n += @$heteroMembers;
485 }
486 29 ▶ return 0 unless $n >= 2;
Branch: 1 branch
BranchTrueFalseTotal
unless $n >= 2 0 29 29
487 29 my $p = int( $n / 2 );
488 29 return $p;
489 }
490  
491  
492 =head2 pprime
493  
494 $tables = $group->pprime
495  
496 p is half the number of players in a bracket, but we may have to accept fewer pairings than this number if suitable opponents cannot be found for players, up to the point where p=0. pprime sets/gets this real p number. A8
497  
498 =cut
499  
500 2085 ▶sub pprime {
Subroutine pprime: called CC=3 SCAR=11.0
Pod documented
501 2085 my ( $self, $p ) = @_;
502 2085 my $pprime = $self->{pprime};
503 2085 ▶ if ( defined $p ) { $self->{pprime} = $p; }
Branch: 2 branches
BranchTrueFalseTotal
if (defined $p) { } 194 1891 2085
elsif (defined $pprime) { } 1884 7 1891
504 1884 elsif ( defined $pprime ) { return $pprime; }
505 else {
506 7 $self->{pprime} = $self->p;
507 7 return $self->{pprime};
508 }
509 }
510  
511  
512 =head2 bigGroupPprime
513  
514 $tables = $group->bigGroupPprime
515  
516 bigGroupP is half the number of players in a heterogeneous bracket and its remainder group, but we may have to accept fewer pairings than this number if suitable opponents cannot be found for players, up to the point where no players are paired. bigGroupPprime sets/gets this real p number for the combined groups/brackets. A8
517  
518 =cut
519  
520 37 ▶sub bigGroupPprime {
Subroutine bigGroupPprime: called CC=5 SCAR=21.6
Pod documented
521 37 my ( $self, $p ) = @_;
522 37 my $bigGroupPprime = $self->{biggrouppprime};
523 37 ▶ if ( defined $p ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $p) { } 0 37 37
elsif (defined $bigGroupPprime) { } 8 29 37
524 0 $self->{biggrouppprime} = $p;
525 0 ▶ if ( $self->{remainderof} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'remainderof'}) { } 0 0 0
elsif ($self->{'remainder'}) { } 0 0 0
526 0 $self->{remainderof}->{biggrouppprime} = $p;
527 }
528 elsif ( $self->{remainder} ) {
529 0 $self->{remainder}->{biggrouppprime} = $p;
530 }
531 0 return;
532 }
533 8 elsif ( defined $bigGroupPprime ) { return $bigGroupPprime; }
534 else {
535 29 $self->{biggrouppprime} = $self->bigGroupP;
536 29 return $self->{biggrouppprime};
537 }
538 }
539  
540  
541 =head2 q
542  
543 $tables = $group->q
544  
545 Number of players in the score bracket divided by 2 and then rounded up. In a homogeneous group with an even number of players, this is the same as p. A8
546  
547 =cut
548  
549 326 ▶sub q {
Subroutine q: called CC=2 SCAR=6.9
Pod documented
550 326 my $self = shift;
551 326 my $players = $self->members;
552 326 ▶ my $q = @$players % 2 ? ( $#$players + 2 ) / 2 : ( $#$players + 1 ) / 2;
Branch: 1 branch
BranchTrueFalseTotal
@$players % 2 ? : 177 149 326
553 }
554  
555  
556 =head2 x
557  
558 $tables = $group->x
559  
560 Sets the number, ranging from zero to p, of matches in the score bracket in which players will have their preferences unsatisfied. A8
561  
562 =cut
563  
564 233 ▶sub x {
Subroutine x: called CC=3 SCAR=11.0
Pod documented
565 233 my $self = shift;
566 233 my $players = $self->residents;
567 466 ▶ my $numbers = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
568 466 my $n = shift;
569 return scalar grep {
570 466 ▶ $_->preference->role and $_->preference->role eq (ROLES)[$n] }
Condition100%3/3
$_->preference->role && $_->preference->role eq (&ROLES())[$n]
!ll&&!rl&&r
226850850
MC/DC100%2/2
$_->preference->role && $_->preference->role eq (&ROLES())[$n]
$_->preference->role $_->preference->role eq (&ROLES())[$n]
Truth table100%3/3
A && B
A= $_->preference->roleB= $_->preference->role eq (&ROLES())[$n]
ABresult
0X0
100
111
571 @$players;
572 233 };
573 233 my $w = $numbers->(0);
574 233 my $b = $numbers->(1);
575 233 my $q = $self->q;
576 233 ▶ my $x = $w >= $b ? $w - $q : $b - $q;
Branch: 1 branch
BranchTrueFalseTotal
$w >= $b ? : 180 53 233
577 233 ▶ $self->{x} = $x < 0? 0: $x;
Branch: 1 branch
BranchTrueFalseTotal
$x < 0 ? : 41 192 233
578 }
579  
580  
581 =head2 bigGroupX
582  
583 $tables = $group->bigGroupX
584  
585 x is okay for a homogeneous group, uncombined with other groups, but in the case of groups that are interacting to form joined brackets, or in that of a heterogeneous bracket and a remainder group, we need a bigGroupX to tell us how many matches in the total number, ranging from zero to bigGroupP, of matches in the score bracket(s) will have players with unsatisfied preferences. A8
586  
587 =cut
588  
589 93 ▶sub bigGroupX {
Subroutine bigGroupX: called CC=5 SCAR=16.4
Pod documented
590 93 my $self = shift;
591 93 my $players = $self->members;
592 my $w =
593 93 ▶ grep { $_->preference->role and $_->preference->role eq (ROLES)[0] }
Condition100%3/3
$_->preference->role && $_->preference->role eq (&ROLES())[0]
!ll&&!rl&&r
38204194
MC/DC100%2/2
$_->preference->role && $_->preference->role eq (&ROLES())[0]
$_->preference->role $_->preference->role eq (&ROLES())[0]
Truth table100%3/3
A && B
A= $_->preference->roleB= $_->preference->role eq (&ROLES())[0]
ABresult
0X0
100
111
594 @$players;
595 93 my $b = @$players - $w;
596 93 my $q = $self->q;
597 93 ▶ my $x = $w >= $b ? $w - $q : $b - $q;
Branch: 1 branch
BranchTrueFalseTotal
$w >= $b ? : 39 54 93
598 93 my $bigGroupX = $x;
599 0 ▶ if ( $self->{remainderof} ) { $bigGroupX += $self->{remainderof}->x; }
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'remainderof'}) { } 0 93 93
elsif ($self->{'remainder'}) { } 0 93 93
600 0 elsif ( $self->{remainder} ) { $bigGroupX += $self->{remainder}->x; }
601 93 $self->{biggroupx} = $bigGroupX;
602 93 return $self->{biggroupx};
603 }
604  
605  
606 =head2 bigGroupXprime
607  
608 $tables = $group->bigGroupXprime
609  
610 xprime is a revised upper limit on matches where preferences are not satisfied, but in the case of a combined bracket (in particular, a heterogeneous bracket and a remainder group) we need a figure for the total number of preference-violating matches over the 2 sections, because the distribution of such matches may change. bigGroupXprime sets/gets this total x number. A8
611  
612 =cut
613  
614 244 ▶sub bigGroupXprime {
Subroutine bigGroupXprime: called CC=9 SCAR=22.1
Pod documented
615 244 my $self = shift;
616 244 my $x = shift;
617 244 my $xprime = $self->{biggroupxprime};
618 244 ▶ if ( defined $x ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $x) { } 5 239 244
elsif (defined $xprime) { } 72 167 239
619 5 $self->{biggroupxprime} = $x;
620 5 ▶ if ( $self->{remainderof} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'remainderof'}) { } 0 5 5
elsif ($self->{'remainder'}) { } 5 0 5
621 0 $self->{remainderof}->{biggroupxprime} = $x;
622 }
623 elsif ( $self->{remainder} ) {
624 5 $self->{remainder}->{biggroupxprime} = $x
625 }
626 5 return; }
627 72 elsif ( defined $xprime ) { return $xprime; }
628 else {
629 167 ▶ if ( $self->{remainderof} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'remainderof'}) { } 21 146 167
elsif ($self->{'remainder'}) { } 53 93 146
630 21 my $x = $self->{remainderof}->{biggroupxprime};
631 21 ▶ return $x if defined $x;
Branch: 1 branch
BranchTrueFalseTotal
if defined $x 18 3 21
632 }
633 elsif ( $self->{remainder} ) {
634 53 $x = $self->{remainder}->{biggroupxprime};
635 53 ▶ return $x if defined $x;
Branch: 1 branch
BranchTrueFalseTotal
if defined $x 0 53 53
636 }
637 93 else { return $self->bigGroupX; }
638 }
639 }
640  
641  
642 =head2 xprime
643  
644 $tables = $group->xprime
645  
646 x is the lower limit on matches where preferences are not satisfied, but the number of such undesirable matches may be increased if suitable opponents cannot be found for players, up to the point where only players with Absolute preferences have their preferences satisfied. xprime sets/gets this real x number. A8
647  
648 =cut
649  
650 1724 ▶sub xprime {
Subroutine xprime: called CC=3 SCAR=11.0
Pod documented
651 1724 my $self = shift;
652 1724 my $x = shift;
653 1724 my $xprime = $self->{xprime};
654 1724 ▶ if ( defined $x ) { $self->{xprime} = $x; return; }
Branch: 2 branches
BranchTrueFalseTotal
if (defined $x) { } 77 1647 1724
elsif (defined $xprime) { } 1559 88 1647
655 1559 elsif ( defined $xprime ) { return $xprime; }
656 else {
657 88 $self->{xprime} = $self->x;
658 88 return $self->{xprime};
659 }
660 }
661  
662  
663 =head2 floatCheckWaive
664  
665 $tables = $group->floatCheckWaive
666  
667 There is an ordered sequence in which the checks of compliance with the Relative Criteria B5,6 restriction on recurring floats are relaxed in C9,10. The order is 1. downfloats for players downfloated 2 rounds before, 2. downfloats for players downfloated in the previous round (in C9), 3. upfloats for players floated up 2 rounds before, 4. upfloats for players floated up in the previous round (for players paired with opponents from a higher bracket in a heterogeneous bracket, in C10). (It appears levels are being skipped, eg from B6Down to B6Up or from All to B6Down.) Finally, although it is not explicitly stated, all float checks must be dropped and pairings considered again, before reducing the number of pairs made in the bracket. (This is not entirely correct.) This method sets/gets the float check waive level at the moment. All criteria below that level should be checked for compliance. The possible values in order are 'None', 'B6Down', 'B5Down', 'B6Up', 'B5Up', 'All'. TODO Should there be some way of not requiring the caller to know how to use this method and what the levels are.
668  
669 =cut
670  
671 1189 ▶sub floatCheckWaive {
Subroutine floatCheckWaive: called CC=22 SCAR=33.3
Pod documented
672 1189 my $self = shift;
673 1189 my $number = $self->number;
674 1189 my $level = shift;
675 1189 ▶ warn "Unknown float level: $level" if
Branch: 1 branch
BranchTrueFalseTotal
if $level and not $level =~ /^(?:None|B6Down|B5Down|B6Up|B5Up|All)$/i 0 1189 1189
Condition66%2/3
$level and not $level =~ /^(?:None|B6Down|B5Down|B6Up|B5Up|All)$/i
!ll&&!rl&&r
9672220
MC/DC0%0/2
$level and not $level =~ /^(?:None|B6Down|B5Down|B6Up|B5Up|All)$/i
$level not $level =~ /^(?:None|B6Down|B5Down|B6Up|B5Up|All)$/i
Truth table66%2/3
A and not(B)
A= $levelB= not $level =~ /^(?:None|B6Down|B5Down|B6Up|B5Up|All)$/i
ABresult
0X0
100
111
676 $level and $level !~ m/^(?:None|B6Down|B5Down|B6Up|B5Up|All)$/i;
677 1189 my $oldLevel = $self->{floatCheck};
678 1189 ▶ if ( defined $level ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $level) { } 222 967 1189
elsif (defined $self->{'floatCheck'}) { } 967 0 967
679 222 ▶ warn
Branch: 1 branch
BranchTrueFalseTotal
unless $level eq "None" or $oldLevel eq "None" and $level eq "B6Down" or $oldLevel eq "B6Down" and $level eq "B5Down" or $oldLevel eq "B6Down" and $level eq "B6Up" or $oldLevel eq "B5Down" and $level eq "B6Up" or $oldLevel eq "B6Up" and $level eq "B5Up" or $oldLevel eq "B5Up" and $level eq "All" or $oldLevel eq "All" and $level eq "None" or $oldLevel eq "All" and $level eq "B6Down" 0 222 222
Condition77%37/48
$level eq "None" or $oldLevel eq "None" and $level eq "B6Down" or $oldLevel eq "B6Down" and $level eq "B5Down" or $oldLevel eq "B6Down" and $level eq "B6Up" or $oldLevel eq "B5Down" and $level eq "B6Up" or $oldLevel eq "B6Up" and $level eq "B5Up" or $oldLevel eq "B5Up" and $level eq "All" or $oldLevel eq "All" and $level eq "None" or $oldLevel eq "All" and $level eq "B6Down"
l!l&&r!l&&!r
22110
$level eq "None" or $oldLevel eq "None" and $level eq "B6Down" or $oldLevel eq "B6Down" and $level eq "B5Down" or $oldLevel eq "B6Down" and $level eq "B6Up" or $oldLevel eq "B5Down" and $level eq "B6Up" or $oldLevel eq "B6Up" and $level eq "B5Up" or $oldLevel eq "B5Up" and $level eq "All" or $oldLevel eq "All" and $level eq "None"
l!l&&r!l&&!r
22101
$level eq "None" or $oldLevel eq "None" and $level eq "B6Down" or $oldLevel eq "B6Down" and $level eq "B5Down" or $oldLevel eq "B6Down" and $level eq "B6Up" or $oldLevel eq "B5Down" and $level eq "B6Up" or $oldLevel eq "B6Up" and $level eq "B5Up" or $oldLevel eq "B5Up" and $level eq "All"
l!l&&r!l&&!r
201201
$level eq "None" or $oldLevel eq "None" and $level eq "B6Down" or $oldLevel eq "B6Down" and $level eq "B5Down" or $oldLevel eq "B6Down" and $level eq "B6Up" or $oldLevel eq "B5Down" and $level eq "B6Up" or $oldLevel eq "B6Up" and $level eq "B5Up"
l!l&&r!l&&!r
1772421
$level eq "None" or $oldLevel eq "None" and $level eq "B6Down" or $oldLevel eq "B6Down" and $level eq "B5Down" or $oldLevel eq "B6Down" and $level eq "B6Up" or $oldLevel eq "B5Down" and $level eq "B6Up"
l!l&&r!l&&!r
1512645
$level eq "None" or $oldLevel eq "None" and $level eq "B6Down" or $oldLevel eq "B6Down" and $level eq "B5Down" or $oldLevel eq "B6Down" and $level eq "B6Up"
l!l&&r!l&&!r
149271
$level eq "None" or $oldLevel eq "None" and $level eq "B6Down" or $oldLevel eq "B6Down" and $level eq "B5Down"
l!l&&r!l&&!r
886173
$level eq "None" or $oldLevel eq "None" and $level eq "B6Down"
l!l&&r!l&&!r
2167134
$oldLevel eq "None" and $level eq "B6Down"
!ll&&!rl&&r
134067
$oldLevel eq "B6Down" and $level eq "B5Down"
!ll&&!rl&&r
71261
$oldLevel eq "B6Down" and $level eq "B6Up"
!ll&&!rl&&r
7102
$oldLevel eq "B5Down" and $level eq "B6Up"
!ll&&!rl&&r
45026
$oldLevel eq "B6Up" and $level eq "B5Up"
!ll&&!rl&&r
21024
$oldLevel eq "B5Up" and $level eq "All"
!ll&&!rl&&r
1020
$oldLevel eq "All" and $level eq "None"
!ll&&!rl&&r
010
$oldLevel eq "All" and $level eq "B6Down"
!ll&&!rl&&r
001
MC/DC0%0/17
$level eq "None" or $oldLevel eq "None" and $level eq "B6Down" or $oldLevel eq "B6Down" and $level eq "B5Down" or $oldLevel eq "B6Down" and $level eq "B6Up" or $oldLevel eq "B5Down" and $level eq "B6Up" or $oldLevel eq "B6Up" and $level eq "B5Up" or $oldLevel eq "B5Up" and $level eq "All" or $oldLevel eq "All" and $level eq "None" or $oldLevel eq "All" and $level eq "B6Down"
too many conditions
680 "Bracket [$number]'s old float check waive level, $oldLevel is now $level."
681 unless $level eq 'None' or
682 $oldLevel eq 'None' and $level eq 'B6Down' or
683 $oldLevel eq 'B6Down' and $level eq 'B5Down' or
684 $oldLevel eq 'B6Down' and $level eq 'B6Up' or
685 $oldLevel eq 'B5Down' and $level eq 'B6Up' or
686 $oldLevel eq 'B6Up' and $level eq 'B5Up' or
687 $oldLevel eq 'B5Up' and $level eq 'All' or
688 # $oldLevel eq 'B5Down' and $level eq 'All' or
689 $oldLevel eq 'All' and $level eq 'None' or
690 $oldLevel eq 'All' and $level eq 'B6Down';
691 222 $self->{floatCheck} = $level;
692 }
693 967 elsif ( defined $self->{floatCheck} ) { return $self->{floatCheck}; }
694 0 else { return; }
695 }
696  
697  
698 =head2 hetero
699  
700 $group->hetero
701  
702 Gets (but doesn't set) whether this group is heterogeneous, ie includes players who have been downfloated from a higher score group, or upfloated from a lower score group, or if it is homogeneous, ie every player has the same score. A group where half or more of the members have come from a higher bracket is regarded as homogeneous. We use the scores of the players, rather than a floating flag.
703  
704 =cut
705  
706 6980 ▶sub hetero {
Subroutine hetero: called CC=7 SCAR=19.6
Pod documented
707 6980 my $self = shift;
708 6980 my @members = @{$self->members};
709 6980 my %tally;
710 6980 for my $member ( @members ) {
711 33640 ▶ my $score = defined $member->score? $member->score: 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $member->score ? : 31184 2456 33640
712 33640 $tally{$score}++ ;
713 }
714 6980 my @range = keys %tally;
715 6980 ▶ return 0 if @range == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @range == 1 5207 1773 6980
716 1773 my $min = min @range;
717 1773 ▶ return unless defined $min;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $min 0 1773 1773
718 1773 ▶ return 0 if $tally{$min} <= @members/2;
Branch: 1 branch
BranchTrueFalseTotal
if $tally{$min} <= @members / 2 657 1116 1773
719 1116 ▶ return 1 if $tally{$min} > @members/2;
Branch: 1 branch
BranchTrueFalseTotal
if $tally{$min} > @members / 2 1116 0 1116
720 0 return;
721 }
722  
723  
724 =head2 trueHetero
725  
726 $group->trueHetero
727  
728 Gets whether this group is really heterogeneous, ie includes players with different scores, because they been downfloated from a higher score group, or upfloated from a lower score group, even if it is being treated as homogeneous. A group where half or more of the members have come from a higher bracket is regarded as homogeneous, but it is really heterogeneous.
729  
730 =cut
731  
732 1 ▶sub trueHetero {
Subroutine trueHetero: called CC=5 SCAR=16.4
Pod documented
733 1 my $self = shift;
734 1 my @members = @{$self->members};
735 1 my %tally;
736 1 for my $member ( @members ) {
737 3 ▶ my $score = defined $member->score? $member->score: 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $member->score ? : 3 0 3
738 3 $tally{$score}++;
739 }
740 1 my @range = keys %tally;
741 1 ▶ return unless @range;
Branch: 1 branch
BranchTrueFalseTotal
unless @range 0 1 1
742 1 ▶ return 0 if @range == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @range == 1 0 1 1
743 1 return 1;
744 }
745  
746  
747 =head2 c7shuffler
748  
749 $nextS2 = $bracket->c7shuffler($firstmismatch)
750 if ( @nextS2 compatible )
751 {
752 create match cards;
753 }
754  
755 Gets the next permutation of the second-half players in D1 transposition counting order, as used in C7, that will not have the same incompatible player in the bad position found in the present transposition. If you get an illegal modulus error, check your $firstmismatch is a possible value.
756  
757 =cut
758  
759 1719 ▶sub c7shuffler {
Subroutine c7shuffler: called CC=10 SCAR=23.1
Pod documented
760 1719 my $self = shift;
761 1719 my $position = shift;
762 1719 my $bigLastGroup = shift;
763 1719 my $s2 = $self->s2;
764 1719 ▶ die "C7 shuffle: pos $position past end of S2" if $position > $#$s2;
Branch: 1 branch
BranchTrueFalseTotal
if $position > $s2->$#* 0 1719 1719
765 1719 my @players = $self->rank(@$s2);
766 1719 ▶ @players = $self->reverseRank(@$s2) if $bigLastGroup;
Branch: 1 branch
BranchTrueFalseTotal
if $bigLastGroup 0 1719 1719
767 # my @players = @$s2;
768 1719 my $p = $self->p;
769 1719 my @pattern;
770 1719 my @copy = @players;
771 1719 for my $i ( 0 .. $#$s2 ) {
772 5381 my $j = 0;
773 5381 ▶ $j++ until $s2->[$i]->pairingNumber == $copy[$j]->pairingNumber;
Branch: 1 branch
BranchTrueFalseTotal
$s2->[$i]->pairingNumber == $copy[$j]->pairingNumber or do { ++$j } 5381 2849 8230
774 5381 $pattern[$i] = $j;
775 5381 splice @copy, $j, 1;
776 }
777 1719 my $value = $pattern[$position];
778 1719 my @nextPattern;
779 1719 @nextPattern[ 0 .. $position ] = @pattern[ 0 .. $position ];
780 1719 @nextPattern[ $position + 1 .. $#pattern ] =
781 (0) x ( $#pattern - $position );
782 1719 for my $digit ( reverse( 0 .. $position ) ) {
783 2730 ▶ die "${digit}th digit overrun of @pattern \@pattern" if
Branch: 1 branch
BranchTrueFalseTotal
if @pattern == $digit 0 2730 2730
784 @pattern == $digit;
785 2730 $nextPattern[$digit] = ++$value % ( @pattern - $digit );
786 2730 ▶ last unless $nextPattern[$digit] == 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $nextPattern[$digit] == 0 1249 1481 2730
787 }
788 1481 continue { $value = $pattern[ $digit - 1 ]; }
789 1719 ▶ return unless grep { $_ } @nextPattern;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_;} @nextPattern 470 1249 1719
790 1249 my @permutation;
791 1249 for my $pos (@nextPattern) {
792 4259 push @permutation, splice( @players, $pos, 1 );
793 }
794 1249 return @permutation;
795  
796 #my @selectS2 = $group->c7shuffler($badpair);
797 #my @unselectS2 = @$s2;
798 #for my $position ( 0 .. $#$s2 )
799 #{
800 # my $player = $s2->[$#$s2 - $position];
801 # splice @unselectS2, $#$s2 - $position, 1 if grep{$_ eq $player} @selectS2;
802 #}
803 #my @newS2 = (@selectS2, @unselectS2);
804 }
805  
806  
807 =head2 c7iterator
808  
809 $next = $bracket->c7iterator
810 while ( my @s2 = &$next )
811 {
812 create match cards unless this permutation is incompatible;
813 }
814  
815 DEPRECATED Creates an iterator for the permutation of the second-half players in D1 transposition counting order, as used in C7. Only as many players as are in S1 can be matched, so we get only the permutations of all the p-length combinations of members of S2. Deprecated because if C1 or C6 finds a player in a certain position in S2 should not be paired with the player in the corresponding position in S1, we need to be able to skip ahead to the next permutation where a different player is in that position.
816  
817 =cut
818  
819 0 ▶sub c7iterator {
Subroutine c7iterator: not called CC=1 SCAR=6.9
Pod documented
820 0 my $self = shift;
821 0 my $players = $self->s2;
822 0 my $p = $self->p;
823 0 my $n = 0;
824 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
825 0 my @pattern = n_to_pat->( $n, $#$players + 1, $p );
826 0 my @result = permGenerator->( \@pattern, $players );
827 0 print "transposition $n:\t";
828 0 $n++;
829 0 return @result;
830 0 };
831 0 ▶ my $permGenerator = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
832 0 my $pattern = shift;
833 0 my @items = @{ shift() };
834 0 my @r;
835 0 for my $pos (@$pattern) {
836 0 push @r, splice( @items, $pos, 1 );
837 }
838 0 return @r;
839 0 };
840 0 ▶ my $n_to_pat = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
841 0 my @odometer;
842 0 my ( $n, $length, $k ) = @_;
843 0 for my $i ( $length - $k + 1 .. $length ) {
844 0 unshift @odometer, $n % $i;
845 0 $n = int( $n / $i );
846 }
847 0 ▶ return $n ? () : @odometer;
Branch: 1 branch
BranchTrueFalseTotal
$n ? : 0 0 0
848 0 };
849 }
850  
851  
852 =head2 c8iterator
853  
854 $next = $bracket->c8iterator
855 while ( my @members = &$next )
856 {
857 next if grep {$incompat{$s1[$_]}{$s2[$_]}} 0..$p-1);
858 }
859  
860 Creates an iterator for the exchange of @s1 and @s2 players in D2 order, as used in C8. Exchanges are performed in order of the difference between the pairing numbers of the players exchanged. If the difference is equal, the exchange with the lowest player is to be performed first. XXX Only as many players as in S1 can be matched, so does this mean some exchanges don't have an effect? I don't understand the description when there are an odd number of players. There appears to be a bug with only 3 players. 1 and 2 should be swapped, I think. I think the order of exchanges of 2 players each may also have some small inconsistencies with the FIDE order.
861  
862 =cut
863  
864 247 ▶sub c8iterator {
Subroutine c8iterator: called CC=5 SCAR=16.1
Pod documented
865 247 my $self = shift;
866 247 my $letter = 'a';
867 247 my $p = $self->p;
868 247 my $oddBracket = @{$self->members} % 2;
869 247 my @exchanges;
870 247 ▶ unless ($oddBracket)
Branch: 2 branches
BranchTrueFalseTotal
if ($oddBracket) { } 85 162 247
if (do { $oddBracket }) 85 0 85
871 {
872 @exchanges = map {
873 162 my $i = $_;
874 189 map { [ [ $_, $_+$i ] ] }
875 reverse( ( max 1, $p-$i ) .. ( min $p-1, 2*($p-1)-$i ) )
876 } ( 1 .. 2*($p-1)-1 );
877 }
878 0 elsif ( $oddBracket ) {
879 85 my $pPlus = $p+1;
880 @exchanges = map {
881 85 my $i = $_;
882 109 map { [ [ $_-1, $_+$i-1 ] ] }
883 reverse( (max 1, $pPlus-$i) .. (min $pPlus-1, 2*($pPlus-1)-$i) )
884 } ( 1 .. 2*($pPlus-1)-1 );
885 }
886 247 my @exchanges2;
887 247 ▶ unless ($oddBracket)
Branch: 2 branches
BranchTrueFalseTotal
if ($oddBracket) { } 85 162 247
if (do { $oddBracket }) 85 0 85
888 {
889 my @s1pair = map {
890 162 my $i = $_;
891 33 map { [ $i - $_, $i ] } 1 .. $i - 1
892 } reverse 2 .. $p - 1;
893 my @s2pair = map {
894 162 my $i = $_;
895 33 map { [ $i, $i + $_ ] } 1 .. 2 * ( $p - 1 ) - $i
896 } $p .. 2 * ( $p - 1 ) - 1;
897 @exchanges2 = map {
898 162 my $i = $_;
899 map {
900 44 [
901 73 [ $s1pair[$_][0], $s2pair[ $i - $_ ][0] ],
902 [ $s1pair[$_][1], $s2pair[ $i - $_ ][1] ]
903 ]
904 } ( max 0, $i - ( $p - 1 ) * ( $p - 2 ) / 2 + 1 )
905 .. ( min( ( $p - 1 ) * ( $p - 2 ) / 2 - 1, $i ) )
906 } 0 .. ( $p - 1 ) * ( $p - 2 ) - 2;
907 }
908 0 elsif ($oddBracket)
909 {
910 85 my $pPlus = $p+1;
911 my @s1pair = map {
912 85 my $i = $_;
913 3 map { [ $i - $_-1, $i-1 ] } 1 .. $i-1
914 } reverse 3 .. $pPlus - 1;
915 my @s2pair = map {
916 85 my $i = $_;
917 12 map { [ $i-1, $i+$_-1 ] } 1 .. 2 * ( $pPlus - 1 ) - $i
918 } $pPlus .. 2 * ( $pPlus - 1 ) - 1;
919 @exchanges2 = map {
920 85 my $i = $_;
921 map {
922 14 [
923 36 [ $s1pair[$_][0], $s2pair[ $i - $_ ][0] ],
924 [ $s1pair[$_][1], $s2pair[ $i - $_ ][1] ]
925 ]
926 } ( max 0, $i - ( $pPlus - 1 ) * ( $pPlus - 2 ) / 2 + 1 )
927 .. ( min( ( $pPlus - 1 ) * ( $pPlus - 2 ) / 2 - 2, $i ) )
928 } 0 .. ( $pPlus - 1 ) * ( $pPlus - 2 ) - 3;
929 }
930 247 push @exchanges, @exchanges2;
931 553 ▶ return sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
932 553 my $exchange = shift @exchanges;
933 553 ▶ return ("last S1,S2 exchange") unless $exchange;
Branch: 1 branch
BranchTrueFalseTotal
unless $exchange 177 376 553
934 376 $self->resetS12;
935 376 my $s1 = $self->s1;
936 376 my $s2 = $self->s2;
937 376 my @members = (@$s1, @$s2);
938 # my @members = @{ $self->members };
939 ( $members[ $_->[0] ], $members[ $_->[1] ] ) =
940 ( $members[ $_->[1] ], $members[ $_->[0] ] )
941 376 for @$exchange;
942 376 my $number = $letter++;
943 die "undef player in exchange $number of S1, S2" if
944 376 ▶ any { not defined } @members;
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
if &any(sub { not defined $_; } , @members) 0 376 376
945 376 return "exchange $number", @members;
946 }
947 247 }
948  
949  
950 =head2 score
951  
952 $group->score
953  
954 Gets/sets the score of the score group.
955  
956 =cut
957  
958 382 ▶sub score {
Subroutine score: called CC=3 SCAR=12.7
Pod documented
959 382 my $self = shift;
960 382 my $score = shift;
961 0 ▶ if ( defined $score ) { $self->{score} = $score; }
Branch: 2 branches
BranchTrueFalseTotal
if (defined $score) { } 0 382 382
elsif (exists $self->{'score'}) { } 382 0 382
962 382 elsif ( exists $self->{score} ) { return $self->{score}; }
963 0 return;
964 }
965  
966  
967 =head2 number
968  
969 $group->number
970  
971 Gets/sets the bracket's number, a number from 1 to the number of separate brackets, remainder groups and bye groups in the tournament. Don't use this number for anything important.
972  
973 =cut
974  
975 9666 ▶sub number {
Subroutine number: called CC=3 SCAR=11.2
Pod documented
976 9666 my $self = shift;
977 9666 my $number = shift;
978 0 ▶ if ( defined $number ) { $self->{number} = $number; }
Branch: 2 branches
BranchTrueFalseTotal
if (defined $number) { } 0 9666 9666
elsif (exists $self->{'number'}) { } 9515 151 9666
979 9515 elsif ( exists $self->{number} ) { return $self->{number}; }
980 151 return;
981 }
982  
983  
984 =head2 badpair
985  
986 $group->badpair
987  
988 Gets/sets the badpair, the position, counting from zero, of the first pair in S1 and S2 for which pairing failed in a previous attempt in C6. This is the first position at which the next ordering of S2 will differ from the previous one. All orderings between these two orderings will not result in a criteria-compliant pairing.
989  
990 =cut
991  
992 4317 ▶sub badpair {
Subroutine badpair: called CC=3 SCAR=11.0
Pod documented
993 4317 my $self = shift;
994 4317 my $badpair = shift;
995 4317 ▶ if ( defined $badpair ) { $self->{badpair} = $badpair; }
Branch: 2 branches
BranchTrueFalseTotal
if (defined $badpair) { } 1384 2933 4317
elsif (defined $self->{'badpair'}) { } 2801 132 2933
996 2801 elsif ( defined $self->{badpair} ) { return $self->{badpair}; }
997 1516 return;
998 }
999  
1000  
1001 =head2 members
1002  
1003 $group->members
1004  
1005 Gets/sets the members of the score group as an anonymous array of player objects. The order of this array is important. The first half is paired with the second half.
1006  
1007 =cut
1008  
1009 18503 ▶sub members {
Subroutine members: called CC=3 SCAR=11.0
Pod documented
1010 18503 my $self = shift;
1011 18503 my $members = shift;
1012 18503 ▶ if ( defined $members ) { $self->{members} = $members; }
Branch: 2 branches
BranchTrueFalseTotal
if (defined $members) { } 2103 16400 18503
elsif ($self->{'members'}) { } 16311 89 16400
1013 16311 elsif ( $self->{members} ) { return $self->{members}; }
1014 2192 return;
1015 }
1016  
1017  
1018 =head2 c8swapper
1019  
1020 $pairing->c8swapper
1021  
1022 Gets/sets an iterator through the different exchanges of players in the two halves of the bracket.
1023  
1024 =cut
1025  
1026 973 ▶sub c8swapper {
Subroutine c8swapper: called CC=3 SCAR=11.0
Pod documented
1027 973 my $self = shift;
1028 973 my $c8swapper = shift;
1029 973 ▶ if ( defined $c8swapper ) { $self->{c8swapper} = $c8swapper; }
Branch: 2 branches
BranchTrueFalseTotal
if (defined $c8swapper) { } 223 750 973
elsif ($self->{'c8swapper'}) { } 696 54 750
1030 696 elsif ( $self->{c8swapper} ) { return $self->{c8swapper}; }
1031 }
1032  
1033  
1034 =head2 _floatCheck
1035  
1036 %b65TestResults = _floatCheck( \@testee, $checkLevels );
1037  
1038 Takes a list representing the pairing of a bracket (see the description for _getNonPaired), and the various up- and down-float check levels. Returns an anonymous hash with keys: (a) 'badpos', the first element of the list responsible for violation of B6 or 5, if there was a violation of any of the levels, (b) 'passer', an anonymous array of the same form as \@testee, if there was no violation of any of the levels, and (c) 'message', a string noting the reason why the pairing is in violation of B6 or 5, and the id of the player involved. If there are multiple violations, the most important one is/should be returned.
1039  
1040 =cut
1041  
1042 274 ▶sub _floatCheck {
Subroutine _floatCheck: called CC=38 SCAR=36.9
1043 274 my $self = shift;
1044 274 my $untested = shift;
1045 274 my @paired = @$untested;
1046 274 my @nopairs = $self->_getNonPaired(@paired);
1047 274 my $levels = shift;
1048 274 ▶ die "Float checks are $levels?" unless $levels and ref($levels) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless $levels and ref $levels eq "ARRAY" 0 274 274
Condition33%1/3
$levels and ref $levels eq "ARRAY"
!ll&&!rl&&r
00274
MC/DC0%0/2
$levels and ref $levels eq "ARRAY"
$levels ref $levels eq "ARRAY"
Truth table33%1/3
A and B
A= $levelsB= ref $levels eq "ARRAY"
ABresult
0X0
100
111
1049 274 my $pprime = $self->pprime;
1050 274 my $s1 = $self->s1;
1051 274 my ($badpos, %badpos);
1052 274 my @pairtestee = @paired;
1053 274 my @nopairtestee = @nopairs;
1054 274 my @pairlevelpasser;
1055 my @nopairlevelpasser;
1056 274 my $message;
1057 274 B56: for my $level (@$levels)
1058 {
1059 892 my ($round, $direction, $checkedOne, $id);
1060 892 ▶ if ( $level =~ m/^B5/i ) { $round = 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($level =~ /^B5/i) { } 371 521 892
1061 521 else { $round = 2; }
1062 892 ▶ if( $level =~ m/Down$/i) { $direction = 'Down'; $checkedOne = 0 }
Branch: 2 branches
BranchTrueFalseTotal
if ($level =~ /Down$/i) { } 319 573 892
elsif ($level =~ /Up$/i) { } 379 194 573
1063 379 elsif ( $level =~ m/Up$/i ) { $direction = 'Up'; $checkedOne = 1 }
1064 194 else { @pairlevelpasser = @pairtestee; last B56 }
1065 698 for my $pos ( 0 .. $#$s1 ) {
1066 956 ▶ next unless defined $pairtestee[$pos];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pairtestee[$pos] 3 953 956
1067 953 my @pair = ( $pairtestee[$pos]->[0], $pairtestee[$pos]->[1] );
1068 953 ▶ my @score = map { defined $_->score? $_->score: 0 } @pair;
Branch: 1 branch
BranchTrueFalseTotal
defined $_->score ? : 1710 196 1906
1069 953 my @float = map { $_->floats( -$round ) } @pair;
1070 953 my $test = 0;
1071 953 ▶ $test = ( $score[0] == $score[1] or $float[$checkedOne] ne
Branch: 1 branch
BranchTrueFalseTotal
unless $direction eq "None" 953 0 953
Condition100%3/3
$score[0] == $score[1] || $float[$checkedOne] ne $direction
l!l&&r!l&&!r
50637968
MC/DC100%2/2
$score[0] == $score[1] || $float[$checkedOne] ne $direction
$score[0] == $score[1] $float[$checkedOne] ne $direction
Truth table100%3/3
A || B
A= $score[0] == $score[1]B= $float[$checkedOne] ne $direction
ABresult
1X1
011
000
1072 $direction ) unless $direction eq 'None';# XXX check both?
1073 953 ▶ if ( $test ) { $pairlevelpasser[$pos] = \@pair; }
Branch: 1 branch
BranchTrueFalseTotal
if ($test) { } 885 68 953
1074 else {
1075 68 ▶ $badpos{$level} = defined $badpos{$level}? $badpos{$level}: $pos;
Branch: 1 branch
BranchTrueFalseTotal
defined $badpos{$level} ? : 0 68 68
1076 68 ▶ $badpos = defined $badpos? $badpos: $pos;
Branch: 1 branch
BranchTrueFalseTotal
defined $badpos ? : 0 68 68
1077 68 ▶ $id ||= $pair[$checkedOne]->pairingNumber;
Condition33%1/3
$id ||= $pair[$checkedOne]->pairingNumber
l!l&&r!l&&!r
0680
MC/DC0%0/2
$id ||= $pair[$checkedOne]->pairingNumber
$id $pair[$checkedOne]->pairingNumber
Truth table33%1/3
A ||= B
A= $idB= $pair[$checkedOne]->pairingNumber
ABresult
1X1
011
000
1078 }
1079 }
1080 698 ▶ if ($direction ne 'Up' and @nopairtestee and ( not $self->hetero or
Branch: 1 branch
BranchTrueFalseTotal
if ($direction ne "Up" and @nopairtestee and !$self->hetero || grep({defined $_;} @nopairtestee) == 1) 128 570 698
Condition100%9/9
$direction ne "Up" and @nopairtestee and !$self->hetero || grep({defined $_;} @nopairtestee) == 1
!ll&&!rl&&r
50961128
$direction ne "Up" and @nopairtestee
!ll&&!rl&&r
379130189
not $self->hetero or grep({defined $_;} @nopairtestee) == 1
l!l&&r!l&&!r
923661
MC/DC100%4/4
$direction ne "Up" and @nopairtestee and !$self->hetero || grep({defined $_;} @nopairtestee) == 1
$direction ne "Up" @nopairtestee not $self->hetero grep({defined $_;} @nopairtestee) == 1
Truth table100%5/5
A and B and not(C) or D
A= $direction ne "Up"B= @nopairtesteeC= not $self->heteroD= grep({defined $_;} @nopairtestee) == 1
ABCDresult
0XXX0
10XX0
11000
111X1
11011
1081 389 (grep {defined} @nopairtestee) == 1 ))
1082 {
1083 #my $potentialDownFloaters =
1084 # grep { grep { defined } @$_ } @nopairtestee;
1085 128 for my $pos ( 0 .. $#nopairtestee ) {
1086 314 ▶ next unless defined $nopairtestee[$pos];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $nopairtestee[$pos] 186 128 314
1087 128 ▶ my @pair = @{ $nopairtestee[$pos] } if defined
Branch: 1 branch
BranchTrueFalseTotal
if defined $nopairtestee[$pos] and ref $nopairtestee[$pos] eq "ARRAY" 128 0 128
Condition33%1/3
defined $nopairtestee[$pos] and ref $nopairtestee[$pos] eq "ARRAY"
!ll&&!rl&&r
00128
MC/DC0%0/2
defined $nopairtestee[$pos] and ref $nopairtestee[$pos] eq "ARRAY"
defined $nopairtestee[$pos] ref $nopairtestee[$pos] eq "ARRAY"
Truth table33%1/3
A and B
A= defined $nopairtestee[$pos]B= ref $nopairtestee[$pos] eq "ARRAY"
ABresult
0X0
100
111
1088 $nopairtestee[$pos] and ref $nopairtestee[$pos] eq 'ARRAY';
1089 128 my $tableTest = 0;
1090 128 my $idCheck;
1091 128 for my $player ( @pair) {
1092 256 ▶ my $test = ( not defined $player or
Condition100%3/3
!defined($player) || $player->floats(-$round) ne 'Down'
l!l&&r!l&&!r
12711712
MC/DC100%2/2
!defined($player) || $player->floats(-$round) ne 'Down'
!defined($player) $player->floats(-$round) ne 'Down'
Truth table100%3/3
not(A) || B
A= !defined($player)B= $player->floats(-$round) ne 'Down'
ABresult
1X1
011
000
1093 ($player->floats(-$round) ne "Down") );
1094 256 ▶ $idCheck ||= $player->pairingNumber if $player and
Branch: 1 branch
BranchTrueFalseTotal
if $player and not $test 12 244 256
Condition66%4/6
$player and not $test
!ll&&!rl&&r
12711712
$idCheck ||= $player->pairingNumber
l!l&&r!l&&!r
0120
MC/DC100%2/2
$player and not $test
$player not $test
MC/DC0%0/2
$idCheck ||= $player->pairingNumber
$idCheck $player->pairingNumber
Truth table100%3/3
A and not(B)
A= $playerB= not $test
ABresult
0X0
100
111
Truth table33%1/3
A ||= B
A= $idCheckB= $player->pairingNumber
ABresult
1X1
011
000
1095 not $test;
1096 256 ▶ $tableTest++ if $test;
Branch: 1 branch
BranchTrueFalseTotal
if $test 244 12 256
1097 }
1098 128 ▶ if ( $tableTest >= 2 ) { $nopairlevelpasser[$pos] = \@pair; }
Branch: 1 branch
BranchTrueFalseTotal
if ($tableTest >= 2) { } 116 12 128
1099 else {
1100 12 ▶ $badpos{$level} = defined $badpos{$level}? $badpos{$level}: $pos;
Branch: 1 branch
BranchTrueFalseTotal
defined $badpos{$level} ? : 0 12 12
1101 12 ▶ $badpos = defined $badpos? $badpos: $pos;
Branch: 1 branch
BranchTrueFalseTotal
defined $badpos ? : 0 12 12
1102 12 ▶ $id = $idCheck if $idCheck;
Branch: 1 branch
BranchTrueFalseTotal
if $idCheck 12 0 12
1103 }
1104 }
1105 }
1106 698 my @retainables = grep { defined } @pairlevelpasser ;#
1107 # , grep { defined } @nopairlevelpasser;
1108 # my @nonfloaters = grep { grep { defined } @$_ } @retainables;
1109 698 ▶ if ( @retainables < $pprime or keys %badpos )
Branch: 1 branch
BranchTrueFalseTotal
if (@retainables < $pprime or keys %badpos) 80 618 698
Condition100%3/3
@retainables < $pprime or keys %badpos
l!l&&r!l&&!r
6812618
MC/DC100%2/2
@retainables < $pprime or keys %badpos
@retainables < $pprime keys %badpos
Truth table100%3/3
A or B
A= @retainables < $pprimeB= keys %badpos
ABresult
1X1
011
000
1110 # if ( @retainables < $pprime or $badpos )
1111 {
1112 80 my $badpos;
1113 80 for my $nextLevel ( @$levels )
1114 {
1115 146 ▶ next unless defined $badpos{ $nextLevel };
Branch: 1 branch
BranchTrueFalseTotal
unless defined $badpos{$nextLevel} 66 80 146
1116 80 $badpos = $badpos{ $nextLevel };
1117 80 last;
1118 }
1119 80 my $pluspos = $badpos+1;
1120 80 $message =
1121 "$level, table $pluspos: $id NOK. Floated $direction $round rounds ago";
1122 80 return badpos => $badpos, passer => undef, message => $message;
1123 }
1124 }
1125 continue {
1126 618 @pairtestee = @pairlevelpasser;
1127 618 @nopairtestee = @nopairlevelpasser;
1128 618 undef @pairlevelpasser;
1129 618 undef @nopairlevelpasser;
1130 }
1131 194 return badpos => undef, passer => \@pairlevelpasser, message => "B56: OK.";
1132 }
1133  
1134  
1135 =head2 _getNonPaired
1136  
1137 $bracket->_getNonPaired([$alekhine,$uwe],undef,[$deepblue,$yournewnike])
1138  
1139 Takes a list representing the pairing of S1 and S2. Each element of the list is either a 2-element anonymous array ref (an accepted pair of players), or undef (a rejected pair.) Returns an array of the same form, but with the accepted player items replaced by undef and the undef items replaced by the pairs rejected. If there are more players in S2 than S1, those players are represented as [undef,$player].
1140  
1141 =cut
1142  
1143 468 ▶sub _getNonPaired {
Subroutine _getNonPaired: called CC=5 SCAR=16.1
1144 468 my $self = shift;
1145 468 my @pairables = @_;
1146 468 my $s1 = $self->s1;
1147 468 my $s2 = $self->s2;
1148 468 my @nopairs;
1149 468 for my $pos ( 0..$#pairables )
1150 {
1151 607 ▶ $nopairs[$pos] = [ $s1->[$pos], $s2->[$pos] ] unless
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pairables[$pos] 0 607 607
1152 defined $pairables[$pos];
1153 }
1154 468 for my $pos ( $#pairables+1 .. $#$s1 )
1155 {
1156 2 $nopairs[$pos] = [ $s1->[$pos], $s2->[$pos] ];
1157 }
1158 468 for my $pos ( $#$s1+1 .. $#$s2 )
1159 {
1160 753 $nopairs[$pos] = [ undef, $s2->[$pos] ];
1161 }
1162 468 return @nopairs;
1163 }
1164  
1165  
1166 =head1 AUTHOR
1167  
1168 Dr Bean, C<< <drbean, followed by the at mark (@), cpan, then a dot, and finally, org> >>
1169  
1170 =head1 BUGS
1171  
1172 Please report any bugs or feature requests to
1173 C<bug-games-tournament-swiss at rt.cpan.org>, or through the web interface at
1174 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Games-Tournament-Swiss>.
1175 I will be notified, and then you'll automatically be notified of progress on
1176 your bug as I make changes.
1177  
1178 =head1 SUPPORT
1179  
1180 You can find documentation for this module with the perldoc command.
1181  
1182 perldoc Games::Tournament::Swiss::Bracket
1183  
1184 You can also look for information at:
1185  
1186 =over 4
1187  
1188 =item * AnnoCPAN: Annotated CPAN documentation
1189  
1190 L<http://annocpan.org/dist/Games-Tournament-Swiss-Bracket>
1191  
1192 =item * CPAN Ratings
1193  
1194 L<http://cpanratings.perl.org/d/Games-Tournament-Swiss-Bracket>
1195  
1196 =item * RT: CPAN's request tracker
1197  
1198 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Games-Tournament-Swiss-Bracket>
1199  
1200 =item * Search CPAN
1201  
1202 L<http://search.cpan.org/dist/Games-Tournament-Swiss-Bracket>
1203  
1204 =back
1205  
1206 =head1 ACKNOWLEDGEMENTS
1207  
1208 See L<http://www.fide.com/official/handbook.asp?level=C04> for the FIDE's Swiss rules.
1209  
1210 =head1 COPYRIGHT & LICENSE
1211  
1212 Copyright 2006 Dr Bean, all rights reserved.
1213  
1214 This program is free software; you can redistribute it and/or modify it
1215 under the same terms as Perl itself.
1216  
1217 =cut
1218  
1219 32 1; # End of Games::Tournament::Swiss::Bracket
1220  
1221 # vim: set ts=8 sts=4 sw=4 noet:
« blib/lib/Games/Tournament/Contestant.pm ↑ Summary blib/lib/Games/Tournament/Card.pm »