Fixture Generating Algorithm Easiest Describe with Drawing
I will explain how to create a fixture algorithm regardless of the programming language. But if you want to see how I write in Java, you can check my GitHub link.
So, let's start.
When we are building a fixture-generating algorithm, we have to know two basic things;
- The teams will match one time or two times?
- How many teams are there? (n)
- How many teams will match every round? : All teams can bisect. (n/2)
- How many rounds will there be?
- If teams will match just once: All teams minus one. (n-1)
- If teams will match twice: All teams minus one and multiplied by two. ((n-1) x 2)
The Algorithm with Drawing
- Relocated the teams on the temp list.
- Then transferred the temp list to the original list. And clear the temp list.
- Now we can enter the team matching loop with the last original and temp list.
- The first loop is the main loop. It will loop total --> (team size -1) times.
- The teams will merge in double. The loop will repeat n/2 times. It means --> (total team / 2) as I said at first.
- The original list will transfer its own first and the last team to the temp list as you see in the drawing. After that, another loop will transfer the left behind in the original list to the temp list.
- The original list will get the new arrangement, and then the cells of the temp list will clear.
- If teams are to match only once, the main loop can end here. But if the teams are to match twice, the loop must continue.
- The loop will n/2 times like the second item. But there is one difference between them; for example, if the second loop match list had the teams from the original list like [a-b] here, teams have to write like [b-a]