babylon.formulas.community
Community layer formulas (Feature 022).
Solidarity potential, threat score, infrastructure decay, and solidarity amplification formulas for the hypergraph community system.
See also
babylon.engine.systems.community: CommunitySystem consuming these formulas.
babylon.models.entities.community: Data models for community state.
Functions
|
Compute new infrastructure after one tick of decay. |
Amplify solidarity_strength based on shared community infrastructure. |
|
|
Compute solidarity potential between two agents from community overlap. |
|
Compute per-agent threat score from community memberships. |
|
Compute compound reproduction cost modifier from community memberships. |
- babylon.formulas.community.calculate_solidarity_potential(base_solidarity, shared_count, rent_a, rent_b, overlap_bonus=0.1, rent_penalty=0.05)[source]
Compute solidarity potential between two agents from community overlap.
Shared community membership creates conditions for solidarity formation, penalized by imperial rent differential (material divergence impedes solidarity even with shared identity).
- Parameters:
base_solidarity (
float) – Base class solidarity between the two agents.shared_count (
int) – Number of communities both agents share.rent_a (
float) – Imperial rent received by agent A.rent_b (
float) – Imperial rent received by agent B.overlap_bonus (
float) – Bonus per shared community membership.rent_penalty (
float) – Penalty per unit of rent differential.
- Return type:
- Returns:
Solidarity potential score (may be negative if rent gap dominates).
Examples
>>> calculate_solidarity_potential(0.3, 2, 0.0, 0.0) 0.5 >>> calculate_solidarity_potential(0.3, 0, 0.0, 0.0) 0.3
- babylon.formulas.community.calculate_threat_score(memberships)[source]
Compute per-agent threat score from community memberships.
Each membership contributes: heat * effective_visibility * role_weight * legal_status_multiplier. The total is the sum across all memberships.
- Parameters:
memberships (
list[tuple[float,float,float,float]]) – List of (heat, effective_visibility, role_weight, legal_status_multiplier) tuples, one per community membership.- Return type:
- Returns:
Cumulative threat score for the agent.
Examples
>>> calculate_threat_score([(0.4, 0.8, 1.0, 1.0)]) 0.32
- babylon.formulas.community.calculate_infrastructure_decay(current, decay_alpha, core_organizer_count, maintenance_factor=0.1)[source]
Compute new infrastructure after one tick of decay.
Infrastructure decays toward zero without maintenance. CORE_ORGANIZER members counteract decay proportionally.
Formula: new = current * (1 - alpha) + maintenance * alpha where maintenance = min(core_organizer_count * maintenance_factor, 1.0)
- Parameters:
- Return type:
- Returns:
New infrastructure level after decay and maintenance, clamped to [0, 1].
Examples
>>> round(calculate_infrastructure_decay(0.5, 0.04, 0), 4) 0.48 >>> round(calculate_infrastructure_decay(0.5, 0.04, 2, 0.1), 4) 0.488
- babylon.formulas.community.calculate_solidarity_amplification(base_strength, shared_communities)[source]
Amplify solidarity_strength based on shared community infrastructure.
For each shared community, the amplification is scaled by the community’s infrastructure, cohesion, and both agents’ membership strengths.
Formula: amplified = base * (1 + sum(infra * cohesion * str_a * str_b))
- Parameters:
- Return type:
- Returns:
Amplified solidarity strength.
Examples
>>> calculate_solidarity_amplification(0.5, []) 0.5 >>> calculate_solidarity_amplification(0.5, [(0.8, 0.6, 0.7, 0.4)]) 0.567
- babylon.formulas.community.compute_community_cost_modifier(memberships, community_states)[source]
Compute compound reproduction cost modifier from community memberships.
The modifier is the product of reproduction_cost_modifier across all communities the agent belongs to. No memberships → 1.0 (no effect).
- Parameters:
- Return type:
- Returns:
Multiplicative compound modifier (product of all community modifiers).
Examples
>>> compute_community_cost_modifier([], {}) 1.0