Hello. Help please solve this problem. Project on Yii2. For example, there is a championship (video battles), from 2 to 64 people can take part. The championship is created, users submit applications and add their videos. All this is recorded in the database,
table with battles c_competition
c_requests
table with options c_option
it's all set.
The problem is that I can’t think of how to randomly split all participants into pairs, in such a way as to memorize the results (who won and who lost). And then from the winners to form more pairs and so on, until only one remains - the winner.
The voting page now looks like this
but the options are displayed by the whole bunch, if you vote for one, then you can’t be anyone else, but I need the couples to be independent, so that you can vote for the person in each pair. I thought to do this: write a function that will take options, group them by 2 and write to another table, but I can’t figure out how to organize it. Maybe someone did something like that, please tell me.
2 answers
Well, you need to have some kind of Versus entity that has user1 , user2 , ratingUser1 , ratingUser2 , winner and another VersusManager that would have a stack of Versus entities (preformed) at the beginning and when all rounds of stage 1 passed formed a new stack of Versus winners. Accordingly, for each Versus entity you need to have an entry in the table (for example, c_battle or c_versus )
We need one common database with the next_tour data next_tour (the number of the next round) and next_tour_id (the participant’s id in the next round).
Initially, the next_tour_id formed randomly. A participant without a pair and the winners of battles receive the next number for each of these fields.
Participants of the next round should be filtered by next_tour , and the pairs should be composed of participants with the nearest next_tour_id .
Versusentity that hasuser1,user2,ratingUser1,ratingUser2,winnerand anotherVersusManagerthat would have a stack ofVersusentities (preformed) at the beginning and when all rounds of stage 1 passed formed a new stack ofVersuswinners. Accordingly, for each Versus entity you need to have an entry in the table (for example,c_battleorc_versus) - Rochfort