git » alan.git » commit e063257

Increase generation attempts and honor parameter overrides

author Alan Dipert
2025-12-04 04:06:43 UTC
committer Alan Dipert
2025-12-04 04:06:43 UTC
parent 51701ce03c3be8d5d40da2427a238b771601d075

Increase generation attempts and honor parameter overrides

main.py +17 -7

diff --git a/main.py b/main.py
index 87839f9..c9009e5 100644
--- a/main.py
+++ b/main.py
@@ -31,18 +31,28 @@ def main() -> None:
     actual_seed = args.seed if args.seed is not None else random.randint(0, 1_000_000)
     concepts = get_default_concepts()
     blueprint = get_default_blueprint()
-
-    for attempt in range(10):
+    max_attempts = 50
+
+    params = {
+        "min_irregular": args.min_irregular,
+        "min_irregular_contrast": args.min_irregular_contrast,
+        "min_irregular_distractor": max(3, args.min_irregular_contrast),
+        "min_ditransitive": args.min_ditransitive,
+        "min_plural": args.min_plural,
+        "min_adjective": args.min_adjective,
+        "min_fem_plural": args.min_fem_plural,
+    }
+
+    for attempt in range(max_attempts):
         rng = random.Random(actual_seed + attempt)
         spec = generate_language_instance(actual_seed + attempt)
-        test_dict = generate_test(spec, blueprint, concepts, rng, seed=actual_seed + attempt)
-        if validate_data(test_dict, spec):
+        test_dict = generate_test(spec, blueprint, concepts, rng, seed=actual_seed + attempt, params=params)
+        if validate_data(test_dict, spec, overrides=params):
             with open(args.out_path, "w", encoding="utf-8") as f:
                 json.dump(test_dict, f, indent=2)
             print(f"Generated test JSON at {args.out_path} (seed {actual_seed + attempt})")
-            break
-    else:
-        raise SystemExit("Property tests failed after retries; test not written.")
+            return
+    raise SystemExit(f"Property tests failed after {max_attempts} attempts; test not written.")
 
 
 if __name__ == "__main__":