Purpose: This repository is the companion code for the research paper "Generative Agents: Interactive Simulacra of Human Behavior," containing the core simulation module and game environment of generative agents, used to simulate believable human behavior.
Main capabilities: Provides the Smallville map environment and simulation of multiple agents (such as Isabella Rodriguez, Maria Lopez, Klaus Mueller); supports running a specified number of game steps (one step represents 10 seconds in-game), saving and continuing simulations, replaying simulations, and compressed demo animations; supports loading agent historical memory files, and also supports customizing the base simulation.
Usage: You need to create utils.py under reverie/backend_server and fill in the OpenAI API key and name, and install requirements.txt (tested environment is Python 3.9.12). Running the simulation requires starting two services simultaneously: the environment server (Django, located in environment/frontend_server, after running access http://localhost:8000/)和仿真服务器(reverie/backend_server under reverie.py). At the simulation server prompt, enter run <step-count> to run, exit to quit without saving, fin to save and exit. The replay address is http://localhost:8000/replay/<simulation-name>/<starting-time-step>; for the demo, you first need to compress with compress_sim_storage.py, then access http://localhost:8000/demo/<simulation-name>/<starting-time-step>/<simulation-speed> (speed 1 is the slowest, 5 is the fastest). Saved simulations are located in environment/frontend_server/storage, and compressed demos are located in environment/frontend_server/compressed_storage.
Applicable scenarios: Academic research, agent behavior simulation experiments, interactive simulation demos.
Limitations: Requires an OpenAI API key; when the OpenAI API reaches the hourly rate limit, it may hang, requiring a restart of the simulation, and frequent saving is recommended; as of early 2023, running simulations may be costly, and more so with more agents; replay is mainly for debugging and does not optimize simulation folder size or visual effects, and character sprites may be identical; customizing agent names or increasing their number may require directly editing the map with the Tiled map editor.