- game.yaml: `givens` (first or later attempt) and `distinct` levels that are not pooled; the shadow roll
depends on the attempt first. Form submissions show the shadow on 9% of first attempts and 0.3% of later ones.
- Reporting bias: a roll whose bias cannot be measured can borrow another roll's (`borrow: {shadow: meadow}`),
so form submissions inform the shadow again. An assumption, stated in planner/policy.yaml.
- policy.json: targets.<colour>.firstAttempt (this attempt, eventually). Black: about 1.4% on a first attempt,
0.07% on a later one.
- solver.js: advisor options `attempt`, `fix`, sampling "uniform"; assign() and armFor() for the plan.
- planner/experiments.yaml + build_experiments.py -> data/public/experiments.json (progress and status per
experiment, rebuilt from the bot's runs).
- python -m collection cycle: import bot runs, refit, re-plan, deliver the kit; .gitea/workflows/bot-cycle.yml.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014jqCC2LZ4x1WHQ1V57nTsv
62 lines
2.9 KiB
Python
62 lines
2.9 KiB
Python
"""A small synthetic world for testing the route model, and its policy.
|
|
|
|
The meadow shows Blue 30% of the time, the shadow appears 2% of the time, facing the valley Red always bonds it,
|
|
the Greens burn half the time and bond Brown (rescue) a quarter of the time.
|
|
|
|
python tests/fixtures/synthetic_policy.py OUT.json (used by tests/core/advisor.test.js)
|
|
"""
|
|
import json
|
|
import random
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
sys.path.insert(0, str(ROOT / "core"))
|
|
from atlas import solver # noqa: E402
|
|
|
|
|
|
def world(n=4000, seed=7):
|
|
r = random.Random(seed).random
|
|
runs = []
|
|
for i in range(n):
|
|
run = {"company": "Alone", "direction": ["East", "West", "Center"][i % 3], "first_sighting": ["Red", "Brown"][i % 2],
|
|
"scream": "Investigate & help", "resolution": ["Killed the bullies yourself", "Squadmate's revenge"][i % 2],
|
|
"post_path": "Forest", "goal": "Any (for fun)", "malek_intent": "No", "left_squadmates": False,
|
|
"sighting_action": "Unknown", "attempt_group": "Later attempt", "combat_first": "(not recorded)", "combat_second": "(not recorded)", "rare_reported": "No",
|
|
**{f"enc_{c}": None for c in ("Red", "Green", "Orange", "Brown", "Blue", "Black")}}
|
|
run["hour"] = "Tree" if r() < 0.5 else "Valley"
|
|
if run["hour"] == "Tree":
|
|
if r() < 0.02:
|
|
run.update(branch="Shadow (rare)", enc_Black="Bonded!", outcome="Bonded", outcome_color="Black")
|
|
elif r() < 0.5:
|
|
run.update(branch="Descend quickly: Red", enc_Red="Incinerated", outcome="Incinerated", outcome_color="Red")
|
|
else:
|
|
run["branch"] = "Descend slowly: two Greens"
|
|
u = r()
|
|
if u < 0.5:
|
|
run.update(enc_Green="Incinerated", outcome="Incinerated", outcome_color="Green")
|
|
elif u < 0.75:
|
|
run.update(enc_Green="Bonded!", outcome="Bonded", outcome_color="Green")
|
|
else:
|
|
run.update(enc_Green="Saved by another", enc_Brown="Bonded!", outcome="Bonded", outcome_color="Brown")
|
|
elif r() < 0.2:
|
|
run.update(branch="Valley Red", enc_Red="Bonded!", outcome="Bonded", outcome_color="Red")
|
|
else:
|
|
run["branch"] = "Passed the Red: meadow"
|
|
u = r()
|
|
c = "Blue" if u < 0.3 else "Orange" if u < 0.65 else "Brown"
|
|
bond = r() < 0.5
|
|
run.update({"enc_" + c: "Bonded!" if bond else "Incinerated", "outcome": "Bonded" if bond else "Incinerated", "outcome_color": c})
|
|
runs.append(run)
|
|
return runs
|
|
|
|
|
|
def policy(draws=10, colours=("Blue", "Black", "Red", "Brown")):
|
|
return solver.build_policy(world(), draws=draws, colours=list(colours))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.path.insert(0, str(ROOT / "planner"))
|
|
from build_policy import clean
|
|
Path(sys.argv[1]).write_text(json.dumps(clean(policy())))
|