Simplified Chinese | English
Stanford AI Town was open sourced by Stanford University and Google in August 2023. It is a virtual world composed of 25 agents that simulates real human life.
25 agents are completely driven by ChatGPT and can independently organize parties, attend meetings, and plan various activities for Valentine's Day. They can display life patterns and behavioral habits similar to humans.
The original code of Generative Agents has a low degree of engineering, making it difficult to maintain or expand its functions continuously. Moreover, after more than a year, the capabilities of Chinese LLM are already qualified for such tasks. Therefore, we reconstructed and in-depth localized the original project, aiming to provide Chinese users with a basic version that is easy to maintain for subsequent experiments or trying more gameplay.
The wounderland project is a reconstructed version of the original Generative Agents project. It has a good structure and the code quality is much better than the original version. Therefore, this project is developed based on wounderland.
Main work:
Playback screen:
Note: The map and character names are also synchronized into Chinese to prevent LLM from switching to English context when encountering mixed Chinese and English contexts.
git clone https://github.com/x-glacier/GenerativeAgentsCN.git
cd GenerativeAgentsCN
Modify the configuration file generative_agents/data/config.json
:
base_url
and model
are consistent with the configuration in Ollama.api_keys
and modify base_url
and model
according to the API documentation.It is recommended to use anaconda3 to create and activate the virtual environment first:
conda create -n generative_agents_cn python=3.11
conda activate generative_agents_cn
Install dependencies:
pip install -r requirements.txt
cd generative_agents
python start.py --name sim-test --start "20240213-09:30" --step 10 --stride 10
Parameter description:
name
- Each time you start the virtual town, you need to set a unique name for later playback.start
- the starting time of the virtual town.resume
- After the run ends or is unexpectedly interrupted, continue running the virtual town from the last "breakpoint".step
- the number of iteration steps after which to stop running.stride
- the time (minutes) corresponding to each iteration in the virtual town. If --stride 10
is set, the time changes of the virtual town during the iteration process will be 9:00, 9:10, 9:20... python compress.py --name <simulation-name>
After the operation is completed, the playback data file movement.json
will be generated in the results/compressed/<simulation-name>
directory. At the same time, simulation.md
will be generated to present the status and dialogue content of each agent in a timeline.
python replay.py
Open the replay page through the browser (address: http://127.0.0.1:5000/?name=<simulation-name>
), and you can see the activities of the residents in the virtual town in various time periods.
You can move the screen with the arrow keys
Parameter description
name
- the name set when starting the virtual town.step
- the starting step number of playback, 0 means starting playback from the first frame, the default value is 0.speed
- playback speed (0-5), 0 is the slowest, 5 is the fastest, and the default value is 2.zoom
- the screen zoom ratio, the default value is 0.8. Replay data named example
(generated by qwen2.5:32b-instruct-q4_K_M) is built into the release version. If you want to start playback from the beginning at a faster speed and the screen zoom ratio is 0.6, the corresponding url is: http://127.0.0.1:5000/?name=example&step=0&speed=2&zoom=0.6
You can also open simulation.md directly to view all character activities and dialogue information in example
.
The dialogue content in the screen is generated by qwen2.5:14b-instruct-q4_K_M
town panorama
garden
cafes
classroom
Generative Agents: Interactive Simulacra of Human Behavior
Generative Agents
wounderland