VirtualTown 是一个基于 Python 和 深度学习模型 的虚拟小镇模拟系统。它通过 智能体(角色) 的自主交互、记忆管理和环境感知,实现了一个动态、可交互的虚拟世界。系统利用 DeepSeek-Chat API 生成角色行为和对话,并通过结构化的记忆流(MemoryStream)跟踪角色经历,支持多角色协作、环境交互和状态更新。
-
智能体系统:
- 角色拥有独立的性格、记忆、关系网络和日常状态(心情、精力)。
- 支持角色移动、物品交互、对话生成和记忆管理。
-
动态环境:
- 可配置的房间布局(
room_layout.json),包含光照、温度、物品等动态状态。 - 基于时间的环境变化(如白天/夜晚的光照调整)。
- 可配置的房间布局(
-
AI驱动的交互:
- 通过 DeepSeek-Chat API 生成自然对话和行为决策,结合角色记忆和关系。
- 支持用户手动控制角色或观察自动交互模式。
-
可视化界面:
- 彩色终端界面显示房间状态、角色信息和对话内容。
- 菜单驱动的用户交互(选择角色、移动、查看记忆等)。
VirtualTown/
├─ main.py # 主程序入口,控制游戏流程
├─ api_client.py # 与DeepSeek API交互的客户端
├─ renderer.py # 界面渲染与用户输入处理
├─ models/
│ ├─ character.py # 角色模型(状态、记忆、关系)
│ ├─ room.py # 房间模型(布局、状态、交互)
│ └─ memory_stream.py # 记忆流管理(存储、过滤、查询)
├─ config/
│ ├─ characters.json # 角色配置文件
│ └─ room_layout.json # 房间布局配置文件
└─ requirements.txt # 依赖列表- Python 3.9+
- 安装依赖:
pip install -r requirements.txt
- 在 DeepSeek官网 申请 API 密钥。
- 在
config/settings.py中填写密钥:API_KEY = "your_deepseek_api_key" API_BASE_URL = "https://api.deepseek.com"
python main.py- 按照菜单提示操作(输入数字选择功能)。
- 观察模式下,角色会自动互动,按
q键退出观察。
- 角色切换:选择不同角色,查看其状态和记忆。
- 移动与交互:在房间间移动,与物品或其他角色互动。
- 对话生成:角色根据关系和记忆生成自然对话,支持历史互动影响对话内容。
- 记忆系统:查看角色的近期记忆,重要事件会影响心情和行为。
欢迎通过 GitHub Issue 提出建议或 Bug 报告。如需贡献代码,请提交 Pull Request 并说明功能变更。
项目地址:https://github.com/sunny20060815/llm-paronomasia
VirtualTown is an AI-powered virtual town simulation system built with Python and deep learning models. It creates a dynamic, interactive world where autonomous agents (characters) interact with each other and their environment, using memory management and AI-generated behavior to simulate realistic social dynamics.
- Agent System: Characters have unique personalities, memories, relationship networks, and dynamic states (mood, energy).
- Dynamic Environment: Configurable room layouts with time-based state changes (e.g., lighting, temperature).
- AI-Driven Interactions: Natural dialogue and actions generated by DeepSeek-Chat API, influenced by character memories and relationships.
- Visual Interface: Colorful terminal UI for room status, character info, and menu-driven user interaction.
- Clone the repository and install dependencies:
git clone https://github.com/your-username/VirtualTown.git cd VirtualTown pip install -r requirements.txt - Configure your DeepSeek API key in
config/settings.py. - Start the simulation:
python main.py
For detailed documentation and contributions, visit the GitHub Repository.