Types of Games¶
About This Package¶
This package deals with creating various game types.
Game definitions¶
Top level module for creating a Game object instance. Also abstractly defines Player, Action, and Equilibrium objects.
-
class
games.types.game.
Actions
¶ Wrapper for an action that a Player can take.
-
class
games.types.game.
Eq
(play: list)¶ Wrapper for an equilibrium solution for the game instance.
- Parameters
play (list) – Index of action being taken.
-
class
games.types.game.
Game
(players: List[games.types.game.Player])¶ Bare-bones game theoretical defintion of a game instance.
- Parameters
players (List[Player]) – List of players defining the game interactions.
-
U_i
(i: int, play: list, *args) → Union[float, Any]¶ Returns utility of player i based on the play.
-
class
games.types.game.
Player
(name: str, index: int, actions: games.types.game.Actions)¶ Game theoretical based description of a player in a game.
- Parameters
-
U
(actions: list, *args) → Union[float, Any]¶ Utility function that should follow the von Neumann - Morgenstern axioms. Outlines preferences of own actions based on what actions othe rplayers have taken.
- Parameters
actions (list) – List of actions that each player in the game has taken.
*args – Here for extendability of the class.
- Raises
NotImplementedError – Needs to be implemented.
- Returns
Utility of the player.
- Return type
Union[float, Any]
Game Factory¶
Abstract definition for a factory class to create a game.
-
class
games.types.factory.
GFactory
¶ Factory class for creating a game.
-
classmethod
make_game
(*args) → games.types.game.Game¶ Main method for game creation.
- Parameters
*args – Arguments needed for creating a game.
- Raises
NotImplementedError – Needs to be implemented.
-
classmethod
Strategic Games¶
Object definitions for a strategic normal form game directly through payoff matrices. Includes factory methods for normal form game creation.
-
class
games.types.strategic.
StrategicFactory
¶ Factory class for creating a normal form game from a list of payoff matrices.
-
classmethod
make_game
(payoffs: List[numpy.ndarray]) → games.types.strategic.StrategicGame¶ Main method for game creation
- Parameters
payoffs (List[np.ndarray]) – Payoff matrix for each player. Shape matches the number of actions for each player.
- Returns
Strategic Normal Form Game.
- Return type
-
classmethod
-
class
games.types.strategic.
StrategicGame
(players: List[games.types.strategic.StrategicPlayer])¶ Strategic Normal Form Game.
- Parameters
players (List[StrategicPlayer]) – List of players in the game.
-
payoffs
¶ List of the payoff matrices for the defined game.
- Type
List[np.ndarray]
Congestion Games¶
Module for creating a Congestion Game with relevant player definitions.
-
class
games.types.congestion.
CongestionFactory
¶ Factory class for creating a congestion game based on given parameters.
-
classmethod
make_game
(all_actions: List[List[List[int]]], r_m: int, list_f_r: List[Callable[[int, List[int]], float]]) → games.types.congestion.CongestionGame¶ Main method for game creation
- Parameters
- Returns
Created congestion game.
- Return type
-
classmethod
-
class
games.types.congestion.
CongestionGame
(players: List[games.types.congestion.CongestionPlayer], r_m: int)¶ General Congestion Game with player and resource dependent covering functions.
- Parameters
players (List[StrategicPlayer]) – List of players in the game.
r_m (int) – number of resources in the congestion game.
-
pcover
(actions: List[List[int]]) → List[Tuple[int, List[int]]]¶ Gives what players are covering which resource over a given action set.
-
class
games.types.congestion.
CongestionPlayer
(name: str, index: int, actions: games.types.misc.FActions)¶ A player in a congestion game.
- Parameters
-
U
(actions: List[List[int]]) → float¶ Utility function that should follow the von Neumann - Morgenstern axioms. Outlines preferences of own actions based on what actions othe rplayers have taken.
-
f_r
(r: int, players: List[int]) → float¶ Utility given if covering the resource r when others are covering the resource as well.
- Parameters
- Raises
NotImplementedError – Needs to be implemented.
- Returns
Utility gained from the covering that resource.
- Return type
-
pcover
(actions: List[List[int]]) → List[Tuple[int, List[int]]]¶ Gives which players are covering resource r covered by self.
-
class
games.types.congestion.
MutableCGPlayer
(name: str, index: int, actions: games.types.misc.FActions, f_r: Callable[[int, List[int]], float])¶ Congestion Player with modifiable covering function f_r
- Parameters
-
f_r
(r: int, players: List[int]) → float¶ Utility given if covering the resource r when others are covering the resource as well.
Board Games¶
-
class
games.types.boardgame.
BGFactory
¶
-
class
games.types.boardgame.
BoardGame
(players, board)¶
-
class
games.types.boardgame.
BoardPlayer
(name, index, actions)¶ -
U
(play, board, *args)¶ Utility function that should follow the von Neumann - Morgenstern axioms. Outlines preferences of own actions based on what actions othe rplayers have taken.
- Parameters
actions (list) – List of actions that each player in the game has taken.
*args – Here for extendability of the class.
- Raises
NotImplementedError – Needs to be implemented.
- Returns
Utility of the player.
- Return type
Union[float, Any]
-
Equilibrium Definitions¶
Parent classes for types of equilibrium
-
class
games.types.equilibrium.
CoarseEq
(play)¶ Coarse Correlated Equilibrium.
-
class
games.types.equilibrium.
CorEq
(play)¶ Correlated Equilibrium.
-
class
games.types.equilibrium.
DomEq
(play)¶ Strictly Dominating Equilibrium
-
class
games.types.equilibrium.
MixedEq
(play)¶ Mixed Nash equilibrium.
-
class
games.types.equilibrium.
PureEq
(play)¶ Pure Nash Equilibrium.
Distributed Resource Games¶
-
class
games.types.resource.
ResourceFactory
¶ -
classmethod
make_game
(all_actions: List[List[List[int]]], values: List[float], f: List[float]) → games.types.resource.ResourceGame¶ Main method for game creation.
- Parameters
*args – Arguments needed for creating a game.
- Raises
NotImplementedError – Needs to be implemented.
-
classmethod
-
class
games.types.resource.
ResourceGame
(players: List[games.types.congestion.CongestionPlayer], values: List[float], f: List[float])¶
-
class
games.types.resource.
ResourcePlayer
(name: str, index: int, actions: games.types.misc.FActions, f: List[float], values: List[float])¶ -
f_r
(r: int, players: List[int]) → float¶ Utility given if covering the resource r when others are covering the resource as well.
- Parameters
- Raises
NotImplementedError – Needs to be implemented.
- Returns
Utility gained from the covering that resource.
- Return type
-
Miscellaneous¶
Miscellaneous class definitions and functions that are useful for creating games.
-
class
games.types.misc.
FActions
(actions: list)¶ Wrapper for a finite action set using a list.
- Parameters
actions (list) – Available actions to a player.
-
class
games.types.misc.
MutablePlayer
(name: str, index: int, actions: games.types.game.Actions, util: Callable[[...], Union[float, Any]])¶ Player with utility function as a object parameter.
- Parameters
-
U
(actions: list, *args) → Union[float, Any]¶ Utility function that should follow the von Neumann - Morgenstern axioms. Outlines preferences of own actions based on what actions othe rplayers have taken.
-
class
games.types.misc.
PotentialGame
(players: List[games.types.game.Player])¶ Potential Game endowed with a potential function.
- Parameters
players (List[Player]) – List of players defining the game interactions.
-
potential
(play: list, *args) → float¶ Potential function.
- Parameters
play (list) – Which indexes of actions are played by each player.
*args – Here for extendability of the class.
- Returns
Potential of the game.
- Return type
- Raises
NotImplementedError – Needs to be implemented.
-
class
games.types.misc.
WelfareGame
(players: List[games.types.game.Player])¶ Game endowed with a system welfare function. Convention is larger welfare is better.
- Parameters
players (List[Player]) – List of players defining the game interactions.
-
welfare
(play: list, *args) → Union[float, Any]¶ Welfare function.
- Parameters
play (list) – Which indexes of actions are played by each player.
*args – Here for extendability of the class.
- Returns
Welfare of the system.
- Return type
Union[float, Any]
- Raises
NotImplementedError – Needs to be implemented.