Spaces:
Sleeping
Sleeping
File size: 2,282 Bytes
57e0211 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | #!/usr/bin/env python3
"""Interactive text CLI for human play-testing."""
import argparse
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from turnabout.envs.text_env import TextCourtEnv
def main():
parser = argparse.ArgumentParser(description="Play a Turnabout case interactively")
parser.add_argument(
"case",
nargs="?",
default=str(Path(__file__).parent.parent / "turnabout" / "cases" / "stolen_prototype.json"),
help="Path to case JSON file",
)
parser.add_argument(
"-d", "--difficulty",
choices=["easy", "hard"],
default=None,
help="Override case difficulty",
)
args = parser.parse_args()
env = TextCourtEnv(case_path=args.case, difficulty=args.difficulty)
print("=" * 60)
print(" TURNABOUT - Interactive Court Game")
print("=" * 60)
print()
print(env.system_prompt)
print()
print("Type 'quit' to exit, 'help' for commands, 'status' for evidence.")
print("=" * 60)
print()
obs = env.reset()
print(obs)
while True:
print()
try:
action = input(">> ").strip()
except (EOFError, KeyboardInterrupt):
print("\nGoodbye!")
break
if not action:
continue
if action.lower() == "quit":
print("Goodbye!")
break
if action.lower() == "help":
print(env.system_prompt)
continue
if action.lower() == "status":
print(env.render())
continue
obs, reward, done, info = env.step(action)
print(obs)
if reward != 0:
print(f" [Reward: {reward:+.2f}]")
if done:
print()
print("=" * 60)
metrics = env.get_metrics()
print(f" Result: {'WON' if metrics.won else 'LOST'}")
print(f" Steps: {metrics.total_steps}")
print(f" Contradiction Accuracy: {metrics.contradiction_accuracy:.1%}")
print(f" Evidence Coverage: {metrics.evidence_coverage:.1%}")
print(f" Composite Score: {metrics.composite_score:.3f}")
print("=" * 60)
break
if __name__ == "__main__":
main()
|