Code works fine except...
Ross
ross.jett at gmail.com
Tue May 5 02:56:57 CEST 2009
On May 4, 7:59 pm, John Yeung <gallium.arsen... at gmail.com> wrote:
> On May 4, 10:01 am, Ross <ross.j... at gmail.com> wrote:
>
> > The "magic numbers" that everyone is wondering about are
> > indeed used for spreading out the bye selection and I got
> > them by simply calculating a line of best fit when plotting
> > several courts: byes ratios.
>
> But that doesn't really help you. When you do seq[::step], step is
> evaluated once and used for the whole extended slice. So in almost
> all cases that you are likely to encounter, step is 2, so you'll get
> seq[0], seq[2], seq[4], etc. Even if step is some other positive
> number, seq[0] will always be chosen.
>
> > The "byes = #whatever" in my code calculate the number of
> > tuples that need to be placed in the bye_list.
>
> Fine, but that's not the number of byes that you put into bye_list.
>
> > At first glance, the suggestion of adding a simple shift
> > at the end of round_robin doesn't seem to work since
> > round_robin already shifts everything except for the first
> > position already. Please correct me if I'm wrong because
> > you might have been suggesting something different.
>
> If you read my post carefully, you would see that you HAVE to do
> something about the first player always being stuck in the first
> spot. Either move him around, or select your byes differently.
>
> That said, I've played around with the shuffling a bit, and it does
> seem to be pretty tricky to get it to work for the general case where
> there is no prior knowledge of how many players and courts you will
> have.
>
> I can't shake the feeling that someone good at math will be able to
> figure out something elegant; but if left to my own devices, I am
> starting to lean toward just generating all the possible matches and
> somehow picking from them as needed to fill the courts, trying to keep
> the number of matches played by each player as close to equal as
> possible, and trying to keep the waiting times approximately equal as
> well.
>
> John
"But that doesn't really help you. When you do seq[::step], step is
evaluated once and used for the whole extended slice. So in almost
all cases that you are likely to encounter, step is 2, so you'll get
seq[0], seq[2], seq[4], etc. Even if step is some other positive
number, seq[0] will always be chosen."
It's not true that in almost all cases the step is 2. How that is
evaluated directly depends on the number of available courts. Anyways,
you're right that seq[0] is always evaluated. That's why my algorithm
works fine when there are odd numbers of players in a league. But if
you will notice, my original question was how I could ADD TO or AMMEND
my current code to account for even number of players. I have used an
algorithm that comes up with all possible pairings and then randomly
puts people together each week and places players in a bye list
according to how many times they've previously been in the bye list
but since I was dealing with random permutations, the algorithm took
minutes to evaluate when there were more than 10 players in the
league.
More information about the Python-list
mailing list