コード例 #1
0
def main(unused_arg):
    # Construct meta-game payoff tables
    # payoff_tables = get_kuhn_poker_data()

    payoff_tables = [
        np.array([[1.1, -10.0], [1.0, -1.0], [-1.0, 1.0]]),
        np.array([[-1.1, 10.0], [-1.0, 1.0], [1.0, -1.0]])
    ]

    payoffs_are_hpt_format = utils.check_payoffs_are_hpt(payoff_tables)
    strat_labels = utils.get_strat_profile_labels(payoff_tables,
                                                  payoffs_are_hpt_format)

    # Run AlphaRank

    rhos, rho_m, pi, _, _ = alpharank.compute(payoff_tables, alpha=1e1)

    # Report & plot results
    alpharank.print_results(payoff_tables,
                            payoffs_are_hpt_format,
                            rhos=rhos,
                            rho_m=rho_m,
                            pi=pi)
    utils.print_rankings_table(payoff_tables, pi, strat_labels)
    m_network_plotter = alpharank_visualizer.NetworkPlot(payoff_tables,
                                                         rhos,
                                                         rho_m,
                                                         pi,
                                                         strat_labels,
                                                         num_top_profiles=8)
    m_network_plotter.compute_and_draw_network()
コード例 #2
0
ファイル: alpharank.py プロジェクト: maxiaoba/rlkit
def compute_and_report_alpharank(payoff_tables,
                                 m=50,
                                 alpha=100,
                                 verbose=False,
                                 num_top_strats_to_print=8):
    """Computes and visualizes Alpha-Rank outputs.

  Args:
    payoff_tables: List of game payoff tables, one for each agent identity. Each
      payoff_table may be either a numpy array, or a _PayoffTableInterface
      object.
    m: Finite population size.
    alpha: Fermi distribution temperature parameter.
    verbose: Set to True to print intermediate results.
    num_top_strats_to_print: Number of top strategies to print.

  Returns:
    pi: AlphaRank stationary distribution/rankings.
  """
    payoffs_are_hpt_format = utils.check_payoffs_are_hpt(payoff_tables)
    rhos, rho_m, pi, _, _ = compute(payoff_tables, m=m, alpha=alpha)
    strat_labels = utils.get_strat_profile_labels(payoff_tables,
                                                  payoffs_are_hpt_format)

    if verbose:
        print_results(payoff_tables, payoffs_are_hpt_format, pi=pi)

    utils.print_rankings_table(payoff_tables,
                               pi,
                               strat_labels,
                               num_top_strats_to_print=num_top_strats_to_print)
    m_network_plotter = NetworkPlot(payoff_tables,
                                    rhos,
                                    rho_m,
                                    pi,
                                    strat_labels,
                                    num_top_profiles=8)
    m_network_plotter.compute_and_draw_network()
    return pi
コード例 #3
0
    # Import the csv
    df = pd.read_csv(csv_path, index_col=False)

    # Convert to payoff_tables
    payoff_tables, strat_labels = payoff_tables_from_df(df)
    # payoff_tables = heuristic_payoff_table.from_elo_scores([1286, 1322, 1401, 1440, 1457, 1466, 1470])

    payoffs_are_hpt_format = utils.check_payoffs_are_hpt(payoff_tables)

    # strat_labels = utils.get_strat_profile_labels(payoff_tables(), payoffs_are_hpt_format)

    # Run AlphaRank
    rhos, rho_m, pi, _, _ = alpharank.compute(payoff_tables, alpha=1e-1)

    # Report & plot results
    alpharank.print_results(payoff_tables,
                            payoffs_are_hpt_format,
                            rhos=rhos,
                            rho_m=rho_m,
                            pi=pi)

    utils.print_rankings_table(payoff_tables, pi, strat_labels)

    m_network_plotter = alpharank_visualizer.NetworkPlot(payoff_tables,
                                                         rhos,
                                                         rho_m,
                                                         pi,
                                                         strat_labels,
                                                         num_top_profiles=7)
    m_network_plotter.compute_and_draw_network()
    # alpharank.sweep_pi_vs_alpha(payoff_tables, visualize=True)