babylon.data.models
Data models for Babylon.
This package re-exports models from the canonical locations: - Entity models are in babylon.models.entities - Database models (SQLAlchemy) are local
For new code, prefer importing directly from babylon.models.
- class babylon.data.models.Contradiction(**data)[source]
Bases:
BaseModelFull contradiction model with entities and resolution methods.
This is a more detailed model for contradictions that includes references to entities and resolution mechanics. Used for game content definition.
- Parameters:
id (str)
name (str)
description (str)
principal_aspect_id (str | None)
secondary_aspect_id (str | None)
principal_contradiction_id (str | None)
universality (str)
particularity (str)
antagonism (str)
intensity (IntensityLevel)
state (str)
potential_for_transformation (IntensityLevel)
intensity_history (list[Annotated[float, FieldInfo(annotation=NoneType, required=True, description='Contradiction intensity from dormant (0) to rupture (1)', metadata=[Ge(ge=0.0), Le(le=1.0)])]])
- id
Unique identifier
- name
Human-readable name
- description
Detailed explanation
- entity_ids
IDs of entities involved in this contradiction
- universality
Universal or Particular
- particularity
Domain (Economic, Political, etc.)
- principal_contradiction_id
ID of the principal contradiction (if this is secondary)
- principal_aspect_id
ID of the entity representing the principal aspect
- secondary_aspect_id
ID of the entity representing the secondary aspect
- antagonism
Primary or Secondary antagonism
- intensity
Current intensity level
- state
Active, Resolved, or Latent
- potential_for_transformation
How likely to transform
- conditions_for_transformation
What conditions must be met
- resolution_methods
Mapping of method names to Effects
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
intensity:
IntensityLevel
-
potential_for_transformation:
IntensityLevel
- class babylon.data.models.Effect(**data)[source]
Bases:
BaseModelA modification to game state.
Effects are the atoms of change - they modify single attributes on single targets by specific amounts. Every state change in the simulation should be expressible as one or more Effects.
- Parameters:
- target_id
ID of the entity to modify
- attribute
Name of the attribute to change
- operation
How to modify the value
- magnitude
Amount of change (interpretation depends on operation)
- description
Human-readable explanation of why this effect occurs
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class babylon.data.models.Event(**kwargs)[source]
Bases:
BaseRepresents a game event that can occur based on certain conditions.
Events can have effects, triggers, and consequences.
- __init__(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class babylon.data.models.LogEntry(**kwargs)[source]
Bases:
BaseSQLAlchemy model for log entries.
- __init__(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class babylon.data.models.Trigger(**data)[source]
Bases:
BaseModelA condition that can trigger game events.
Triggers define when events should occur based on game state. They can have multiple conditions that must all be met (AND logic) or any one met (OR logic).
- Parameters:
- id
Unique identifier
- description
Human-readable description
- trigger_type
Category of trigger (economic, political, social, etc.)
- conditions
List of conditions to evaluate
- logic
How to combine conditions (all must pass or any must pass)
- parameters
Optional parameters for condition evaluation
- cooldown_turns
Minimum turns between activations (0 = no cooldown)
- last_triggered_turn
Turn when this was last triggered
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
conditions:
list[TriggerCondition]
Modules
Event model for handling game events and their effects. |
|
Log entry model for database logging. |