- Every package passes the open_board_format crate's validator (already an aac-core dev-dependency), so the sets open in any OBF app, not only ours. - solve.py with no options reproduces each committed layout byte for byte; the seed, restarts and iterations are written in the layout's header. Co-Authored-By: Claude Opus 5.5 <[email protected]>
46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Propose the layouts of the open page sets (run by a designer, not by the build).
|
|
|
|
python3 tools/pagesets/solve.py core # -> data/growing-core.layout.yaml
|
|
python3 tools/pagesets/solve.py motor # -> data/fixed-paths.layout.yaml
|
|
|
|
The result is reviewed and committed; build.py reads it and checks every rule
|
|
(it never solves). Run with no options, each reproduces its committed layout
|
|
byte for byte (seed, restarts and iterations are in the layout's header).
|
|
Needs Python 3.11+ and PyYAML.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
|
|
from pslib import layout # noqa: E402
|
|
from pslib.data import HERE, Data # noqa: E402
|
|
|
|
|
|
def main() -> None:
|
|
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
ap.add_argument("which", choices=["core", "motor"])
|
|
ap.add_argument("--seed", type=int, default=20261005)
|
|
ap.add_argument("--restarts", type=int, help="default: 4 for core, 6 for motor (what the committed layouts used)")
|
|
ap.add_argument("--iters", type=int, default=40000)
|
|
args = ap.parse_args()
|
|
if args.restarts is None:
|
|
args.restarts = 4 if args.which == "core" else 6
|
|
data = Data()
|
|
if args.which == "core":
|
|
text = layout.solve_core(data, args.seed, args.restarts, args.iters)
|
|
out = HERE / "data" / "growing-core.layout.yaml"
|
|
else:
|
|
text = layout.solve_motor(data, args.seed, args.restarts, args.iters)
|
|
out = HERE / "data" / "fixed-paths.layout.yaml"
|
|
out.write_text(text, encoding="utf-8")
|
|
print(f"wrote {out.relative_to(HERE)}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|