AgentSquares / make_scenarios.py
DHDRL's picture
Upload 107 files
6cb442b verified
Raw History Blame Contribute Delete
1.02 kB
"""Synthetic scenarios are frozen under scenarios/s*.json (opaque synth:* tool keys; no live URLs).
Helpers below are shared with unit tests (packing samples).
"""
import glob, json, math
def grid(k, side=None):
sq = [{"x": f"{2*i+1}/2", "y": f"{2*j+1}/2", "c": 1, "s": 0} for i in range(k) for j in range(k)]
return {"n": k * k, "side": str(side or k), "squares": sq}
def five(S):
p = [(0.5, 0.5), (S - .5, .5), (.5, S - .5), (S - .5, S - .5)]
sq = [{"x": x, "y": y, "theta_rad": 0.0} for x, y in p] + [{"x": S / 2, "y": S / 2, "theta_rad": math.pi / 4}]
return {"n": 5, "side": S, "squares": sq}
def block(p):
return "```packing\n" + json.dumps(p) + "\n```"
S5 = 2.70710678118654
def load():
return [json.load(open(p)) for p in sorted(glob.glob("scenarios/s*.json"))]
if __name__ == "__main__":
S = load()
print(f"{len(S)} synthetic scenarios on disk")
for sc in S:
print(sc["id"], "held_out=" + str(sc.get("held_out")), "n=" + str(sc["prompt"].get("n")))