Crate subtr_actor
source ·Expand description
subtr-actor
subtr-actor is a versatile library designed to facilitate the process of
working with and extracting data from Rocket League replays. Utilizing the
powerful boxcars library for parsing, subtr-actor simplifies the
underlying complex 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. TheReplayProcessortraverses the actor graph, pushing frames through anActorStateModelerto capture the state of all actors at any given moment. It provides a suite of helper methods to assist in the navigation of the actor graph and the retrieval of information about the game as it progresses. -
Collector: This trait outlines the blueprint for data collection from replays. The Collector interfaces with a ReplayProcessor, handling frame data and guiding the pace of replay progression. It is typically invoked repeatedly through theReplayProcessor::processmethod as the replay is processed frame by frame.
Notably, subtr-actor 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). This representation is ideal for use with machine learning libraries like pytorch and tensorflow. -
ReplayData: 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. raw boxcars in that it is not a complicated graph of actor objects and is instead something more akin to the way a human might think of the data contained in a replay.
Modules
Macros
- This macro creates a global
FeatureAdderstruct and implements the necessary traits to add the calculated features to the data matrix. The macro exports a struct with the same name as passed in the parameter. The number of column names and the length of the feature array returned by$prop_getterare checked at compile time to ensure they match, in line with theLengthCheckedFeatureAddertrait. The output struct also provides an implementation of theFeatureAddertrait via theimpl_feature_adder!macro, allowing it to be used in contexts where aFeatureAdderobject is required. - This macro creates a player feature adder struct and implements the necessary traits to add the calculated player-specific features to the data matrix. The macro exports a struct with the same name as passed in the parameter. The number of column names and the length of the feature array returned by
$prop_getterare checked at compile time to ensure they match, in line with theLengthCheckedPlayerFeatureAddertrait. The output struct also provides an implementation of thePlayerFeatureAddertrait via theimpl_player_feature_adder!macro, allowing it to be used in contexts where aPlayerFeatureAdderobject is required. - A macro that tries to convert each provided item into a type. If any of the conversions fail, it short-circuits and returns the error.
- A convenience macro that uses the
convert_allmacro with theconvert_float_conversion_errorfunction for error handling. - This macro is used to implement necessary traits for an existing struct to add the calculated features to the data matrix. This macro is particularly useful when the feature adder needs to be instantiated with specific parameters. The number of column names and the length of the feature array returned by
$prop_getterare checked at compile time to ensure they match. - A macro to provide an automatic implementation of the
FeatureAddertrait for types that implementLengthCheckedFeatureAdder. This allows you to take advantage of the compile-time guarantees provided byLengthCheckedFeatureAdder, while still being able to use your type in contexts that require aFeatureAdderobject. This macro is used to bridge the gap between the two traits, as Rust’s type system does not currently provide a way to prove to the compiler that there will always be exactly one implementation ofLengthCheckedFeatureAdderfor each type. - A macro to provide an automatic implementation of the
PlayerFeatureAddertrait for types that implementLengthCheckedPlayerFeatureAdder. This allows you to take advantage of the compile-time guarantees provided byLengthCheckedPlayerFeatureAdder, while still being able to use your type in contexts that require aPlayerFeatureAdderobject. This macro is used to bridge the gap between the two traits, as Rust’s type system does not currently provide a way to prove to the compiler that there will always be exactly one implementation ofLengthCheckedPlayerFeatureAdderfor each type. - This macro is used to implement necessary traits for an existing struct to add the calculated player-specific features to the data matrix. This macro is particularly useful when the feature adder needs to be instantiated with specific parameters. The number of column names and the length of the feature array returned by
$prop_getterare checked at compile time to ensure they match.
Structs
- A struct representing the state of an actor.
- A struct modeling the states of multiple actors at a given point in time. Provides methods to update that state with successive frames from a boxcars::Replay.
DemolishInfostruct represents data related to a demolition event in the game.NDArrayCollectoris aCollectorwhich transforms frame-based replay data into a 2-dimensional array of typendarray::Array2, where each element is of a specified floating point type.- Represents the column headers in the collected data of an
NDArrayCollector. PlayerInfostruct provides detailed information about a specific player in the replay.ReplayMetastruct represents metadata about the replay being processed.- A struct that contains both the metadata of a replay and the associated column headers.
- The
ReplayProcessorstruct is a pivotal component insubtr-actor’s replay parsing pipeline. It is designed to process and traverse an actor graph of a Rocket League replay, and expose methods for collectors to gather specific data points as it progresses through the replay. SubtrActorErrorstruct provides an error variantSubtrActorErrorVariantalong with its backtrace.
Enums
- Enum to define the direction of searching within a collection.
SubtrActorErrorVariantis an enumeration of all the specific error variants that can occur while processing game replays in the subtr-actor domain. These include errors related to network frames, frame indexing, player sets, actor states, object ids, team identities, and data types amongst others.- Enum used to control the progress of time during replay processing.
Statics
Traits
- Trait for types that collect data from a replay.
- This trait acts as an abstraction over a feature adder, and is primarily used to allow for heterogeneous collections of feature adders in the
NDArrayCollector. While it provides methods for adding features and retrieving column headers, it is generally recommended to implement theLengthCheckedFeatureAddertrait instead, which provides compile-time guarantees about the number of features returned. - This trait is stricter version of the
FeatureAddertrait, enforcing at compile time that the number of features added is equal to the number of column headers provided. Implementations of this trait can be automatically adapted to theFeatureAddertrait using theimpl_feature_adder!macro. - This trait is a more strict version of the
PlayerFeatureAddertrait, enforcing at compile time that the number of player-specific features added is equal to the number of column headers provided. Implementations of this trait can be automatically adapted to thePlayerFeatureAddertrait using theimpl_player_feature_adder!macro. - This trait acts as an abstraction over a player-specific feature adder, and is primarily used to allow for heterogeneous collections of player feature adders in the
NDArrayCollector. While it provides methods for adding player-specific features and retrieving column headers, it is generally recommended to implement theLengthCheckedPlayerFeatureAddertrait instead, which provides compile-time guarantees about the number of features returned.
Functions
- Searches for an item in a slice in a specified direction and returns the first item that matches the provided predicate.
- Interpolates between two
boxcars::RigidBodystates based on the provided time. - Extracts the location, rotation, linear velocity and angular velocity from a
boxcars::RigidBodyand converts them to a type implementingTryFrom<f32>. - Extracts the location and rotation from a
boxcars::RigidBodyand converts them to a type implementingTryFrom<f32>.