babylon.models.components
Component system for the Babylon Entity-Component architecture.
This package contains the foundational component types that define the material ontology of the simulation:
Component: Protocol defining the interface for all components
MaterialComponent: Wealth, resources, means of production
VitalityComponent: Population, subsistence needs
SpatialComponent: Location, mobility
MaterialConditionsBuffer: Value-tensor-derived consciousness inputs
OrganizationComponent: Cohesion, cadre level
All components are immutable (frozen) Pydantic models that use constrained types from babylon.models.types.
- class babylon.models.components.Component(*args, **kwargs)[source]
Bases:
ProtocolProtocol defining the interface for all component types.
All components in the Babylon simulation must implement this protocol. The protocol requires a component_type property that returns a string identifier for the component type.
This protocol is runtime-checkable, meaning you can use isinstance() to verify that an object implements the Component interface.
Example
>>> class MyComponent(BaseModel): ... model_config = ConfigDict(frozen=True) ... @property ... def component_type(self) -> str: ... return "my_component" ... >>> instance = MyComponent() >>> isinstance(instance, Component) True
- __init__(*args, **kwargs)
- class babylon.models.components.MaterialComponent(**data)[source]
Bases:
BaseModelMaterial conditions of an entity.
Tracks the economic and material state of an entity including: - Accumulated wealth (Currency) - Available resources (Currency) - Control over means of production (Probability)
All values use constrained types for automatic validation: - wealth, resources: Currency [0, inf) - means_of_production: Probability [0, 1]
This component is immutable (frozen) to ensure state integrity.
- Parameters:
wealth (Annotated[float, Ge(ge=0.0), AfterValidator(func=~babylon.utils.math.quantize)])
resources (Annotated[float, Ge(ge=0.0), AfterValidator(func=~babylon.utils.math.quantize)])
means_of_production (Annotated[float, Ge(ge=0.0), Le(le=1.0), AfterValidator(func=~babylon.utils.math.quantize)])
- wealth
Accumulated economic resources (default: 10.0)
- resources
Available material resources (default: 0.0)
- means_of_production
Control over productive apparatus [0, 1] (default: 0.0)
- property component_type: str
Return the component type identifier.
- Returns:
The string ‘material’ identifying this component type.
- model_config: ClassVar[ConfigDict] = {'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class babylon.models.components.VitalityComponent(**data)[source]
Bases:
BaseModelPopulation and survival needs of an entity.
Tracks the demographic and subsistence state of an entity: - Population size (Currency) - Minimum resources required for survival (Currency)
All values use constrained types for automatic validation: - population, subsistence_needs: Currency [0, inf)
This component is immutable (frozen) to ensure state integrity.
- Parameters:
population (Annotated[float, Ge(ge=0.0), AfterValidator(func=~babylon.utils.math.quantize)])
subsistence_needs (Annotated[float, Ge(ge=0.0), AfterValidator(func=~babylon.utils.math.quantize)])
- population
Size of the population (default: 1.0)
- subsistence_needs
Resources needed for survival (default: 5.0)
- property component_type: str
Return the component type identifier.
- Returns:
The string ‘vitality’ identifying this component type.
- model_config: ClassVar[ConfigDict] = {'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class babylon.models.components.SpatialComponent(**data)[source]
Bases:
BaseModelLocation and mobility of an entity.
Tracks the spatial state of an entity: - Geographic/topological location identifier (string) - Ability to relocate (Probability)
All numeric values use constrained types for automatic validation: - mobility: Probability [0, 1]
This component is immutable (frozen) to ensure state integrity.
- Parameters:
location_id (str)
mobility (Annotated[float, Ge(ge=0.0), Le(le=1.0), AfterValidator(func=~babylon.utils.math.quantize)])
- location_id
Geographic or topological location identifier (default: “”)
- mobility
Ability to relocate [0=immobile, 1=fully mobile] (default: 0.5)
- property component_type: str
Return the component type identifier.
- Returns:
The string ‘spatial’ identifying this component type.
- model_config: ClassVar[ConfigDict] = {'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class babylon.models.components.MaterialConditionsBuffer(**data)[source]
Bases:
BaseModelMaterial preconditions for consciousness change on a population node.
This model stores the intermediate quantities derived from the value tensor (c/v/s) that feed into the community-level consciousness routing formula. It is NOT consciousness itself — consciousness lives on the community hyperedge as TernaryConsciousness.
- Parameters:
- model_config: ClassVar[ConfigDict] = {'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- agitation: float
- exploitation_visibility: float
- reification_buffer: float
- class babylon.models.components.OrganizationComponent(**data)[source]
Bases:
BaseModelOrganizational capacity of an entity.
Tracks the organizational state of an entity: - Internal unity and coordination (Probability) - Quality of organizational leadership (Probability)
All values use constrained types for automatic validation: - cohesion: Probability [0, 1] - cadre_level: Probability [0, 1]
This component is immutable (frozen) to ensure state integrity.
- Parameters:
cohesion (Annotated[float, Ge(ge=0.0), Le(le=1.0), AfterValidator(func=~babylon.utils.math.quantize)])
cadre_level (Annotated[float, Ge(ge=0.0), Le(le=1.0), AfterValidator(func=~babylon.utils.math.quantize)])
- cohesion
Internal unity and coordination [0=atomized, 1=unified] (default: 0.1)
- cadre_level
Quality of organizational leadership [0=none, 1=elite] (default: 0.0)
- property component_type: str
Return the component type identifier.
- Returns:
The string ‘organization’ identifying this component type.
- model_config: ClassVar[ConfigDict] = {'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Modules
Component protocol definition. |
|
MaterialComponent - Material conditions of an entity. |
|
MaterialConditionsBuffer - Material preconditions for consciousness change. |
|
OrganizationComponent - Organizational capacity of an entity. |
|
SpatialComponent - Location and mobility of an entity. |
|
VitalityComponent - Population and survival needs of an entity. |