Esempio n. 1
0
 def game_to_payoffs(game: Game) -> List[np.ndarray]:
     """Turn a noncooperative game into strategic form through calculation of payoff arrays.
     
     Args:
         game (Game): Noncooperative game, all players must have a finite number of actioms.
     
     Returns:
         List[np.ndarray]: List of payoff arrays defining the game.
     """
     num_act = [len(ac) for ac in game.actions]
     payoffs = [None] * game.N
     for i, player in enumerate(game.players):
         payoff_i = np.zeros(num_act)
         # generate all possible types of action indices
         for a in product(*[range(n_i) for n_i in num_act]):
             payoff_i[a] = game.U_i(i, a)
         payoffs[i] = payoff_i
     return payoffs
Esempio n. 2
0
 def __init__(self, players: List[StrategicPlayer]):
     Game.__init__(self, players)
     self.payoffs: List[np.ndarray] = [p.payoff for p in self.players]
Esempio n. 3
0
	def test_verify_game(self):
		self.assertRaises(ValueError, verify_player_list, Game([]))
		self.assertRaises(ValueError, verify_player_list, Game([Player('0', 0, Actions()), Player('1', 2, Actions())]))
Esempio n. 4
0
 def __init__(self, players: List[Player]):
     Game.__init__(self, players)
Esempio n. 5
0
 def __init__(self, players, board):
     Game.__init__(self, players)
     self.board = board
Esempio n. 6
0
 def __init__(self, players: List[CongestionPlayer], r_m: int):
     Game.__init__(self, players)
     self.r_m: int = r_m
Esempio n. 7
0
 def __init__(self, players):
     Game.__init__(self, players)