Skip to content

Analysing a Replay

DivvyCr edited this page Apr 27, 2020 · 2 revisions

Overview

Once the replay was converted into JSON, and an instance of Game was created, the replay can be analysed. AnalysisManager is the class responsible for preparing and performing the analysis, and it requires the Game object as a parameter. Before doing any analysis, it fills in relevant data into the Protobuffer and the DataFrame. Then, it performs full analysis on all of the replay data.

To prepare and perform the analysis, call the create_analysis() method.

Working with the Analysis

The analysis only parses all of the replay data into easy-to-use data structures - it does not calculate any stats or events. Those calculations belong to their respective classes in the analysis section of carball (carball > analysis).

After running the analysis once, all of the data can be retrieved by using the write_X_to_file methods, where X is the wanted data structure (json/pandas.DataFrame/proto). After writing the data to the respective files, you may reuse those with the data Manager classes (carball > analysis > utils), and the JSON file can be reused to directly initialize the game object. See sections below for instructions.

ProtobufManager

Create the class and call the read_proto_out_from_file(file) method, make sure that the file (or buffer) is in "Read Bytes" mode. The method returns an instance of game_pb2.Game.

PandasManager

Create the class and call the read_numpy_from_memory(buffer) method (buffer = file), make sure that the file (or buffer) is in "Read Bytes" mode. The method returns an instance of pandas.DataFrame.

Detailed Docs

The AnalysisManager class is very well documented within the code. By convention, all methods beginning with an underscore are 'private' - you shouldn't call them for any of your general replay analyses.