I have a system where I number each match in a tournament the following way:
round 1 | round 2 |
------------|---------------|
·
[a vs b] -----------
(match 0) · |
· |
· [a vs c] ------ [a winner]
· (match 2)
· |
· |
[c vs d] -----------
(match 1) ·
·
So matches are numbered from top to bottom, and left to right from 0 to N.
When a match is played and a winner is known, I need to know to which match the winner will be placed (Example: in Match 0, winner A will be directed to Match 2)
I've found that:
next_match_number = (current_match_number + total_number_of_teams)/2
gives me the next match number that I need. Please note that I need to round down the result.
Example:
next_match_number = (0+4)/2 = 2
Now for a different purpose, I need the Match Number where a Team may come from -> The previous match number.
For example, in match 2 I would like to know that its teams come from match 0 and match 1.
Obviously the same formula doesn`t work. I know that rounding down the result is a dirty trick...