Jump to content

Round Robin code help?


MKS_sjacques

Recommended Posts

I'm trying to write a flexible round robin program for randomly scheduling teams to play one another. There is one variable, the # of teams, which has to be an even number. The fixed constants are that every team has to play all of the other teams, but they only play all of the teams once, and all teams play on the same day every week... seems fairly straightforward to do...

So what I have so far seems to work initially, but it then bogs down as the # of possible pairings dwindles... I basically initialize a 2D array (#teams x #teams-1) so for example if there's 10 teams, there would only be 9 sets of matches (9 weeks), as the teams don't play themselves. I have a couple of for loops to strip out the row and column indexes, a random # generator to generate random opponents, and some logic to sort out if the randomly selected team has played the matched team before (across the row) and if they were matched to play any other team that week (down the column).

So in an 8 team environment, you could imagine the first weeks games as team 1 vs team 4, team 2 vs team 3, team 5 vs team 7, and team 6 vs team 8. The rub is that I have seen the algorithm pick the next weeks matchups as team 1 vs team 7, team 2 vs team 5, team 3 vs team 4, and it hangs because now it's trapped itself into team 6 vs team 8 again...

Anyone ever do something like this? I was thinking I'll just keep scrapping the row until the program is able to randomly come up with a matching that works for that week, but I was hoping for a more scientific way to "randomly" generate a schedule...

Any thoughts?

Link to comment

I haven't done this in LabVIEW, but a quick google search turned up

http://en.wikipedia.org/wiki/Round-robin_tournament

and

http://www.devenezia.com/javascript/articl...oundRobin3.html

This seems to be a fairly good explanation and sould be easy to implement in LabVIEW (or with even less translation, a math script node).

I might play with implementing it this weekend, but don't wait on me! :beer:

Hope that this helps,

Bob Young

Link to comment

Bob,

Thanks for the info, I also came across the javascript RR generator link, trouble with those is that they are "patterned", i.e. they follow the round robin algorithm and you can clearly see a pattern... what I wanted to do was to randomize the results such that there's no discernable pattern to the viewer... so it would be some form of the RR algorithm... I've even generated code that randomizes the columns after the RR schedule is created, but there's still a visible pattern by column...

Thanks again for your inputs!

Steve

I haven't done this in LabVIEW, but a quick google search turned up

http://en.wikipedia.org/wiki/Round-robin_tournament

and

http://www.devenezia.com/javascript/articl...oundRobin3.html

This seems to be a fairly good explanation and sould be easy to implement in LabVIEW (or with even less translation, a math script node).

I might play with implementing it this weekend, but don't wait on me! :beer:

Hope that this helps,

Bob Young

Link to comment
  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.