role#
Role (Component) base class definition.
This module defines the Role base class, the fundamental building block of the BAM-ECS architecture. Roles are dataclasses containing NumPy arrays that represent specific aspects of agent behavior.
Design Notes#
All Roles auto-register via __init_subclass__ hook
Each Role has a name (ClassVar) set automatically
Roles should be immutable containers; use system functions for mutations
NumPy array fields enable vectorized operations across all agents
Auto-Registration#
When a class inherits from Role, __init_subclass__ automatically:
Sets the role name (cls.name) to class name if not provided
Registers the role class in the global _ROLE_REGISTRY
Makes the role retrievable via get_role(name)
This eliminates manual registration boilerplate and ensures all roles are discoverable at runtime.
Classes#
Base class for all roles (components) in the BAM-ECS architecture. |