예제 #1
0
    def __init__(self, payoff_matrix, N):
        A = np.asarray(payoff_matrix)
        if A.ndim != 2 or A.shape[0] != A.shape[1]:
            raise ValueError('payoff matrix must be square')
        self.num_actions = A.shape[0]  # Number of actions
        self.N = N  # Number of players

        self.player = Player(A)  # "Representative player"
        self.tie_breaking = 'smallest'

        # Current action distribution
        self.current_action_dist = np.zeros(self.num_actions, dtype=int)
        self.current_action_dist[0] = self.N  # Initialization
예제 #2
0
    def __init__(self, payoff_matrix, adj_matrix):
        self.adj_matrix = sparse.csr_matrix(adj_matrix)
        M, N = self.adj_matrix.shape
        if N != M:
            raise ValueError('adjacency matrix must be square')
        self.N = N  # Number of players

        A = np.asarray(payoff_matrix)
        if A.ndim != 2 or A.shape[0] != A.shape[1]:
            raise ValueError('payoff matrix must be square')
        self.num_actions = A.shape[0]  # Number of actions

        self.players = [Player(A) for i in range(self.N)]
        self.tie_breaking = 'smallest'

        init_actions = np.zeros(self.N, dtype=int)
        self.current_actions_mixed = sparse.csr_matrix(
            (np.ones(self.N, dtype=int), init_actions, np.arange(self.N + 1)),
            shape=(self.N, self.num_actions))
        self._current_actions = self.current_actions_mixed.indices.view()
예제 #3
0
 def setUp(self):
     """Setup a Player instance"""
     payoffs_2opponents = [[[3, 6], [4, 2]], [[1, 0], [5, 7]]]
     self.player = Player(payoffs_2opponents)
예제 #4
0
def test_normalformgame_invalid_input_players_num_inconsistent():
    p0 = Player(np.zeros((2, 2, 2)))
    p1 = Player(np.zeros((2, 2, 2)))
    g = NormalFormGame([p0, p1])
예제 #5
0
 def setUp(self):
     """Setup a Player instance"""
     coordination_game_matrix = [[4, 0], [3, 2]]
     self.player = Player(coordination_game_matrix)
예제 #6
0
 def setUp(self):
     """Setup a Player instance"""
     payoffs = [0, 1]
     self.player = Player(payoffs)
예제 #7
0
 def setUp(self):
     """Setup a NormalFormGame instance"""
     payoffs_2opponents = [[[3, 6], [4, 2]], [[1, 0], [5, 7]]]
     player = Player(payoffs_2opponents)
     self.g = NormalFormGame([player for i in range(3)])