コード例 #1
0
ファイル: main.py プロジェクト: dimatomp/play
 def _load_players(self):
     '''
     Load players_list with players_parse(it parses
     file containing player's information), filename is there in config
     '''
     players_config_path = os.path.join(self._game_path,
                                        config.players_config)
     self._players_list = config_helpers.players_parse(players_config_path)
     if self._players_list is None:
         raise PlayersException('Players list doesn\'t exist')
コード例 #2
0
ファイル: config_helpers_test.py プロジェクト: dimatomp/play
    def test_write_logs(self):
        self.maxDiff = None

        test_logs = open('test_for_players_parse', 'w')
        test_logs.write("""


"Author Authorovich" "MegaBot" "/home/artur/bot_path"
Author Bot "/usr/lol"
Author "Bot and bot" /usr/lol
Author "Bot and bot'   '/usr/lol"
"Author and co"   Bot /usr/lol
"Author and co" Bot     "/usr/lol"
"Author and co"      'Bot' /usr/lol
Author   Bot     /usr/lol
  '   '   a   '   '


     """)
        test_logs.close()
        gotten_list = config_helpers.players_parse('test_for_players_parse')
        answer_list = list()
        answer_list.append(player.Player('/home/artur/bot_path',
                                         'Author Authorovich', 'MegaBot'))
        answer_list.append(player.Player('/usr/lol', 'Author', 'Bot'))
        answer_list.append(player.Player('/usr/lol', 'Author', 'Bot and bot'))
        answer_list.append(player.Player('/usr/lol', 'Author', 'Bot and bot'))
        answer_list.append(player.Player('/usr/lol', 'Author and co', 'Bot'))
        answer_list.append(player.Player('/usr/lol', 'Author and co', 'Bot'))
        answer_list.append(player.Player('/usr/lol', 'Author and co', 'Bot'))
        answer_list.append(player.Player('/usr/lol', 'Author', 'Bot'))
        answer_list.append(player.Player('   ', '   ', 'a'))
        for i in range(9):
            self.assertEqual(answer_list[i].bot_name, gotten_list[i].bot_name)
            self.assertEqual(answer_list[i].author_name,
                             gotten_list[i].author_name)
            self.assertEqual(answer_list[i].command_line,
                             gotten_list[i].command_line)
        self.assertEqual(9, len(gotten_list))
        os.remove('test_for_players_parse')
コード例 #3
0
ファイル: create_video.py プロジェクト: dimatomp/play
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.')