#1 by Ben (edited )
Hi, I am trying to put participant into a certain group given a condition given to them in the previous app. The following code rank the participant in the expected order, but put all of them in the group number 2, instead of the 3 groups that I want to design. How can I fix that ? def group_by_arrival_time_method(subsession: Subsession, waiting_players): print('in group_by_arrival_time_method') a_players = [p for p in waiting_players if p.participant.roole == 'A'] b_players = [p for p in waiting_players if p.participant.roole == 'B'] c_players = [p for p in waiting_players if p.participant.roole == 'C'] if len(a_players) == 4 and len(b_players) == 4 and len(c_players) == 4: return [a_players[0], a_players[1], a_players[2], a_players[3], b_players[0], b_players[1], b_players[2], b_players[3], c_players[0], c_players[1], c_players[2], c_players[3]] I am also wondering if it is possible to create 2x2 matching in groups of 4 (in a group of 4, p1 vs p2 and p3 vs p4), that will change randomly during the different rounds Any help will be much appreciated ! Thanks in advance
#2 by Ben (edited )
Hi, I got a super ugly fix but it seems to work to I put it here just in case: def group_by_arrival_time_method(subsession, waiting_players): while len(waiting_players) >= 4: rooles = [(p, p.participant.roole) for p in waiting_players] sorted_rooles = sorted(rooles, key=lambda x: x[1]) sorted_player = [p[0] for p in sorted_rooles] if sorted_rooles[3][1] == 'A' and sorted_rooles[0][1] == 'A' and sorted_rooles[2][1] == 'A' and sorted_rooles[1][1] == 'A': return sorted_player[:4] elif sorted_rooles[3][1] == 'B' and sorted_rooles[0][1] == 'B' and sorted_rooles[2][1] == 'B' and sorted_rooles[1][1] == 'B': return sorted_player[:4] elif sorted_rooles[3][1] == 'C' and sorted_rooles[0][1] == 'C' and sorted_rooles[2][1] == 'C' and sorted_rooles[1][1] == 'C': return sorted_player[:4] break I am now trying to get the participants to play inside their group of 4 in 2x2 games for 5 rounds. I am wondering how it is possible to do so Any help will be super appreciated Thank you in advance
#3 by Ben (edited )
Hi, to be more precise, I want to know if in a single app, it is possible to make participants face each other in "1 vs 1" randomly drawn within a group of 4. The 1 vs 1 will change, but the group of 4 will remain the same for the entire app If you have any idea, please let me know ! Thank you in advance