Beispiel #1
0
def game_session(game_id: int,
                 matrix_suite: MatrixSuite,
                 strategies: List[Strategy],
                 proportions: List[List[float]],
                 restarts: int,
                 rounds=1000) -> None:
    """
    Builds the game session according to the given parameters.
    Parameters:
        *game_id*: Identifier, it gets printed on console
        *matrix_suite: The MatrixSuite that the game is played on
        *strategies*: The set of strategies that will play against each other
        *proportions*: The probability distribution associated to each strategy for replicator dynamic
        *restarts*: The number of restart per game session
        *rounds* The number of rounds per restart, default is 1000
    """

    print("\n==============================================\n")

    print("GAME ", game_id, " \n")
    grand_table = GrandTable(matrix_suite, strategies, restarts, rounds)

    grand_table.play_games()
    print(grand_table)
    # grand_table.to_latex("Game_" + str(game_id))

    for i, proportion in enumerate(proportions):
        replicator_dynamic = ReplicatorDynamic(grand_table)
        replicator_dynamic.run(proportion,
                               name="Game_" + str(game_id) + "_" + str(i + 1))

    print("Gambit test result:")
    Nash.nash_equilibria(strategies, grand_table)