예제 #1
0
def analyze_replay_file(replay_path: str,
                        output_path: str,
                        overwrite=True,
                        controls: ControlsCreator = None,
                        sanity_check: SanityChecker = None):
    """
    Decompile and analyze a replay file.

    :param replay_path: Path to replay file
    :param output_path: Path to write JSON
    :param overwrite: If to overwrite JSON (suggest True if speed is not an issue)
    :param controls: Generate controls from the replay using our best guesses (ALPHA)
    :param sanity_check: Run sanity check to make sure we analyzed correctly (BETA)
    :return: AnalysisManager of game with analysis.
    """
    _json = decompile_replay(replay_path, output_path, overwrite=overwrite)
    game = Game(loaded_json=_json)
    # get_controls(game)  # TODO: enable and optimise.
    if controls is not None:
        controls.get_controls(game)
    if sanity_check is not None:
        sanity_check.check_game(game)
    analysis = AnalysisManager(game)
    analysis.create_analysis()

    return analysis
예제 #2
0
def analyze_replay_file(replay_path: str, output_path: str = None, overwrite=True, controls: ControlsCreator = None,
                        sanity_check: SanityChecker = None, analysis_per_goal=False, rattletrap_path: str = None):
    """
    Decompile and analyze a replay file.

    :param replay_path: Path to replay file
    :param output_path: Path to write JSON
    :param overwrite: If to overwrite JSON (suggest True if speed is not an issue)
    :param controls: Generate controls from the replay using our best guesses (ALPHA)
    :param sanity_check: Run sanity check to make sure we analyzed correctly (BETA)
    :param analysis_per_goal: Runs the analysis per a goal instead of the replay as a whole
    :param rattletrap_path: Custom location for rattletrap executable. Path to folder.
    :param force_full_analysis: If True full analysis will be performed even if checks say it should not.
    :return: AnalysisManager of game with analysis.
    """
    _json = decompile_replay(replay_path, output_path=output_path, overwrite=overwrite, rattletrap_path=rattletrap_path)
    game = Game()
    game.initialize(loaded_json=_json)
    # get_controls(game)  # TODO: enable and optimise.
    if sanity_check is not None:
        sanity_check.check_game(game)
    if analysis_per_goal:
        analysis = PerGoalAnalysis(game)
    else:
        analysis = AnalysisManager(game)
    analysis.create_analysis()

    if controls is not None:
        controls.get_controls(game)

    return analysis
예제 #3
0
def analyze_replay_file(replay_path: str,
                        output_path: str = None,
                        overwrite=True,
                        controls: ControlsCreator = None,
                        sanity_check: SanityChecker = None,
                        analysis_per_goal=False,
                        rattletrap_path: str = None,
                        logging_level=logging.NOTSET,
                        calculate_intensive_events: bool = False):
    """
    Decompile and analyze a replay file.

    :param replay_path: Path to replay file
    :param output_path: Path to write JSON
    :param overwrite: If to overwrite JSON (suggest True if speed is not an issue)
    :param controls: Generate controls from the replay using our best guesses (ALPHA)
    :param sanity_check: Run sanity check to make sure we analyzed correctly (BETA)
    :param analysis_per_goal: Runs the analysis per a goal instead of the replay as a whole
    :param rattletrap_path: Custom location for rattletrap executable. Path to folder.
    :param force_full_analysis: If True full analysis will be performed even if checks say it should not.
    :param logging_level: Sets the logging level globally across carball
    :param calculate_intensive_events: Indicates if expensive calculations should run to include additional stats.
    :return: AnalysisManager of game with analysis.
    """

    if logging_level != logging.NOTSET:
        logging.getLogger('carball').setLevel(logging_level)

    _json = decompile_replay(replay_path,
                             output_path=output_path,
                             overwrite=overwrite,
                             rattletrap_path=rattletrap_path)
    game = Game()
    game.initialize(loaded_json=_json)
    # get_controls(game)  # TODO: enable and optimise.
    if sanity_check is not None:
        sanity_check.check_game(game)
    if analysis_per_goal:
        analysis = PerGoalAnalysis(game)
    else:
        analysis = AnalysisManager(game)
    analysis.create_analysis(
        calculate_intensive_events=calculate_intensive_events)

    if controls is not None:
        controls.get_controls(game)

    return analysis