Zugzwangle Posted October 26, 2013 Share Posted October 26, 2013 Hi all. I have a question involving a Round Robin sporting event. I want to create a formula to evenly distribute home and away matches. Firstly, to less complicate the situation, I need only consider even number participants in the tournament, as I would substitute a 'bye' with an extra number if need be.You can visualise the Round Robin Schedule below.However I am going to complicate the issue. This is a Single Round robin - so each team plays each other team ONCE only.From my own mathematical findings, I have found that:Participants1). Matches per round = P / 22). Rounds = P - 13). Games (or I considered this the 'area' of the triangle, and hence a triangle number) , so the nth triangle number = (P^2 - P) / 2. (Multiply matches per round by Rounds)4). If I create a Round Robin using a rotating formula such as this where the numbers rotate around the first number (1) the numbers are not correctly distributed between home and awayR1 R2 R3 R4 12 16 15 etc ....63 52 41 ....54 43 32 ....=>>>> works out asIf H = Home, A=AwayParticipant 1 HHHHHParticipant 2 AAHHHParticipant 3 AAHHHParticipant 4 AAHHHParticipant 5 AAHHHParticipant 6 AAHHHAn example of how the finished tournament would look like:Participant 1 HAHAHParticipant 2 AHAHAParticipant 3 HAHAHParticipant 4 AHAHAParticipant 5 HAHAHParticipant 6 AHAHAGiven I have already paired the participants, how might I go about formulating an equally distributed Single Round Robin Tournament!! Link to comment https://forums.phpfreaks.com/topic/283292-single-round-robin-tournament/ Share on other sites More sharing options...
Zugzwangle Posted October 28, 2013 Author Share Posted October 28, 2013 I have been given this formula. n = teams / 2... The teams should only be even numbers. n is always even!! (1,2,3,4... 2n .... ) which sums up to: if (i v j) ---> 1 < (|i-j| % 2n) < n - 1 , i = home, if (i v j) ---> n + 1 < (|i-j| % 2n) < 2n - 1, i = home, if (i v j) ---> (|i-j| % 2n) = n and ( i > j) i = home else i = away This produces an array of 12 teams such as: Where Rounds --> Matches --> Teams --> Team numbers Array ( [0] => Array ( [0] => Array ( [0] => 7 [1] => 1 ) [1] => Array ( [0] => 8 [1] => 2 ) [2] => Array ( [0] => 9 [1] => 3 ) [3] => Array ( [0] => 10 [1] => 4 ) [4] => Array ( [0] => 11 [1] => 5 ) [5] => Array ( [0] => 12 [1] => 6 ) ) [1] => Array ( [0] => Array ( [0] => 2 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 7 ) [2] => Array ( [0] => 4 [1] => 8 ) [3] => Array ( [0] => 5 [1] => 9 ) [4] => Array ( [0] => 6 [1] => 10 ) [5] => Array ( [0] => 12 [1] => 11 ) ) [2] => Array ( [0] => Array ( [0] => 1 [1] => 3 ) [1] => Array ( [0] => 4 [1] => 2 ) [2] => Array ( [0] => 5 [1] => 7 ) [3] => Array ( [0] => 6 [1] => 8 ) [4] => Array ( [0] => 12 [1] => 9 ) [5] => Array ( [0] => 11 [1] => 10 ) ) [3] => Array ( [0] => Array ( [0] => 4 [1] => 1 ) [1] => Array ( [0] => 5 [1] => 3 ) [2] => Array ( [0] => 6 [1] => 2 ) [3] => Array ( [0] => 12 [1] => 7 ) [4] => Array ( [0] => 11 [1] => 8 ) [5] => Array ( [0] => 10 [1] => 9 ) ) [4] => Array ( [0] => Array ( [0] => 1 [1] => 5 ) [1] => Array ( [0] => 6 [1] => 4 ) [2] => Array ( [0] => 3 [1] => 12 ) [3] => Array ( [0] => 2 [1] => 11 ) [4] => Array ( [0] => 10 [1] => 7 ) [5] => Array ( [0] => 9 [1] => 8 ) ) [5] => Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 5 [1] => 12 ) [2] => Array ( [0] => 4 [1] => 11 ) [3] => Array ( [0] => 3 [1] => 10 ) [4] => Array ( [0] => 2 [1] => 9 ) [5] => Array ( [0] => 8 [1] => 7 ) ) [6] => Array ( [0] => Array ( [0] => 1 [1] => 12 ) [1] => Array ( [0] => 11 [1] => 6 ) [2] => Array ( [0] => 10 [1] => 5 ) [3] => Array ( [0] => 9 [1] => 4 ) [4] => Array ( [0] => 8 [1] => 3 ) [5] => Array ( [0] => 7 [1] => 2 ) ) [7] => Array ( [0] => Array ( [0] => 11 [1] => 1 ) [1] => Array ( [0] => 10 [1] => 12 ) [2] => Array ( [0] => 9 [1] => 6 ) [3] => Array ( [0] => 8 [1] => 5 ) [4] => Array ( [0] => 7 [1] => 4 ) [5] => Array ( [0] => 2 [1] => 3 ) ) [8] => Array ( [0] => Array ( [0] => 1 [1] => 10 ) [1] => Array ( [0] => 9 [1] => 11 ) [2] => Array ( [0] => 8 [1] => 12 ) [3] => Array ( [0] => 7 [1] => 6 ) [4] => Array ( [0] => 2 [1] => 5 ) [5] => Array ( [0] => 3 [1] => 4 ) ) [9] => Array ( [0] => Array ( [0] => 9 [1] => 1 ) [1] => Array ( [0] => 8 [1] => 10 ) [2] => Array ( [0] => 7 [1] => 11 ) [3] => Array ( [0] => 12 [1] => 2 ) [4] => Array ( [0] => 3 [1] => 6 ) [5] => Array ( [0] => 4 [1] => 5 ) ) [10] => Array ( [0] => Array ( [0] => 1 [1] => 8 ) [1] => Array ( [0] => 7 [1] => 9 ) [2] => Array ( [0] => 10 [1] => 2 ) [3] => Array ( [0] => 11 [1] => 3 ) [4] => Array ( [0] => 12 [1] => 4 ) [5] => Array ( [0] => 5 [1] => 6 ) ) ) If displayed as, Teams --> Rounds --> Home / Away.. it looks like this: Array ( [1] => Array ( [0] => 1 [1] => 1 [2] => 0 [3] => 1 [4] => 0 [5] => 1 [6] => 0 [7] => 1 [8] => 0 [9] => 1 [10] => 0 ) [2] => Array ( [0] => 1 [1] => 0 [2] => 1 [3] => 1 [4] => 0 [5] => 0 [6] => 1 [7] => 0 [8] => 0 [9] => 1 [10] => 1 ) [3] => Array ( [0] => 1 [1] => 0 [2] => 1 [3] => 1 [4] => 0 [5] => 0 [6] => 1 [7] => 1 [8] => 0 [9] => 0 [10] => 1 ) [4] => Array ( [0] => 1 [1] => 0 [2] => 0 [3] => 0 [4] => 1 [5] => 0 [6] => 1 [7] => 1 [8] => 1 [9] => 0 [10] => 1 ) [5] => Array ( [0] => 1 [1] => 0 [2] => 0 [3] => 0 [4] => 1 [5] => 0 [6] => 1 [7] => 1 [8] => 1 [9] => 1 [10] => 0 ) [6] => Array ( [0] => 1 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 1 [7] => 1 [8] => 1 [9] => 1 [10] => 1 ) [7] => Array ( [0] => 0 [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 1 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 ) [8] => Array ( [0] => 0 [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 1 ) [9] => Array ( [0] => 0 [1] => 1 [2] => 1 [3] => 1 [4] => 0 [5] => 1 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 1 ) [10] => Array ( [0] => 0 [1] => 1 [2] => 1 [3] => 0 [4] => 0 [5] => 1 [6] => 0 [7] => 0 [8] => 1 [9] => 1 [10] => 0 ) [11] => Array ( [0] => 0 [1] => 1 [2] => 0 [3] => 0 [4] => 1 [5] => 1 [6] => 0 [7] => 0 [8] => 1 [9] => 1 [10] => 0 ) [12] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 1 [5] => 1 [6] => 1 [7] => 1 [8] => 1 [9] => 0 [10] => 0 ) ) As you can see, although there ARE a fairly distributed number of teams with home or away, in some cases there are long strings of matches at home, for some teams!! Can you help me sort this one out!! Please try if you can. Thanks in advance Link to comment https://forums.phpfreaks.com/topic/283292-single-round-robin-tournament/#findComment-1455832 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.