File size: 1,016 Bytes
3831e97 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | """Spawn budget and regular attempt probabilities (R3)."""
from __future__ import annotations
from typing import Dict, Mapping
DEFAULT_BUDGET = {
"PREP": 0.0,
"MORNING": 2.5,
"AFTERNOON": 3.5,
"DUSK": 2.5,
"CLOSING": 0.5,
"NIGHT": 0.0,
}
DEFAULT_P_REGULAR = {
"MORNING": 0.15,
"AFTERNOON": 0.30,
"DUSK": 0.50,
"CLOSING": 0.10,
}
def spawn_budget(phase: str, table: Mapping[str, float] | None = None) -> float:
t = table or DEFAULT_BUDGET
return float(t.get(phase, 0.0) or 0.0)
def p_regular_attempt(phase: str, table: Mapping[str, float] | None = None) -> float:
t = table or DEFAULT_P_REGULAR
return float(t.get(phase, 0.0) or 0.0)
def arrival_interval(phase_limit: float, budget: float, jitter: float, rng) -> float:
"""Mean spacing with ±jitter factor already applied externally."""
if budget <= 0 or phase_limit <= 0:
return phase_limit
base = phase_limit / max(budget, 0.01)
return base * float(jitter)
# reseal-product R53
|