Exemple #1
0
    def __post_init__(self):
        # Create/stash connection
        db_path = settings.MONITORING_DB_PATH
        full_path_mkdir_p(db_path)
        self.db_connection = sqlite3.connect(db_path)

        # Ensure tables are created
        # - All table/index creates are re-runnable
        SystemStats.build_table(self.db_connection)
Exemple #2
0
    def record_replay(self, output_dir):
        replay = AgentReplay.from_agent(self)

        # Write replay
        # - mkdir -p replay path if it doesn't exist.
        game_id = self.environment.id
        agent_num = self.agent_num
        output_path = f"{output_dir}/{game_id}-{agent_num}.json"
        full_path_mkdir_p(output_path)
        with open(output_path, 'w') as fout:
            fout.write(json.dumps(replay.marshall()))
        if settings.VERBOSITY >= 2:
            print("Saved replay:", output_path)
        return output_path, replay
Exemple #3
0
    def save_results(self, output_path):
        results = []
        for entrant in self.entrants.values():
            species, generation = entrant.bot.name.split("-")
            generation = int(generation)
            results.append((
                species,
                generation,
                entrant.skill_rating.mu,
                entrant.skill_rating.sigma,
            ))

        full_path_mkdir_p(output_path)
        with open(output_path, 'w') as f:
            f.write(json.dumps(results))
        print(f"\nSaved results to: {output_path}")