# Round robin fixture order

Hi,

I'm working on a tournament app. I have 8 teams and I have it so it generates 28 fixtures, or 56 fixtures, dependent on whether you want a return leg or not.  However, they aren't in a playable order, they show all of team 1s fixtures, then team 2s etc.

How do I build logic in order to build a round robin type order,

1 vs 2

3 vs 4

5 vs 6

7 vs 8

Etc  for 7 rounds?

Edward

Hi Eddie,

Do you have any specific doubt regarding how to do this in OutSystems?

Your question is way too open and you should work yourself on the algorithm you would like it to use.

Regards,

Hi

Sorry it's quite open. I don't know where to start. I googled for an algorithm, but don't know how to implement it in Outsystems

https://en.m.wikipedia.org/wiki/Round-robin_tournament

There is a scheduling algorithm here

Edward

err, the algorithm seems easy enough to be implemented by Outsystems.

so what is your initial idea how to approach it?

Well I have a Player entity, so I thought about maybe adding a position to it, or using Index?

I have a Round robin entity which takes 2 instances of the Player entity.

I'm looking through the Player entity twice in order to get the fixtures played. It's just they're not in the right order.

you need to implement the algorithm first.

set numPlayers = X

set round =1

generate "matches", or simply the list of numbers

round++

generate again.

So do I need a fixtures entity?

Do I hard code the combinations? Or is there way of implementing the rotating logic in Outsystems? Will the output be a list, or text variable? Will I then be able to use this output elsewhere?

Like Joao and me already said, the algorithm is the thing you need to work on.

Just make it, and when you are stuck or have more questions, post the oml and share what you already have done..

Hi,

I can post the oml or screenshots if this doesn't make sense, it's just I have personal data in the app, so that's why it's not ready to share.

I can generate the first round of matches. I use a Player Number to find the Index position in the list.

0 vs 4, 1 vs 5, 2 vs 6, 3 vs 7.

However, I seem to keep iterating this combination 7 times.

Adding one to the PlayerNumber doesn't work as you cant have an Index 8 on an 8 itemed list.

I tried to embed if conditions if the Player number is 0 to not increment by one, and if it's 7, to reset the count by 1. But these have not worked. Is this even the right Idea? If so, I will stick the debugger on again.

If not, how so you ensure that the 0 stays the same in each round, but the others increment by 1. Is a modulus needed?

The home team is using the Player number index

The away team is using player number plus half the length of the list (which is what the algorithm suggested).

Edward