Brier-scored probability

Continuous reward 1 − (p − outcome)². A proper scoring rule: honest probabilities maximize expected reward.

brier_forecast.pyverify_environment
def verify_environment(completion: str, metadata: dict | None = None) -> float:
    """metadata["label"] is the resolved outcome in [0, 1]. Reads the last 'p: 0.xx' line."""
    import re

    label = (metadata or {}).get("label")
    if label is None:
        return 0.0
    found = re.findall(r"^\s*p\s*[:=]\s*([01](?:\.\d+)?|\.\d+)\s*$", completion, flags=re.M | re.I)
    if not found:
        return 0.0
    p = float(found[-1])
    if not 0.0 <= p <= 1.0:
        return 0.0
    return round(1.0 - (p - float(label)) ** 2, 6)
Brier-scored probability reward function (Python) — Reinforcement.tech