misc package¶
Submodules¶
misc.evaluate module¶
A collection of functions for evaluating strategies given a game.
- misc.evaluate.evaluate_strategies(Game, strategies, n_iters)[source]¶
Evaluates a set of strategies on a game.
- Parameters
Game (
Type
[ExtensiveFormGame
]) – The game class to evaluate the strategies on (e.g.,RockPaperScissorGame
).A list of strategies, one strategy per each player in the game. Example:
player0_strat = {"P0": [1/3, 1/3, 1/3]} # equally likely rock-paper-scissor player1_strat = {"P1": [0.4, 0.4, 0.2]} strategies = [player0_strat, player1_strat]
n_iters (
int
) – The number of iterations to run the game for.
- Return type
- Returns
A list of the average payoffs of each strategy.
misc.trainer module¶
A class to train players in an extensive form game.
The players are trained over a number of games by calling each player’s update_strategy
method
after each game. The average payoffs and the average strategies during training are recorded.
- class misc.trainer.NormalFormTrainer(Game, players, n_iters=100, display_status_bar=True)[source]¶
Bases:
object
A class to train players in an extensive form game.
- Parameters
- game¶
The game to train players in.
- Type
- ep_payoffs¶
The payoffs of each player in each game over the course of this trainer instance.
- Type
np.ndarray
- manager¶
The enlighten manager to display the status bar.
- Type
- pbar¶
The enlighten counter to display the status bar.
- Type
- train(freeze_ls=[])[source]¶
Train the players for n_iter games using each player’s update_strategy function.
Note
Players in the
freeze_ls
list will not be trained.
- property avg_payoffs: numpy.ndarray¶
Get the average payoffs of each player over the course of this trainer instance.
- Return type
- Returns
The average payoffs of each player.
- property avg_strategies: dict¶
Get the average strategies of each player.
- Return type
- Returns
The average strategies of each player.
- store_strategies(filenames)[source]¶
Store the episodic strategies and average strategies of each player in json files.
misc.utils module¶
A collection of helper functions and classes.