34 lines
841 B
Python
34 lines
841 B
Python
|
|
"""Launch a Chessistics build with the automation harness enabled and drop
|
||
|
|
into an interactive Python REPL.
|
||
|
|
|
||
|
|
python tools/automation/run_game.py
|
||
|
|
|
||
|
|
Then at the prompt: `h.load_mission()`, `h.state()`, `h.screenshot("foo")`...
|
||
|
|
"""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import code
|
||
|
|
import sys
|
||
|
|
|
||
|
|
from harness import Harness
|
||
|
|
|
||
|
|
|
||
|
|
def main() -> None:
|
||
|
|
h = Harness.launch(run_name="repl")
|
||
|
|
try:
|
||
|
|
print(f"\nHarness launched. Working directory: {h.root}")
|
||
|
|
print("Ready-to-use object: `h` (see harness.py for the full API)\n")
|
||
|
|
banner = "Chessistics automation REPL — type h.<tab> for commands. Ctrl-D to quit."
|
||
|
|
local = {"h": h}
|
||
|
|
code.interact(banner=banner, local=local)
|
||
|
|
finally:
|
||
|
|
h.close()
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
try:
|
||
|
|
main()
|
||
|
|
except KeyboardInterrupt:
|
||
|
|
sys.exit(130)
|