def play_round(self, players): # moves: Nx(N-1) array # where moves[i, j] is action of player i for player j moves = Moves([p.play() for p in players]) for i, player in enumerate(players): player.update_state(moves.opponent_moves(i)) scores = self.score_moves(moves) return scores
def play_two_groups(self, graphs1, graphs2, n_rounds=20): players1 = [Player(graph, len(graphs2)) for graph in graphs1] players2 = [Player(graph, len(graphs1)) for graph in graphs2] total_scores = None for r in range(n_rounds): moves1 = Moves([p.play() for p in players1]) moves2 = Moves([p.play() for p in players2]) for i, player in enumerate(players1): player.update_state( moves2.opponent_moves(i, exclude_self=False)) for i, player in enumerate(players2): player.update_state( moves1.opponent_moves(i, exclude_self=False)) scores = self.score_moves(moves1, moves2) if total_scores is None: total_scores = scores else: total_scores += scores return total_scores