快速上手
1. 环境准备
要求:
- Python
>=3.10 - Node.js / npm 只在前端开发态需要;安装态
chatgame web serve不依赖它们
建议使用干净的 Python 虚拟环境,避免系统 numpy/scipy/sklearn 混装导致 ABI 冲突。
python3 -m venv .venv
. .venv/bin/activate
安装 chatgame:
pip install chatgame
确认安装:
chatgame --version
# chatgame, version 0.1.12
chatgame --tree
chatgame --tree-brief
2. 纯 CLI 求解
准备一张游戏截图,一条命令得到答案:
chatgame solve level24.png
输出示例:
解(按点击顺序):
第 1 步 行0 列4 热粉
第 2 步 行1 列7 粉
...
棋盘([N]=第N步点击,数字=色块ID):
0 1 2 3 4 5 6 7
+────────────────────────+
0 │ 0 0 0 0 [1] 2 2 2 │
...
✓ 验证通过 (51 ms)
常用选项:
# 保存标注图(数字写在原图上)
chatgame solve level24.png -o solved.png
# 棋盘大小不能自动推断时手动指定
chatgame solve level24.png -n 10
# 打印颜色矩阵等调试信息
chatgame solve level24.png -v
3. 启动 Web UI
3.1 检查环境
chatgame web setup
输出示例:
── Python 环境
✓ chatgame 0.1.12
✓ fastapi 0.136.1
✓ uvicorn 0.47.0
── Web 静态资源
✓ 包内静态资源已就绪:.../site-packages/chatgame/web_static
· 可直接运行:chatgame web serve
✓ 环境就绪,可运行:chatgame web serve
说明:
web setup只验证安装态 Web 运行必需项,不要求scikit-learn/scipy- 只要
pip install chatgame完整成功,通常不需要额外准备 Node.js
3.2 启动服务
chatgame web serve
打开浏览器访问 http://localhost:8000,即可使用 Web 界面求解游戏。
# 自定义端口
chatgame web serve --port 9000
# 允许局域网/IP 访问
chatgame web serve --host 0.0.0.0 --port 8000
4. 支持的游戏
chatgame games
| 游戏 ID | 游戏名称 | 说明 |
|---|---|---|
cow-puzzle |
牛牛摆放谜题 | 色块区域约束,N-Queens 变体 |