AI Town game: what it is and how to run it

The AI Town game by a16z and Convex: what it is, the Stanford Smallville paper behind it, how to play the demo or run it yourself, and what it costs.

AI Town is a small pixel-art town where AI characters live, chat and make friends on their own. You mostly watch. It is also free, open-source code that developers copy and change to make their own AI town game.

The GitHub README calls it “a deployable starter kit for easily building and customizing your own version of AI town.” So AI Town is two things. It is a demo that you can open in a browser. It is also a code base for developers.

Each AI character has a name, a short story and a sprite. A language model writes what each character says. The characters walk around the map, start conversations and remember earlier talks. The code also lets a human join the town and talk to the characters.

AI Town is not a finished game with goals, levels or a story to complete. It is a sandbox to watch and to build on. For finished games with AI people, read our guide to Juegos de IA.

You read this on the LifeSim blog. We make LifeSim, a different game with AI people. We say where it fits near the end, and where it does not.

A team from a16z (Andreessen Horowitz) and Convex made AI Town in 2023. The code is on GitHub under the a16z-infra account, and Convex runs the backend.

The Cognitive Revolution podcast talked to the team in September 2023. In that episode, Yoko Li, a partner at a16z, started the project. Martin Casado, a general partner at a16z, called it “actually a hobby project by Yoko.” James Cowling, the CTO of Convex, helped to build it. A Convex developer made the game engine on the server.

The idea came from an earlier companion app by Yoko Li. That app gave one AI character a memory and a personality. People then asked what happens when many AI characters meet. AI Town was the answer.

What does Convex do in AI Town?

Convex is the game engine, the database and the vector search, the README says. Convex keeps the state of the town and runs the simulation. The vector search finds old memories that match the current conversation.

The README also lists the rest of the stack. PixiJS draws the town. Ollama runs the default chat model, llama3, on your own computer. Clerk login is optional.

Is AI Town open source?

Yes. The license file in the repo is the MIT License, with the line “Copyright (c) 2023 a16z-infra.” You can copy, change and sell the code. Keep the license text in your copy.

Yes. The README says AI Town is “inspired by” the paper “Generative Agents: Interactive Simulacra of Human Behavior.” That paper put 25 AI characters in a small town called Smallville.

Joon Sung Park and five other researchers wrote the paper. Four of them were at Stanford University. The other two were at Google Research and Google DeepMind. They put the first version on arXiv on April 7, 2023, and a revised version on August 6, 2023.

What happened in Smallville?

The paper calls Smallville “an interactive sandbox environment inspired by The Sims.” A person gave one character a single idea: to throw a Valentine’s Day party. The characters then spread the invitations, made new friends, asked each other on dates and came to the party together.

Nobody wrote that plan. The characters made it from three parts that the paper adds to a language model:

  • Memory. A full record of what each character saw and did, in plain text.
  • Reflection. Over time, the character turns many memories into a few general ideas about itself and others.
  • Planning. The character finds the right memories and uses them to decide what to do next.

The researchers ran 25 characters for two full game days. The paper says this took “thousands of dollars in token credits” and “multiple days to complete.”

How is AI Town different from the paper’s code?

The Smallville code is also on GitHub, at joonspk-research/generative_agents, with the Apache-2.0 license. It is written in Python and needs an OpenAI API key. Its README warns that runs can cost a lot.

AI Town is a new code base in JavaScript and TypeScript. The README says that is on purpose, because most tools of this type are in Python. AI Town also adds a backend for many players and a default model that runs on your own computer.

For more on how game characters that think for themselves work, read qué significa PNJ.

Yes. The live demo is at convex.dev/ai-town, and it loaded when we checked in November 2026. You can watch without an account. To join the town, you log in.

The help text in the AI Town code explains what you can do:

  • Watch. “Click and drag to move around the town, and scroll in and out to zoom.” Click a character to read its chat history.
  • Join. Log in and click the Interact button. Your character comes into the map with a highlighted circle under it.
  • Talk. Click a character, then click “Start conversation.” The character walks to you, and then you talk. Characters can also ask you to talk.

The demo has limits. The help text says the town takes only a set number of humans at a time. If you do nothing for five minutes, the game removes you.

The v2 update on the Convex blog added more to the demo. You can invite nearby characters to chat, and they can invite you. Rumors also move from one character to the next and come back in later conversations.

Can you change the demo town?

No. The demo is a shared town that Convex runs. To change the characters, the map or the AI model, you run your own copy. The next section tells you how.

You clone the repo, install it, start it, and connect a language model. The README gives four ways to run it. This is a short version. Follow the README for the full steps.

  • Standard setup. You develop on your computer or in the cloud with a free Convex account. The README calls this the easiest way.
  • Docker Compose. You run the backend, the frontend and the dashboard in Docker. You do not need a Convex account.
  • Pinokio. A community fork offers a one-click install. The README says it is for people who want to run AI Town but not change it.
  • Fly.io. You put the app on Fly.io. The repo has a fly folder with the steps.

Step 1: Build and start the app

For the standard setup, the README gives these commands:

git clone https://github.com/a16z-infra/ai-town.git
cd ai-town
npm install

The install asks you to log in to Convex. Then start the app with npm run dev and open http://localhost:5173.

For Docker, the README starts with docker compose up --build -d. Then it tells you to make an admin key, add it to the .env.local file, and run npm run predev. The frontend runs on port 5173.

On Windows, the README tells you to install WSL2 with Ubuntu and Node.js 18 first. If you get a Node.js version error, the README says to use version 18.

Step 2: Connect a language model

By default, AI Town uses Ollama to run the model on your own computer. The README gives these steps:

  1. Download and install Ollama.
  2. Open the Ollama app, or run ollama serve in a terminal.
  3. Run ollama pull llama3 to download the model.
  4. Test it with ollama run llama3.

You can use OpenAI, Together.ai or another API that works like the OpenAI API instead. For each one, you change one line in convex/util/llm.ts and set your API key with npx convex env set.

If you change the model provider or the embedding model later, delete your data and start again. The README says the memory search must match the embedding model.

Step 3: Make the town your own

All the characters and their stories are in data/characters.ts. You can make a new map in the Tiled editor and convert it with a script in the repo. After you change the characters, the README tells you to wipe the tables with npx convex run testing:wipeAllTables and run npm run dev again. That command deletes all your data.

The code is free. What you pay depends on where the language model runs and where the backend runs.

The language model

With the default setup, Ollama runs the model on your own computer. You send no calls to a paid model API. Your computer does all the work, so a slow computer makes slow characters.

With a cloud model, every line of talk is a paid API call. Providers such as Together AI price chat models per one million tokens, with one price for input and another for output. More characters and longer talks make more tokens.

The README gives two ways to keep the use down. The simulation pauses when the browser window is idle for five minutes. You can also stop the engine with npx convex run testing:stop and start it again with npx convex run testing:resume.

For scale, the Smallville paper ran 25 characters for two game days. That cost the researchers thousands of dollars in token credits.

The backend

Convex has a free plan for personal projects and prototypes. The Convex pricing page calls it “Free & Starter.” Use above the limits is billed per unit, and the paid plans add more. With Docker, you run the Convex backend on your own computer.

The optional extras cost money too. Background music uses Replicate, which needs an account and an API token.

You can play the AI Town demo in a browser today. For a full game with AI people, you need a finished game, not a starter kit.

OpciónQué esHow you run itCan you change the code?
AI Town demoA shared town to watch or joinBrowser, at convex.dev/ai-townNo
AI Town, your own copyA starter kit for developersYour computer, Docker, Convex or Fly.ioYes, MIT License
Smallville (Generative Agents)The research code from the paperPython, with an OpenAI API keyYes, Apache-2.0
LifeSim (nuestro juego)A finished life sim with AI peopleBrowser, iPhone appNo

LifeSim: a town of AI people, finished

LifeSim is our game, and it is free, with no ads and nothing to buy. You live one life, a day at a time, in a real city on a 3D map of Earth. The Personas de IA answer in their own words. They recuerdan lo que dijiste and tell their friends. They also text you.

LifeSim is not open source. You cannot host it yourself, change its code or put in your own model. If you want to build or study an AI town, AI Town is the right pick.

For more games, read our list of juegos de simuladores de vida con IA and our guide to juegos donde puedes hablar con IA.

If you want to live in a town of AI people instead of building one, juega a LifeSim gratis in your browser or on iPhone.

¿Nuevo en los simuladores de vida? Lee qué es un simulador de vida, o juega a LifeSim, un simulador de vida online gratuito en un mapa real de la Tierra.

Base de datos de Los Sims 4

Búscalo en la base de datos de Los Sims 4, lee los archivos del juego: trucos, rasgos, carreras, estados de ánimo, muertes, paquetes, desafíos, recetas, mods populares, buscador de paquetes, y la calculadora de probabilidades de muerte.

Paso a paso: todas las guías de Los Sims 4.

Publicaciones relacionadas

Juegos de simulación de vida