• tetris11@lemmy.ml
    link
    fedilink
    arrow-up
    5
    arrow-down
    1
    ·
    edit-2
    6 months ago
    1. Everyone tosses three coins, and posts it in the chat
      • If a player tosses three of the same, they have to toss again.
    2. Everyone chooses the mode coin from their neighbour, and adds it to their stack
    3. Each player, with 3+N coins, picks the mode coin in their own collection.
      • Ideally: the player’s own bias, is outweighed by the other player’s biases.
    4. The final coin is the mode of all players coins.
    spoiler
    from numpy import median
    from pprint import pprint
    
    players = {"p1" : [1,0,1],  ## playing fair
               "p2" : [0,0,1],  ## cheating
               "p3" : [1,1,0],  ## cheating
               "p4" : [1,1,0],  ## cheating
               "p5" : [0,0,1]}   ## playing fair
    print("Initial rolls:")
    pprint(players)
    
    get_mode_coin = lambda x: int(median(x))
    get_all_mode_coins = lambda x: [get_mode_coin(y) for y in x]
    
    for play in players: ## Players add the mode coin from their neigbours
        players[play] = players[play] + get_all_mode_coins(players.values())
    print("First picks:")
    pprint(players)
    
    for play in players: ## Players collapse their collections to mode
        players[play] = [get_mode_coin(players[play])]
    print("Last modes:", players)
    
    print("Final choice:", get_mode_coin([x for x in players.values()]))
    

    Which as you can see, is no better than simply picking the median coin from the initial rolls. I thank you for wasting your time.

    • tetris11@lemmy.ml
      link
      fedilink
      arrow-up
      2
      ·
      6 months ago

      Second attempt that factors in cheating.

      spoiler
      from numpy import median
      from random import choice
      from pprint import pprint
      
      # Functions
      get_mode_coin = lambda x: int(median(x))
      def pick(player, wants):
          for neighbor in players:
              if player != neighbor:
                  neighbor_purse = players[neighbor]["purse"]
                  if wants:
                      if wants in neighbor_purse: # Cheat
                          players[play]["purse"] = players[play]["purse"] + [wants]
                          continue
                  players[play]["purse"] = players[play]["purse"] + [choice(neighbor_purse)]
      
      
      # Main
      players = {"p1" : {"purse": [1,0,1], "wants": False}, ## playing fair
                 "p2" : {"purse": [0,0,1], "wants": 0}, ## cheating
                 "p3" : {"purse": [1,1,0], "wants": 1}, ## cheating
                 "p4" : {"purse": [1,1,0], "wants": 0}, ## cheating
                 "p5" : {"purse": [0,0,1], "wants": False}}   ## playing fair
      
      for play in players: ## Players pick a desired coin from each of their neighbours
          pick(play, players[play]["wants"])
      print("First picks:")
      pprint(players)
      
      for play in players: ## Players collapse their collections to mode
          players[play] = [get_mode_coin(players[play]["purse"])]
      print("Last modes:", players)
      
      print("Final choice:", get_mode_coin([x for x in players.values()]))
      

      So, my method doesn’t work