Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

First off, I would like to point out that I am not a student, this is not a homework assignment and I am really not looking for the code per se but for the methodology and perhaps some gotchyas to programming a round robin tournament. This is for a hobby group I chair. Yes, I know the website runs PHP but this is going to be a tool for tournament directors to help them out.

For the last 3 days, I have stared blankly at my computer screen wondering why this should be so hard. For those of you who may not know what a roudn robin tournament is, if there are 4 players in a tournament each player must play 3 games against the remaining players. The kicker and the point *I think* is tripping me up is that obviously the same player can't play two games with different opponents in the same round. Let's say I have 4 players: A, B, C, D.

This is how the rounds would break down (the # of rounds is always $#players)

Round 1 A vs B C vs D Round 2 A vs C B vs D Round 3 A vs D B vs C

Which is easy to program for $#rounds < 6. In fact I got it working quite well. The way I did it was a clever one I thought whereby I just cut the field in half and had the first player play the middle player, second player play the middle player + 1, etc. And then merge the two arrays together then cut it in half and repeat until all rounds were populated. This however will break down in $round >= 6 because the merged array will be the original array and the process starts over again which means that for $players > 7 the players would start playing the same players again. There are no pointers that I could find on the web for round robin tournaments. Plenty for single/double elimination bracket tournaments but round robin seems perhaps to be beyond the scope of normal Japhies.

Help is greatly appreciated.



CiceroLove
Fates! We will know your pleasures: That we shall die, we know; 'Tis but the time, and drawing days out, that men stand upon. - Act III,I, Julius Caesar

20031022 Edit by castaway: Changed title from 'Please Save My Withering Hair!'


In reply to Round robin tournament problem by CiceroLove

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-26 08:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found