Quote:
|
Originally Posted by Jeremy_Mc
I've attached a simple graphic of my algorithm to this post.
It's not the easiest thing to work out/comprehend, but it will work. I worked it out a bunch of different ways and it works out fine every time. The graphics uses a small dataset (23 teams) but I just wanted to illustrate the way to work it, and some of the problems that might arise from using it.
If there are any questions/comments please PM me or post here or something...
I'm sure this would be easy to work into a program of sorts (using linked lists or arrays), but I'm simply too lazy to worry about doing it in VB or C.
[edit: forgot the file...]
|
here is your algorithm as far as I understand it: (its in perl, accepts number of teams and number of matches as command line arguments)
Code:
my ($teams, $matches) = @ARGV[0,1];
if ($teams < 16) {
die "need at least 16 teams";
}
my @teams = 1..$teams;
my @matches = 1..$matches;
my @pools;
while (my @slice = splice(@teams, 0, 4)) {
push @pools, [@slice[0,1], @slice[2,3]];
}
foreach my $match (@matches) {
print "match $match: ";
my $pool1 = $pools[0];
my $pool2 = $pools[2];
my @red = splice(@$pool1, 0, 2);
my @blue = splice(@$pool2, 0, 2);
my $off = ($match % 2 ? 0 : 2);
$red[1] = splice(@{$pools[1]}, 1 + $off, 1) if not $red[1];
$red[0] = splice(@{$pools[1]}, 0 + $off, 1) if not $red[0];
$blue[1] = splice(@{$pools[3]}, 1 + $off, 1) if not $blue[1];
$blue[0] = splice(@{$pools[3]}, 0 + $off, 1) if not $blue[0];
print "@red vs. @blue\n";
if ($match % 2) {
push @pools, [@red];
push @pools, [reverse @blue];
} else {
push @{$pools[-2]}, shift @blue;
unshift @{$pools[-2]}, shift @blue;
splice @{$pools[-1]}, 1, 0, @red;
splice(@pools, 0, 1);
splice(@pools, 1, 1);
}
}
It seems to make a nice match list. I have not yet analyzed to results are far as how good the match listing is of this method. Will see.