GameAgent Plugin

The GameAgent plugin extends the base GameAgent class with game-specific functionality.

Plugin Package Structure

A GameAgent plugin package contains:

  • Plugin definition file

  • GameAgent subclass

  • Helper modules

  • Machine learning models

Creating a GameAgent Subclass

Required Components

  • One or more frame handler functions

  • Frame handler setup functions (optional)

  • Frame handler registrations in constructor

  • Frame handler setup registrations in constructor

  • Optional AnalyticsClient instance

You can implement additional custom instance methods. Consider using helper modules if the file becomes too large.

Registering Components

Frame Handler Registration

class MyGameAgent(GameAgent):
    def __init__(self, **kwargs):
        super().init(**kwargs)

        self.frame_handlers["MY_FRAME_HANDLER"] = self.my_frame_handler

    def my_frame_handler(self, game_frame):
        pass

Frame Handler Setup Registration

class MyGameAgent(GameAgent):
    def __init__(self, **kwargs):
        super().init(**kwargs)

        self.frame_handler_setups["MY_FRAME_HANDLER"] = self.my_frame_handler_setup

    def my_frame_handler_setup(self):
        pass

Helper Modules

  1. Create files in files/helpers

  2. Add desired functions and classes

  3. Import in GameAgent subclass using relative imports

Machine Learning Models

Adding Models

  1. Copy models to files/ml_models

  2. Use .model extension (recommended for Git LFS support)

Loading Models

Load in constructor for all frame handlers:

class MyGameAgent(GameAgent):
    def __init__(self, **kwargs):
        super().init(**kwargs)

        self.machine_learning_models["MY_MODEL"] = self.load_machine_learning_model(
            os.path.join(os.path.dirname(__file__), "ml_models/my_model.model")
        )

Last updated