File size: 666 Bytes
3831e97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"""Pricing helpers + arrival interval utility used by spawn pacing."""
from __future__ import annotations
import random

def wholesale(retail: float, factor: float = 0.4) -> int:
    return max(1, int(round(float(retail) * factor)))

def margin(retail: float, factor: float = 0.4) -> int:
    return int(retail) - wholesale(retail, factor)

def arrival_interval(base: float, pace: float = 1.0, jitter: float = 0.15, rng: random.Random | None = None) -> float:
    """Seconds until next arrival; pace multiplies base, jitter is fractional."""
    r = rng or random.Random(0)
    j = 1.0 + r.uniform(-jitter, jitter)
    return max(0.5, float(base) * float(pace) * j)