Cross Evaluating Random Players

Complete source code for this example is available here.

A similar example using gen 7 mechanics is available here.

This example illustrates how to locally run existing agents and utilize the cross_evaluate utility function to measure the relative performance of multiple agents.

Install tabulate for formatting results by running pip install tabulate.

[1]:
from poke_env.player import RandomPlayer, cross_evaluate
from tabulate import tabulate

# Create three random players
players = [RandomPlayer(max_concurrent_battles=10) for _ in range(3)]

# Cross evaluate players: each player plays 20 games against every other player
cross_evaluation = await cross_evaluate(players, n_challenges=20)

# Prepare results for display
table = [["-"] + [p.username for p in players]]
for p_1, results in cross_evaluation.items():
    table.append([p_1] + [cross_evaluation[p_1][p_2] for p_2 in results])

# Display results
print(tabulate(table))

--------------  --------------  --------------  --------------
-               RandomPlayer 1  RandomPlayer 2  RandomPlayer 3
RandomPlayer 1                  0.45            0.45
RandomPlayer 2  0.55                            0.65
RandomPlayer 3  0.55            0.35
--------------  --------------  --------------  --------------

Running the above cells will output a table displaying the results of the cross evaluation among the players.

For creating custom players, refer to the max_damage_player example.

For diving into Reinforcement Learning, check out the rl_with_open_ai_gym_wrapper example.