#1 by giodini121
Dear all I have an issue I am trying to solve but I do not find a reasonable way. My game has 2 players per group with 2 roles ("seller" and "buyer"). Groups are shuffled randomly every round keeping the roles constant for 7 rounds in total. For each seller I want to give a product from a list of 7 products and by the end of the 7 rounds the products are over. The buyer matched with the seller in the same round has the same product as the (matched) seller. Crucially, I want the buyer to see only ONCE each of the 7 products. The problem arises from the shuffling. By shuffling groups, some buyers are matched with a seller who has a product that the buyer has already seen. And this is of course wrong. I am considering this strategy: - in round = 1 I randomly draw from a list of available products for the seller I copy this random draw for the buyer I create a list of products drawn for the seller I create a list of products associated with the buyer - in round = 2 I need to match sellers and buyers conditional on the available products of both. This second part is very complex. Do you have any suggestions? I am also considering using dictionaries and group matrices to avoid this mechanism. This is my starting code that gives a seller a product for each round: all_products = ['Product1', 'Product2', 'Product3', 'Product4', 'Product5', 'Product6'] for player in subsession.get_players(): participant = player.participant if player.role == "Seller": if subsession.round_number == 1: product = 'Product0' available_products = all_products else: round_number = subsession.round_number removed_products = participant.vars.get('removed_products', []) # Create a list of available products excluding removed products available_products = [x for x in all_products if x not in removed_products] if available_products: product = random.choice(available_products) removed_products.append(product) participant.vars['removed_products'] = removed_products else: product = 'No product available' player.product_this_round = product