Skip to content

VirtualTown: 基于 AI 的虚拟小镇模拟系统 项目简介 VirtualTown 是一个基于 Python 和 深度学习模型 的虚拟小镇模拟系统。它通过 智能体(角色) 的自主交互、记忆管理和环境感知,实现了一个动态、可交互的虚拟世界。系统利用 DeepSeek-Chat API 生成角色行为和对话,并通过结构化的记忆流(MemoryStream)跟踪角色经历,支持多角色协作、环境交互和状态更新。

Notifications You must be signed in to change notification settings

sunny20060815/llm-paronomasia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VirtualTown: 基于AI的虚拟小镇模拟系统

Python DeepSeek API

项目简介

VirtualTown 是一个基于 Python深度学习模型 的虚拟小镇模拟系统。它通过 智能体(角色) 的自主交互、记忆管理和环境感知,实现了一个动态、可交互的虚拟世界。系统利用 DeepSeek-Chat API 生成角色行为和对话,并通过结构化的记忆流(MemoryStream)跟踪角色经历,支持多角色协作、环境交互和状态更新。

核心功能

  1. 智能体系统

    • 角色拥有独立的性格、记忆、关系网络和日常状态(心情、精力)。
    • 支持角色移动、物品交互、对话生成和记忆管理。
  2. 动态环境

    • 可配置的房间布局(room_layout.json),包含光照、温度、物品等动态状态。
    • 基于时间的环境变化(如白天/夜晚的光照调整)。
  3. AI驱动的交互

    • 通过 DeepSeek-Chat API 生成自然对话和行为决策,结合角色记忆和关系。
    • 支持用户手动控制角色或观察自动交互模式。
  4. 可视化界面

    • 彩色终端界面显示房间状态、角色信息和对话内容。
    • 菜单驱动的用户交互(选择角色、移动、查看记忆等)。

技术架构

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

配置 API 密钥

  1. DeepSeek官网 申请 API 密钥。
  2. config/settings.py 中填写密钥:
    API_KEY = "your_deepseek_api_key"
    API_BASE_URL = "https://api.deepseek.com"

运行程序

python main.py
  • 按照菜单提示操作(输入数字选择功能)。
  • 观察模式下,角色会自动互动,按 q 键退出观察。

功能演示

  1. 角色切换:选择不同角色,查看其状态和记忆。
  2. 移动与交互:在房间间移动,与物品或其他角色互动。
  3. 对话生成:角色根据关系和记忆生成自然对话,支持历史互动影响对话内容。
  4. 记忆系统:查看角色的近期记忆,重要事件会影响心情和行为。

贡献与反馈

欢迎通过 GitHub Issue 提出建议或 Bug 报告。如需贡献代码,请提交 Pull Request 并说明功能变更。

项目地址https://github.com/sunny20060815/llm-paronomasia

English Introduction

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.

Key Features

  • 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.

How to Run

  1. Clone the repository and install dependencies:
    git clone https://github.com/your-username/VirtualTown.git
    cd VirtualTown
    pip install -r requirements.txt
  2. Configure your DeepSeek API key in config/settings.py.
  3. Start the simulation:
    python main.py

For detailed documentation and contributions, visit the GitHub Repository.


About

VirtualTown: 基于 AI 的虚拟小镇模拟系统 项目简介 VirtualTown 是一个基于 Python 和 深度学习模型 的虚拟小镇模拟系统。它通过 智能体(角色) 的自主交互、记忆管理和环境感知,实现了一个动态、可交互的虚拟世界。系统利用 DeepSeek-Chat API 生成角色行为和对话,并通过结构化的记忆流(MemoryStream)跟踪角色经历,支持多角色协作、环境交互和状态更新。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages