예제 #1
0
파일: tournament.py 프로젝트: dimatomp/play
    def run(self):
        '''
        Getting results of tournament.
        '''
        logger.info('running tournament #%d', self.tournament_id)

        game_signature = GameSignature(self.tournament_id)

        self.tournament_system = create()(self.players_list)
        for round_id, players in enumerate(self.tournament_system.get_rounds()):
            game_signature.round_id = round_id
            # If our tournament can give names to rounds, e.g. olympic,
            # we should also assign a name to the round. But it is also
            # possible, that get_round_name returns None.
            game_signature.round_name = self.tournament_system.get_round_name(
                round_id, len(list(self.tournament_system.get_rounds())))
            _round = Round(list(players), game_signature)
            _round.run()
            _round_results = _round.games_results
            self.tournament_system.add_round_results(_round_results)
        self.results = self.tournament_system.get_all_results()
        logger.info('tournament #%d finished', self.tournament_id)
예제 #2
0
from config_helpers import initialize_game_environment, players_parse
from visualizer import VideoVisualizer
import sys
from time import clock
import os

if len(sys.argv) < 5:
    print('Usage: create_video.py <path to game env> <folder with game logs> '
          '<filemask of logs> <resw_name> [-f <framerate>] [--silent]')
    exit()

if __name__ == '__main__':
    game_path, log_path, log_mask, res_name = sys.argv[1:5]
    framerate = 24 if '-f' not in sys.argv\
                  else int(sys.argv[sys.argv.index('-f') + 1])
    silent = '--silent' in sys.argv
    initialize_game_environment(game_path)
    import config
    from tournament_systems.tournament_system_factory import create
    beg = clock()
    ts = create()(players_parse(os.path.join(game_path,
                                             config.players_config)))
    visualizer = VideoVisualizer(framerate, config.Painter, log_mask,
                                 log_path, silent, ts.draw_table\
                                 if hasattr(ts, 'draw_table') else None)
    visualizer.compile(res_name)
    if not silent:
        print('Compiled in', clock() - beg, 'sec.')
 def test_exception_not_available_tournament_system(self):
     config.tournament_system = 'abacaba'
     with self.assertRaises(ts_factory.TournamentSystemNotFoundException):
         ts_factory.create()
 def test_all_tournament_systems(self):
     for ts_name, ts in all_ts.tournament_systems.items():
         ts_factory.config.tournament_system = ts_name
         self.assertTrue(isinstance(
             ts_factory.create()(), ts
         ))