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. The ReplayProcessor traverses the actor graph, pushing frames through an ActorStateModeler to 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 the ReplayProcessor::process method as the replay is processed frame by frame.

Notably, subtr-actor includes implementations of the Collector trait,

  • NDArrayCollector: This Collector implementations translates frame-based replay data into a 2 dimensional array in the form of a ::ndarray::Array2 instance. The exact data that is recorded in each frame can be configured with the FeatureAdder and PlayerFeatureAdder instances that are provided to its constructor (NDArrayCollector::new). This representation is ideal for use with machine learning libraries like pytorch and tensorflow.

  • ReplayData: This Collector implementation provides an easy way to get a serializable to e.g. json (though serde::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 FeatureAdder struct 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_getter are checked at compile time to ensure they match, in line with the LengthCheckedFeatureAdder trait. The output struct also provides an implementation of the FeatureAdder trait via the impl_feature_adder! macro, allowing it to be used in contexts where a FeatureAdder object 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_getter are checked at compile time to ensure they match, in line with the LengthCheckedPlayerFeatureAdder trait. The output struct also provides an implementation of the PlayerFeatureAdder trait via the impl_player_feature_adder! macro, allowing it to be used in contexts where a PlayerFeatureAdder object 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_all macro with the convert_float_conversion_error function 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_getter are checked at compile time to ensure they match.
  • A macro to provide an automatic implementation of the FeatureAdder trait for types that implement LengthCheckedFeatureAdder. This allows you to take advantage of the compile-time guarantees provided by LengthCheckedFeatureAdder, while still being able to use your type in contexts that require a FeatureAdder object. 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 of LengthCheckedFeatureAdder for each type.
  • A macro to provide an automatic implementation of the PlayerFeatureAdder trait for types that implement LengthCheckedPlayerFeatureAdder. This allows you to take advantage of the compile-time guarantees provided by LengthCheckedPlayerFeatureAdder, while still being able to use your type in contexts that require a PlayerFeatureAdder object. 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 of LengthCheckedPlayerFeatureAdder for 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_getter are checked at compile time to ensure they match.

Structs

Enums

  • Enum to define the direction of searching within a collection.
  • SubtrActorErrorVariant is 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 the LengthCheckedFeatureAdder trait instead, which provides compile-time guarantees about the number of features returned.
  • This trait is stricter version of the FeatureAdder trait, 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 the FeatureAdder trait using the impl_feature_adder! macro.
  • This trait is a more strict version of the PlayerFeatureAdder trait, 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 the PlayerFeatureAdder trait using the impl_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 the LengthCheckedPlayerFeatureAdder trait instead, which provides compile-time guarantees about the number of features returned.

Functions

Type Definitions