subtr-actor
subtr-actor
subtr-actor is a versatile library designed to facilitate the
processes of working with and extracting data from Rocket League replays.
Utilizing the powerful boxcars library for parsing, subtr-actor
simplifies (or 'subtracts', as hinted by its name) the underlying
actor-based structure of replay files, making them more accessible and
easier to manipulate.
Overview of Key Components
-
ReplayProcessor: This struct is at the heart of subtr-actor's replay processing capabilities. In its main entry point,ReplayProcessor::process, it pushes network frames from theboxcars::Replaythat it is initialized with though anActorStateModelerinstance, calling theCollectorinstance that is provided as an argument as it does so. TheCollectoris provided with a reference to theReplayProcessoreach time the it is invoked, which allows it to use the suite of helper methods which greatly assist in the navigation of the actor graph and the retrieval of information about the current game state. -
Collector: This trait outlines the blueprint for data collection from replays. TheCollectorinterfaces with aReplayProcessor, handling frame data and guiding the pace of replay progression withTimeAdvance. It is typically invoked repeatedly through theReplayProcessor::processmethod as the replay is processed frame by frame. -
FrameRateDecorator: This struct decorates aCollectorimplementation with a target frame duration, controlling the frame rate of the replay processing.
Collector implementations
subtr-actor also includes implementations of the Collector trait:
-
NDArrayCollector: ThisCollectorimplementations translates frame-based replay data into a 2 dimensional array in the form of a::ndarray::Array2instance. The exact data that is recorded in each frame can be configured with theFeatureAdderandPlayerFeatureAdderinstances that are provided to its constructor (NDArrayCollector::new). Extending the exact behavior ofNDArrayCollectoris thus possible with user definedFeatureAdderandPlayerFeatureAdder, which is made easy with thebuild_global_feature_adder!andbuild_player_feature_adder!macros. The::ndarray::Array2produced byNDArrayCollectoris ideal for use with machine learning libraries like pytorch and tensorflow. -
ReplayDataCollector: ThisCollectorimplementation provides an easy way to get a serializable to e.g. json (thoughserde::Serialize) representation of the replay. The representation differs from what you might get from e.g. rawboxcarsin that it is not a complicated graph of actor objects, but instead something more natural where the data associated with each entity in the game is grouped together.
Examples
Getting JSON
Getting a ::ndarray::Array2
In the following example, we demonstrate how to use boxcars,
NDArrayCollector and FrameRateDecorator to write a function that
takes a replay filepath and collections of features adders and returns a
ReplayMetaWithHeaders along with a ::ndarray::Array2 . The resulting
::ndarray::Array2 would be appropriate for use in a machine learning
context. Note that ReplayProcessor is also used implicitly here in the
Collector::process_replay
use *;
Using NDArrayCollector::from_strings
In the second function we see the use of feature adders like
InterpolatedPlayerRigidBodyNoVelocities. The feature adders that are
included with subtr_actor can all be found in the
crate::collector::ndarray module. It is also possible to access these
feature adders by name with strings, which can be useful when implementing
bindings for other languages since those languages may not be able to access
rust structs an instantiate them easily or at all.
pub static DEFAULT_GLOBAL_FEATURE_ADDERS: = ;
pub static DEFAULT_PLAYER_FEATURE_ADDERS: =
;