line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Tournament::Swiss::Procedure::Dummy; |
2
|
|
|
|
|
|
|
$Games::Tournament::Swiss::Procedure::Dummy::VERSION = '0.20'; |
3
|
|
|
|
|
|
|
# Last Edit: 2016 Jan 01, 13:44:45 |
4
|
|
|
|
|
|
|
# $Id: $ |
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
1056
|
use warnings; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
203
|
|
7
|
8
|
|
|
8
|
|
38
|
use strict; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
208
|
|
8
|
|
|
|
|
|
|
|
9
|
8
|
|
|
8
|
|
37
|
use constant ROLES => @Games::Tournament::Swiss::Config::roles; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
505
|
|
10
|
8
|
|
|
8
|
|
48
|
use constant FIRSTROUND => $Games::Tournament::Swiss::Config::firstround; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
440
|
|
11
|
|
|
|
|
|
|
|
12
|
8
|
|
|
8
|
|
36
|
use base qw/Games::Tournament::Swiss/; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
459
|
|
13
|
8
|
|
|
8
|
|
244
|
use Games::Tournament::Contestant::Swiss; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
5271
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Games::Tournament::Swiss::Procedure::Dummy - A brain-dead pairing algorithm |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$tourney = Games::Tournament::Swiss->new( rounds => 2, entrants => [ $a, $b, $c ] ); |
24
|
|
|
|
|
|
|
%groups = $tourney->formBrackets; |
25
|
|
|
|
|
|
|
$pairing = $tourney->pairing( \%groups ); |
26
|
|
|
|
|
|
|
@pairs = $pairing->matchPlayers; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
A test module swappable in to allow testing the non-Games::Tournament::Procedure parts of Games::Tournament::Swiss |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 METHODS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 new |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$pairing = Games::Tournament::Swiss::Procedure::Dummy->new(TODO \@groups ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Creates a stupid algorithm object that on matchPlayers will just pair the nth player with the n+1th in each score group, downfloating the last player if the number in the bracket is odd, ignoring the FIDE Swiss Rules. You can swap in this module in your configuration file, instead of your real algorithm to test the non-algorithm parts of your program are working. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
43
|
13
|
|
|
13
|
1
|
19
|
my $self = shift; |
44
|
13
|
|
|
|
|
17
|
my $index = 0; |
45
|
13
|
|
|
|
|
83
|
my %args = @_; |
46
|
13
|
|
|
|
|
32
|
my $round = $args{round}; |
47
|
13
|
|
|
|
|
19
|
my $brackets = $args{brackets}; |
48
|
13
|
|
|
|
|
32
|
my $banner = "Round $round: "; |
49
|
13
|
|
|
|
|
69
|
for my $bracket ( reverse sort keys %$brackets ) { |
50
|
49
|
|
|
|
|
160
|
my $members = $brackets->{$bracket}->members; |
51
|
49
|
|
|
|
|
147
|
my $score = $brackets->{$bracket}->score; |
52
|
49
|
|
|
|
|
77
|
$banner .= "@{[map { $_->pairingNumber } @$members]} ($score), "; |
|
49
|
|
|
|
|
78
|
|
|
127
|
|
|
|
|
276
|
|
53
|
|
|
|
|
|
|
} |
54
|
13
|
|
|
|
|
1354
|
print $banner . "\n"; |
55
|
13
|
|
|
|
|
139
|
return bless { |
56
|
|
|
|
|
|
|
round => $round, |
57
|
|
|
|
|
|
|
brackets => $brackets, |
58
|
|
|
|
|
|
|
matches => [] |
59
|
|
|
|
|
|
|
}, |
60
|
|
|
|
|
|
|
"Games::Tournament::Swiss::Procedure"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 matchPlayers |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
@pairs = $pairing->matchPlayers; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Run a brain-dead algorithm that instead of pairing the players according to the rules creates matches between the nth and n+1th player of a bracket, downfloating the last player of the group if the number of players is odd. If there is an odd number of total players, the last gets a Bye. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub matchPlayers { |
73
|
13
|
|
|
13
|
1
|
233
|
my $self = shift; |
74
|
13
|
|
|
|
|
42
|
my $brackets = $self->brackets; |
75
|
13
|
|
|
|
|
18
|
my $downfloater; |
76
|
|
|
|
|
|
|
# my @allMatches = @{ $self->matches }; |
77
|
|
|
|
|
|
|
my %allMatches; |
78
|
13
|
|
|
|
|
21
|
my $number = 1; |
79
|
13
|
|
|
|
|
48
|
for my $score ( reverse sort keys %$brackets ) { |
80
|
49
|
|
|
|
|
55
|
my @bracketMatches; |
81
|
49
|
|
|
|
|
148
|
my $players = $brackets->{$score}->members; |
82
|
49
|
100
|
|
|
|
117
|
if ($downfloater) { |
83
|
20
|
|
|
|
|
42
|
unshift @$players, $downfloater; |
84
|
20
|
|
|
|
|
39
|
undef $downfloater; |
85
|
|
|
|
|
|
|
} |
86
|
49
|
100
|
|
|
|
134
|
$downfloater = pop @$players if @$players % 2; |
87
|
49
|
|
|
|
|
130
|
for my $table ( 0 .. @$players / 2 - 1 ) { |
88
|
62
|
|
|
|
|
150
|
push @bracketMatches, Games::Tournament::Card->new( |
89
|
|
|
|
|
|
|
round => $self->round, |
90
|
|
|
|
|
|
|
result => undef, |
91
|
|
|
|
|
|
|
score => $score, |
92
|
|
|
|
|
|
|
contestants => { |
93
|
|
|
|
|
|
|
(ROLES)[0] => $players->[ 2 * $table ], |
94
|
|
|
|
|
|
|
(ROLES)[1] => $players->[ 2 * $table + 1 ] |
95
|
|
|
|
|
|
|
}, |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# floats => \%floats |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
} |
100
|
49
|
100
|
100
|
|
|
187
|
if ( $number == keys %$brackets and $downfloater ) { |
101
|
3
|
|
|
|
|
7
|
push @bracketMatches, Games::Tournament::Card->new( |
102
|
|
|
|
|
|
|
round => $self->round, |
103
|
|
|
|
|
|
|
result => undef, |
104
|
|
|
|
|
|
|
contestants => { Bye => $downfloater }, |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# floats => \%floats |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
} |
109
|
49
|
|
|
|
|
98
|
$allMatches{$score} = \@bracketMatches; |
110
|
49
|
|
|
|
|
96
|
$number++; |
111
|
|
|
|
|
|
|
} |
112
|
13
|
|
|
|
|
46
|
$self->matches( \%allMatches ); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 brackets |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
$pairing->brackets |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Gets/sets all the brackets which we are pairing, as an anonymous array of score group (bracket) objects. The order of this array is important. The brackets are paired in order. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub brackets { |
125
|
13
|
|
|
13
|
1
|
20
|
my $self = shift; |
126
|
13
|
|
|
|
|
19
|
my $brackets = shift; |
127
|
13
|
50
|
|
|
|
71
|
if ( defined $brackets ) { $self->{brackets} = $brackets; } |
|
0
|
50
|
|
|
|
0
|
|
128
|
13
|
|
|
|
|
31
|
elsif ( $self->{brackets} ) { return $self->{brackets}; } |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 round |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
$pairing->round |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
What round is this round's results we're pairing on the basis of? |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub round { |
141
|
65
|
|
|
65
|
1
|
78
|
my $self = shift; |
142
|
65
|
|
|
|
|
76
|
my $round = shift; |
143
|
65
|
50
|
|
|
|
232
|
if ( defined $round ) { $self->{round} = $round; } |
|
0
|
50
|
|
|
|
0
|
|
144
|
65
|
|
|
|
|
437
|
elsif ( $self->{round} ) { return $self->{round}; } |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 matches |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
$group->matches |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Gets/sets the matches which we have made. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub matches { |
157
|
16
|
|
|
16
|
1
|
31
|
my $self = shift; |
158
|
16
|
|
|
|
|
30
|
my $matches = shift; |
159
|
16
|
100
|
|
|
|
39
|
if ( defined $matches ) { $self->{matches} = $matches; } |
|
13
|
50
|
|
|
|
67
|
|
160
|
3
|
|
|
|
|
13
|
elsif ( $self->{matches} ) { return $self->{matches}; } |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 AUTHOR |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Dr Bean, C<< >> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 BUGS |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
170
|
|
|
|
|
|
|
C, or through the web interface at |
171
|
|
|
|
|
|
|
L. |
172
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
173
|
|
|
|
|
|
|
your bug as I make changes. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 SUPPORT |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
perldoc Games::Tournament::Swiss |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
You can also look for information at: |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=over 4 |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
L |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item * CPAN Ratings |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
L |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
L |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item * Search CPAN |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
L |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=back |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
See L for the FIDE's Swiss rules. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Copyright 2006 Dr Bean, all rights reserved. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
212
|
|
|
|
|
|
|
under the same terms as Perl itself. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=cut |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
1; # End of Games::Tournament::Swiss::Procedure |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
# vim: set ts=8 sts=4 sw=4 noet: |