Exemplo n.º 1
0
 def test_gamecount_equity(self):
     rank_sys = RankingSystem.read(RESOURCES_FOLDER /
                                   '20210925212802_rankings.json')
     ticket_sys = TicketSystem.read(
         RESOURCES_FOLDER / '20210925212802_tickets.json', LeagueSettings())
     bot_ids = rank_sys.ratings.keys()
     for i in range(19):
         MatchMaker.decide_on_players_2(bot_ids, rank_sys, ticket_sys)
     game_counts = list(ticket_sys.session_game_counts.values())
     print(ticket_sys.session_game_counts)
     print(
         f'Game count std dev: {numpy.std(game_counts)}, max: {max(game_counts)} min: {min(game_counts)} avg: {numpy.mean(game_counts)}'
     )
     for i in range(5):
         print(f'Num with {i}: {game_counts.count(i)}')
Exemplo n.º 2
0
    def _test_decide(self, decide_name, decide_function):
        rank_sys = RankingSystem.read(RESOURCES_FOLDER /
                                      '20210925212802_rankings.json')
        ticket_sys = TicketSystem.read(
            RESOURCES_FOLDER / '20210925212802_tickets.json', LeagueSettings())
        bot_ids = sorted(rank_sys.ratings.keys(),
                         key=lambda id: rank_sys.ratings[id].mu)
        qualities = []
        max_mmr_diffs = []
        matches_played = {bot_id: 0 for bot_id in bot_ids}
        for i in range(NUM_ITERATIONS):
            players = decide_function(bot_ids, rank_sys, ticket_sys)
            quality = get_trueskill_quality(players, rank_sys)
            qualities.append(quality)
            max_mmr_diff = get_max_mmr_diff(players, rank_sys)
            max_mmr_diffs.append(max_mmr_diff)
            for bot_id in itertools.chain.from_iterable(players):
                matches_played[bot_id] += 1

        average = sum(qualities) / NUM_ITERATIONS
        print(f'{decide_name} average quality: {average}')
        plt.hist(qualities, bins=20, range=(0, 1))
        plt.ylabel('matches')
        plt.xlabel('quality')
        plt.title(f'{decide_name} - Matches played by quality')
        plt.show()
        plt.hist(max_mmr_diffs, bins=10, range=(0, 100))
        plt.ylabel('matches')
        plt.xlabel('max MMR difference')
        plt.title(f'{decide_name} - Matches played by MMR difference')
        plt.show()
        matches = matches_played.values()
        plt.bar(range(len(matches)), matches)
        plt.ylabel('matches')
        plt.xlabel('bot (sorted by MMR)')
        plt.title(f'{decide_name} - Matches played by bot')
        plt.show()
Exemplo n.º 3
0
from paths import LeagueDir
from ranking_system import RankingSystem
from settings import PersistentSettings
import seaborn as sns
import pandas as pd
import matplotlib.pylab as plt

settings = PersistentSettings.load()
ld = LeagueDir(Path(settings.league_dir_raw))

rankings = {}
for path in list(ld.rankings.iterdir()):
    time = path.name[:8]
    if time not in rankings:
        rankings[time] = {}
    ranking = RankingSystem.read(path)
    rankings[time].update(ranking.get_mmr_all())

bots = sorted(set([bot_id for time in rankings for bot_id in rankings[time]]))
times = sorted(rankings.keys())
data = {bot: [rankings[time].get(bot) or 33 for time in times] for bot in bots}
df = pd.DataFrame.from_dict(data,
                            orient='index',
                            columns=range(1,
                                          len(times) + 1)).transpose()

print(df)

plt.figure(figsize=(10.0, 5.0))
plt.plot(df)
plt.legend(bots,