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
IdeologicalComponent: Political alignment, adherence
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
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.
- 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.
- 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.IdeologicalComponent(**data)[source]
Bases:
BaseModelMulti-dimensional ideological state (George Jackson Model).
Tracks the ideological state of an entity using three axes: - Relationship to Capital (class consciousness) - Relationship to State/Tribe (national identity) - Accumulated political energy (agitation)
The bifurcation mechanism: - When wages fall, agitation accumulates - If solidarity edges exist: agitation routes to class_consciousness - If no solidarity edges: agitation routes to national_identity
All values use constrained floats for automatic validation: - class_consciousness: [0, 1] (0=False Consciousness, 1=Revolutionary) - national_identity: [0, 1] (0=Internationalist, 1=Fascist) - agitation: [0, inf) (no upper bound - accumulates during crises)
This component is immutable (frozen) to ensure state integrity.
- Parameters:
- class_consciousness
Relationship to Capital [0=False, 1=Revolutionary] (default: 0.0)
- national_identity
Relationship to State [0=Internationalist, 1=Fascist] (default: 0.5)
- agitation
Raw political energy from wage crises [0, inf) (default: 0.0)
- property component_type: str
Return the component type identifier.
- Returns:
The string ‘ideological’ 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.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
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. |
|
IdeologicalComponent - Multi-dimensional ideological state (George Jackson Model). |
|
MaterialComponent - Material conditions of an entity. |
|
OrganizationComponent - Organizational capacity of an entity. |
|
SpatialComponent - Location and mobility of an entity. |
|
VitalityComponent - Population and survival needs of an entity. |