ramo.game package
Submodules
ramo.game.checking module
ramo.game.example_games module
- ramo.game.example_games.get_monfg(game)
Get a predefined MONFG.
- Parameters:
game (str) – The string of the game.
- Returns:
An MONFG object initiated with predefined payoffs.
- Return type:
- ramo.game.example_games.payoffs1 = [numpy.array, numpy.array]
Game 1 - The (im)balancing act game. A 3-action 2-player game with team rewards.
There are no NE under SER using u1 and u2. There are two PSNE using u1 and u5: [0, 0], [2, 2]. Checked for correctness using Gambit.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs10 = [numpy.array, numpy.array]
Game 10 - A 2-action 2-player game with individual rewards.
This game has no Nash equilibrium with utility functions u1 and u2, but does have a cyclic Nash equilibrium.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs11 = [numpy.array, numpy.array]
Game 11 - A 2-action 2-player game with individual rewards.
The same game as game 10 but intended to be used with the utility functions reversed.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs12 = [numpy.array, numpy.array]
Game 12 - A 3-action 2-player game with individual rewards.
This game has two PSNE using u1 and u5: [0, 0], [2, 2]. Checked for correctness using Gambit.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs13 = [numpy.array, numpy.array]
Game 13 - A 3-action 2-player game with individual rewards.
This game has no PSNE using u1 and u5. Checked for correctness using Gambit.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs14 = [numpy.array, numpy.array, numpy.array]
Game 14 - A 2-action 3-player game with individual rewards.
This game has two PSNE using u1, u5 and u6: [0, 1, 1], [1, 0, 1]. Checked for correctness by hand.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs15 = [numpy.array, numpy.array, numpy.array]
Game 15 - A 3-player game where p1 has 3 actions, p2 has 2 and p3 has 3, with individual rewards.
This game has three PSNE using u1, u5 and u6: [0, 1, 1], [1, 0, 2], [1, 1, 0]. Checked for correctness by hand.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs16 = [numpy.array, numpy.array]
Game 16 - A 2-player 2-action game with individual rewards.
This game has no NE when both players use the utility function u1.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs17 = [numpy.array, numpy.array]
Game 17 - A 2-action 2-player game with team rewards.
There are two NE under SER using u1 and u2: (L, L) and (M, M). This game solves the problem from game 4, which in some papers falsely claims to have these two strategies as NE. There are two PSNE using u1 and u5: [0, 0], [1, 1]. Checked for correctness using Gambit. This game shows cyclic behaviour under IBR with simultaneous updates but not with alternating updates. This game shows no cyclic behaviour with fictitious play.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs18 = [numpy.array, numpy.array]
Game 18 - A 3-action 2-player game with team rewards.
There are three NE under SER using u1 and u2: (M, M), (L, L) and (R, R). This game solves the problem from game 5, which in some papers falsely claims to have these three strategies as NE. There are three NE under SER using u1 and u2: (L,L), (M,M) and (R,R). There are three PSNE using u1 and u5: [0, 0], [1, 1], [2, 2]. Checked for correctness using Gambit. This game shows cyclic behaviour under IBR with simultaneous updates but not with alternating updates.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs19 = [numpy.array, numpy.array]
Game 19 - A 2-action 2-player game with individual rewards.
This game has a NE of {(0.5, 0.5), (0.75, 0.25)} using u2 for both players. It is used to test the correctness of the FP and IBR algorithms.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs2 = [numpy.array, numpy.array]
Game 2 - The (im)balancing act game without M. A 2-action 2-player game with team rewards.
There are no NE under SER using u1 and u2. There are two PSNE using u1 and u5: [0, 0], [1, 1]. Checked for correctness using Gambit.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs3 = [numpy.array, numpy.array]
Game 3 - The (im)balancing act game without R. A 2-action 2-player game with team rewards.
There is one NE under SER using u1 and u2: (L, M). There is one PSNE using u1 and u5: [0, 0]. Checked for correctness using Gambit.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs4 = [numpy.array, numpy.array]
Game 4 - A 2-action 2-player game with team rewards.
There is one NE under SER using u1 and u2: (M, M). Several papers have claimed that (L,L) is also a NE. This is false. Player 2 has an incentive to deviate to (5/6, 1/6). There are two PSNE using u1 and u5: [0, 0], [1, 1]. Checked for correctness using Gambit. This game shows cyclic behaviour under IBR with simultaneous updates but not with alternating updates. This game shows no cyclic behaviour with fictitious play.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs5 = [numpy.array, numpy.array]
Game 5 - A 3-action 2-player game with team rewards.
There is one NE under SER using u1 and u2: (M, M). Several papers have claimed that (L,L) and (R, R) are also NE. This is false. Player 2 has an incentive to deviate in both cases. For (L, L) they deviate to (5/6, 1/6, 0) and for (R, R) they deviate to (0, 1/4, 3/4). There are three NE under SER using u1 and u2: (L,L), (M,M) and (R,R). There are three PSNE using u1 and u5: [0, 0], [1, 1], [2, 2]. Checked for correctness using Gambit. This game shows cyclic behaviour under IBR with simultaneous updates but not with alternating updates.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs6 = [numpy.array, numpy.array]
Game 6 - A multi-objectivised version of the game of chicken. Both players use the utility function u2.
The cyclic equilibrium is to go 2/3 your own, 1/3 other action uniformly over these.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs7 = [numpy.array, numpy.array]
Game 7 - A 2-action 2-player game with team rewards.
An example of a game where commitment may be exploited.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs8 = [numpy.array, numpy.array]
Game 8 - A 2-action 2-player game with team rewards.
There are two NE when both agents use utility function u2 under SER: (L,L) and (R, R). The cyclic equilibrium is to mix uniformly over these.
- Type:
List[ndarray]
- ramo.game.example_games.payoffs9 = [numpy.array, numpy.array]
Game 9 - A 2-action 2-player game with team rewards.
A noisy version of game 8. The cyclic equilibrium with utility function u2 is to play A 75% of the time and 25% B.
- Type:
List[ndarray]
ramo.game.generators module
- ramo.game.generators.covariant_monfg(player_actions, num_objectives=2, mean=0, std=1, cov=0, rng=None)
Generate a random MONFG with payoffs from a normal distribution and given covariance.
- Parameters:
player_actions (Tuple[int], optional) – A tuple of actions indexed by player. (Default value = (2, 2))
num_objectives (int, optional) – The number of objectives in the game. (Default value = 2)
mean (float, optional) – The mean of the normal distribution. (Default value = 0)
std (float, optional) – The standard deviation of the normal distribution. (Default value = 1)
cov (float, optional) – The covariance between the players. (Default value = 0)
rng (Generator, optional) – A random number generator. (Default value = None)
- Returns:
The generated MONFG.
- Return type:
- ramo.game.generators.discrete_uniform_monfg(player_actions=(2, 2), num_objectives=2, reward_min_bound=0, reward_max_bound=5, rng=None)
Generate a random MONFG with payoffs from a discrete uniform distribution.
- Parameters:
player_actions (Tuple[int], optional) – A tuple of actions indexed by player. (Default value = (2, 2))
num_objectives (int, optional) – The number of objectives in the game. (Default value = 2)
reward_min_bound (int, optional) – The minimum reward on an objective. (Default value = 0)
reward_max_bound (int, optional) – The maximum reward on an objective. (Default value = 5)
rng (Generator, optional) – A random number generator. (Default value = None)
- Returns:
The generated MONFG.
- Return type:
- ramo.game.generators.identity_game(player_actions)
Generate an identity game.
- Parameters:
player_actions (Tuple[int]) – A tuple of actions indexed by player.
- Returns:
The generated MONFG.
- Return type:
- ramo.game.generators.normal_distributed_monfg(player_actions=(2, 2), num_objectives=2, mean=0, std=1, rng=None)
Generate a random MONFG with payoffs from a normal distribution.
- Parameters:
player_actions (Tuple[int], optional) – A tuple of actions indexed by player. (Default value = (2, 2))
num_objectives (int, optional) – The number of objectives in the game. (Default value = 2)
mean (float, optional) – The mean of the normal distribution. (Default value = 0)
std (float, optional) – The standard deviation of the normal distribution. (Default value = 1)
rng (Generator, optional) – A random number generator. (Default value = None)
- Returns:
The generated MONFG.
- Return type:
- ramo.game.generators.scalarised_game(monfg, u_tpl)
Scalarise an MONFG, which is a list of payoff matrices, using individual utility functions.
Note
The scalarised game is sometimes referred to as a trade-off game.
- Parameters:
monfg (MONFG) – An MONFG object.
u_tpl (Tuple[callable]) – A utility function per player.
- Returns:
The scalarised game. Each payoff matrix has the same shape as in the MONFG except the last dimension which is removed due to the scalarisation.
- Return type:
List[ndarray]
- ramo.game.generators.uniform_monfg(player_actions=(2, 2), num_objectives=2, reward_min_bound=0, reward_max_bound=5, rng=None)
Generate a random MONFG with payoffs from a uniform distribution.
- Parameters:
player_actions (Tuple[int], optional) – A tuple of actions indexed by player. (Default value = (2, 2))
num_objectives (int, optional) – The number of objectives in the game. (Default value = 2)
reward_min_bound (int, optional) – The minimum reward on an objective. (Default value = 0)
reward_max_bound (int, optional) – The maximum reward on an objective. (Default value = 5)
rng (Generator, optional) – A random number generator. (Default value = None)
- Returns:
The generated MONFG.
- Return type:
- ramo.game.generators.unique_ps_game(player_actions=(2, 2), num_objectives=2, reward_min_bound=0, reward_max_bound=5, rng=None)
- Generate a random single-objective game where pure strategy payoffs for each opponent pure strategy are forced to
be different.
This generator makes a game where pure strategies have different payoffs for each opponent pure strategy. Note that this does not imply all payoffs are unique. The intention of this generator is to create a generic/non-degenerate game. In two-player two-action games this condition is sufficient. In all other games, this condition is necessary but not sufficient.
Note
The current implementation samples a point, which is then hashed into a dictionary. When the dictionary reaches the correct length, there are enough unique payoffs.
- Parameters:
player_actions (Tuple[int], optional) – A tuple of actions indexed by player. (Default value = (2, 2))
num_objectives (int, optional) – The number of objectives in the game. (Default value = 2)
reward_min_bound (int, optional) – The minimum reward on an objective. (Default value = 0)
reward_max_bound (int, optional) – The maximum reward on an objective. (Default value = 5)
rng (Generator, optional) – A random number generator. (Default value = None)
- Returns:
The generated MONFG with unique pure strategy payoffs for each opponent pure strategy.
- Return type:
- Raises:
Exception – When the generic game is impossible to create. This can happen when the action space of a player is
larger than the reward space. This would imply the same reward for different actions, making the game –
non-generic. –
ramo.game.monfg module
- class ramo.game.monfg.MONFG(payoffs, players=None)
Bases:
objectA wrapper class for an MONFG.
- get_num_objectives(player=0)
Get the number of objectives for a given player.
- Parameters:
player (int, optional) – The player to get the number of objectives for. (Default value = 0)
- Returns:
The number of objectives in the game for the given player.
- Return type:
int
- get_payoff_matrix(player)
Get the payoff matrix for a specific player.
- Parameters:
player (int) – The player index.
- Returns:
A payoff matrix.
- Return type:
ndarray