A newer version of the Gradio SDK is available:
5.49.1
metadata
title: Besiege Machine Generator
emoji: 🎮
colorFrom: purple
colorTo: blue
sdk: gradio
sdk_version: 4.44.1
app_file: app.py
pinned: false
license: mit
🎮 Besiege Machine Generator
使用 AI 生成你的 Besiege 机器设计!这个应用使用 DeepSeek AI 模型来理解你的描述,并生成可以直接在 Besiege 游戏中使用的 .bsg 文件。
✨ 特性
- 🤖 AI 生成:使用自然语言描述你想要的机器,AI 会自动生成
- 🔄 手动转换:如果你已经有 JSON 数据,可以直接转换为 .bsg 文件
- 💾 一键下载:生成后直接下载 .bsg 文件
- 🎨 现代界面:美观易用的用户界面
🚀 使用方法
AI 生成模式
- 在文本框中描述你想要创建的机器
- 例如:"创建一个四轮车,带有旋转块驱动"
- (可选)调整高级设置
- Temperature:控制创意程度
- Max Tokens:控制生成长度
- 点击"生成机器"按钮
- 等待 AI 生成完成
- 下载生成的 .bsg 文件
手动转换模式
- 粘贴你的 JSON 机器数据
- 点击"转换为 XML"按钮
- 下载生成的 .bsg 文件
📋 JSON 格式说明
JSON 格式应该包含机器的方块信息,例如:
[
{"id": "0", "order_id": 0, "parent": -1, "bp_id": -1},
{"id": "1", "order_id": 1, "parent": 0, "bp_id": 0},
...
]
字段说明:
id: 方块类型 IDorder_id: 方块的顺序编号parent: 父方块的 order_id(-1 表示根方块)bp_id: 连接到父方块的建造点 ID
对于线性方块(如橡皮筋,id=9):
{"id": "9", "order_id": 2, "parent_a": 0, "bp_id_a": 0, "parent_b": 1, "bp_id_b": 2}
🎮 可用方块类型
0: Starting Block(起始方块)1: Wooden Block(木块)2: Powered Wheel(动力轮)15: Small Wooden Block(小木块)16: Spring(弹簧)22: Rotating Block(旋转块)30: Container(容器)35: Ballast(配重)36: Boulder(巨石)41: Wooden Rod(木棒)63: Log(原木)9: Rubber Band(橡皮筋,线性方块)
🔧 技术栈
- Frontend: Gradio
- AI Model: DeepSeek-R1-Distill-Llama-8B
- Backend: Python
- Libraries: NumPy, SciPy, Hugging Face Hub
⚙️ 本地运行
- 克隆仓库
git clone <your-repo-url>
cd BesiegeField-MachineGenerator
- 安装依赖
pip install -r requirements.txt
- 设置环境变量(可选,用于访问 HF 模型)
export HF_TOKEN=your_huggingface_token
- 运行应用
python app.py
📝 注意事项
- 生成质量:AI 生成的机器可能需要在游戏中进行调整
- 尺寸限制:
- 长度(Z): ≤ 17
- 宽度(X): ≤ 17
- 高度(Y): ≤ 9.5
- 方块连接:新方块必须连接到现有方块的可建造点
- 坐标系统:使用左手坐标系,Y+ 向上,Z+ 向前,X+ 向右
🤝 贡献
欢迎提交 Issue 和 Pull Request!
📄 许可证
MIT License
🙏 致谢
- Besiege - 精彩的物理建造游戏
- DeepSeek AI - 强大的 AI 模型
- Gradio - 快速构建 ML 应用界面