10 Replies Latest reply on Jul 21, 2017 3:55 AM by greatgrey

    Random pairings

    fmpro_novice

      I have a twenty team golf league.

       

      Each team will play once a week for 20 weeks - or more - against another team.

       

      I want to guarantee that for at least the first 20 weeks, the same teams do not play each other twice.

       

      Can anyone think of a way to script a button that will create these pairings week by week?

        • 1. Re: Random pairings
          user1069

          Do a Google search for "round-robin tournament algorithm" which is what you're trying to accomplish. The basic algorithm is as follows:

           

          Number your teams 1-20 and pair them up as follows:

           

          01 02 03 04 05 06 07 08 09 10

          20 19 18 17 16 15 14 13 12 11

           

          These are the pairings for the first week. The next week you rotate everything except the first team:

           

          01 20 02 03 04 05 06 07 08 09

          19 18 17 16 15 14 13 12 11 10

           

          The third week you do this again:

           

          01 19 20 02 03 04 05 06 07 08

          18 17 16 15 14 13 12 11 10 09

           

          and so on...

           

          If you have an odd number of teams you can add a bye week:

           

          01 02 03 04 05 06 07 08 09 10

          XX 19 18 17 16 15 14 13 12 11

           

          (XX indicating team 01 has a bye week)

           

          The XX "team" will rotate through giving each team a bye week in succession.

          2 of 2 people found this helpful
          • 2. Re: Random pairings
            keywords

            Random is hardly likely to achieve that. By its very nature it is random, and there is nothing to stop it throwing up repeat numbers. Better to come up with a calc that will rotate them through and thus guarantee your outcome. Such as the cycle already suggested.

            Of course if you really want the pairings to be random, i.e. not a predictable cycle, you could use Random, and then manually fix any issues it throws up.

            • 3. Re: Random pairings
              user19752

              For 20 teams, you can't "first 20 weeks..." since a team can play with 19 other teams

              • 4. Re: Random pairings
                fmpro_novice

                Thank you for the reply. But how do I accomplish this by simply pushing a button?

                 

                I have this already set up to function like this:

                 

                01

                02

                03

                04

                05

                06

                etc., resulting, 01 vs 02; 03 vs 04; 05 vs 06

                 

                So, if I need a list like you are saying;

                01

                20

                02

                19

                03

                18

                etc., if each team is assigned that number at the start, how do I make FM sort like this, instead of numerically?

                • 5. Re: Random pairings
                  fmpro_novice

                  Thank you. Random was a poor description.

                  • 6. Re: Random pairings
                    fmpro_novice

                    I figured it out, thank you. My solution is clunky, but it will work. I used a custom value list and just made one for each week.

                    Thanks again.

                    • 7. Re: Random pairings
                      user1069

                      I'm afraid you may be attempting to run before you have learned how to walk.

                       

                      There are a few things at play here. First is the need for a data structure representing the pairings. Simply sorting a list of teams isn't going to do it. You want a table representing each team:

                       

                      TEAM

                      teamNumber     number

                      teamName     text

                       

                      and a table representing the pairings:

                       

                      MATCH

                      homeTeamNumber     number

                      awayTeamNumber     number

                       

                      The TEAM table would have twenty records in it, one for each team. The MATCH table would have 190 records in it, one for each match between two teams. The task at hand is to populate this MATCH table with the pairings generated by your algorithm. That algorithm is going to be expressed by a script which implements the round-robin tournament algorithm.

                      • 8. Re: Random pairings
                        philmodjunk

                        You definitely need to get the basics working first, but to randomize the process, you can put the teams into random order for the first match, then rotate systematically from that initial set of random pairs. To get a random order, you can use the random function to put a random number into a field of each team record and then sort your records on that field.

                        • 9. Re: Random pairings
                          fmpro_novice

                          Thank you for your response. I know it's clunky - but I just made 20 value lists - and I will use one for each week.

                          It actually works fine. Not elegant, for sure, but it's done and it's all I have time for now. (Plus, I fully understand what I did - and how it works.)

                          • 10. Re: Random pairings
                            greatgrey

                            With only 20 teams there can be only 19 weeks of being matched to a team that they have not played before.