基于大语言模型的游戏AI控制器,可以分析游戏截图并自动生成操作指令。
pip install -r requirements.txt
config.ini,填入你的OpenAI API密钥:[api]
api_key = your_api_key_here
python run.py
程序启动后会显示倒计时,倒计时结束后进入等待状态:
在 config.ini 中设置倒计时秒数:
[control]
countdown_seconds = 5 # 启动倒计时(秒)
在 config.ini 中选择驱动类型:
Python驱动(默认):
[driver]
type = python
C驱动(高性能):
[driver]
type = c
dll_path = virtual_driver.dll
press w # 按下并释放w键 hold shift # 按住shift键 release shift # 释放shift键
mouse 100 200 # 移动鼠标到(100,200) click left # 左键点击 click right # 右键点击 click middle # 中键点击
config.ini 配置项:
[api]
api_key = your_api_key_here # OpenAI API密钥
api_base = https://api.openai.com/v1 # API基础URL
model = gpt-4-vision-preview # 使用的模型
max_tokens = 500 # 最大生成token数
temperature = 0.7 # 温度参数
[driver]
type = python # 驱动类型: python 或 c
dll_path = virtual_driver.dll # C驱动DLL路径
[ai]
handshake_prompt_enabled = true # 是否启用握手提示词
instruction_format = line_by_line # 指令格式
[capture]
screenshot_interval = 0.5 # 截图间隔(秒)- 已废弃,现在改为按需触发
capture_region = full_screen # 截图区域
save_screenshots = true # 是否保存截图到tmp目录
max_screenshot_count = 50 # 最大保留截图数量(0=不保存)
[control]
countdown_seconds = 5 # 启动倒计时(秒)
pip install -r requirements.txt
# 编辑 config.ini,填入你的OpenAI API密钥
python main.py
. ├── main.py # 主程序 ├── api_client.py # API客户端 ├── driver.py # Python驱动 ├── c_driver_wrapper.py # C驱动包装器 ├── virtual_driver.dll # C驱动DLL ├── config.ini # 配置文件 ├── requirements.txt # Python依赖 └── README.md # 本文档
启动时向AI发送标准化提示词,确保AI理解指令格式并只返回指令,不返回额外解释。
MIT License