Example #1
0
 def test_integration(self):
     main = Main(game_path, 1)
     main._load_players()
     main._run_tournament()
     self.assertTrue(os.path.exists(log_file))
     video_visualizer = VideoVisualizer(24, config.Painter, file_mask,
                                        'logs/tournament1')
     video_visualizer.compile('test_video.mpg')
     self.assertTrue(os.path.exists('logs/tournament1/test_video.mpg'))
Example #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.')
Example #3
0
arg_parser.add_argument(
    'game_controller_filemask',
    help='File mask of GameController files (regular expression)')
args = arg_parser.parse_args()

from visualizer import VideoVisualizer
import config_helpers
config_helpers.initialize_game_environment(args.game_path)
import config

output_name = 'output.mpg'


'''
Run Visualizer
'''
vjs = VideoVisualizer(args.framerate, config.Painter(),
                      args.game_controller_filemask,
                      args.game_controller_directory)
vjs.compile(output_name)

output_name = output_name[:output_name.rfind('.')] + '1.mpg'
output_place = os.path.join(os.path.dirname(__file__),
                            args.game_controller_directory, output_name)

'''
Play results
'''
subprocess.call('ffplay -x 640 -y 480 ' + output_place)
os.remove(output_place)