Code works fine except...

John Yeung gallium.arsenide at gmail.com
Tue May 5 01:59:15 CEST 2009


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



More information about the Python-list mailing list