#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """Seeded faults for milestone 5's controller judges, then ``controller_run.py``. The first argument names the fault; the rest are ``controller_run.py``'s: - ``two-button-always``: the ProLine reads as two-button whatever the RIOT holds (One-on-One must then stay on its option menu, Worm! never start: the wiki's failure symptoms); - ``gun-blind``: the light gun's sensor never sees light (Crossbow's aimed shot must then score nothing). python scripts/controller_faults.py two-button-always ".../Worm! (World) (Aftermarket) (Unl).zip" \\ --no-gun --frames 1000 --script 400:b1 406:none --png-at 450 --out tests/detector_runs/worm-fault """ from __future__ import annotations import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT / "src")) sys.path.insert(0, str(ROOT / "scripts")) from a7800_python import controllers # noqa: E402 FAULTS = { "two-button-always": lambda: setattr( controllers.ProLine, "two_button", lambda self, port: True ), "gun-blind": lambda: setattr(controllers.LightGun, "sees_light", lambda self: False), } def main() -> int: if len(sys.argv) < 2 or sys.argv[1] not in FAULTS: raise SystemExit(f"first argument: one of {sorted(FAULTS)}") FAULTS[sys.argv.pop(1)]() import controller_run return controller_run.main() if __name__ == "__main__": sys.exit(main())