run_playtest.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""试玩运行脚本 - 运行自动试玩并生成报告"""
import sys
import os
# 修复 Windows 终端编码(UTF-8 输出)
if sys.platform == 'win32':
try:
sys.stdout.reconfigure(encoding='utf-8')
sys.stderr.reconfigure(encoding='utf-8')
except Exception:
pass
sys.path.insert(0, 'D:/1979')
from src.playtest import AutoPlaytest
def main():
"""运行试玩"""
num_runs = 20 # 默认20次运行
if len(sys.argv) > 1:
num_runs = int(sys.argv[1])
tester = AutoPlaytest()
report = tester.run_full_playtest(num_runs)
print(report)
# 保存报告
with open('playtest_report.txt', 'w', encoding='utf-8') as f:
f.write(report)
print("\n报告已保存到 playtest_report.txt")
if __name__ == '__main__':
main()