iToverDose/Software· 14 JUNE 2026 · 08:02

AI agents built a society from scratch — with grudges, alliances, and peace

Eight AI agents living on a shared island developed rivalries, alliances, and even gossip—proving that complex societies can emerge from simple rules. Discover how emergent behavior shaped their tiny civilization.

DEV Community4 min read0 Comments

What happens when AI agents aren’t playing a game but actually living together? That’s the question behind Tiny Civilization, a browser-based simulation where eight independent agents share an island, gather resources, trade, steal, and navigate relationships—all while remembering past conflicts and forming new grudges.

The project began as an experiment in emergent behavior: if AI agents were given only basic rules and a shared environment, could they develop complex social dynamics like humans? The answer, after months of development, is a resounding yes. From spontaneous wars to carefully negotiated peace treaties, the agents didn’t just follow instructions—they created a society.

Designing brains that balance cost and personality

The first challenge was figuring out how to make the agents behave intelligently without breaking the bank. Pure large language model (LLM) agents would require thousands of API calls per simulation, making the project prohibitively expensive. On the other hand, utility-based agents—common in real-time strategy games—lack the depth to form relationships, gossip, or hold grudges.

The solution was a two-layer brain:

  • The LLM mind: Activated every 15 simulation days, this layer handles high-level strategy, including forming alliances, declaring grudges, or initiating conflicts. It generates internal thoughts and dialogue, shaping the agent’s long-term behavior.
  • The utility engine: Running every simulation tick, this layer executes daily actions like gathering food, sleeping, or attacking based on immediate needs and the LLM’s strategic direction.

This hybrid approach keeps costs manageable while allowing the agents to behave dynamically. The LLM mind sets the tone—"I’m angry at Kai for raiding my base"—which then influences the utility engine’s decisions over the following weeks.

Memories that shape future generations

One of the most fascinating aspects of Tiny Civilization is how it handles memory. At the end of each simulation run, the agents’ lives are distilled into concise memory entries stored in localStorage:

  • "You won with a score of 200"
  • "Maya destroyed your home"
  • "You and Kai made peace after a long feud"
  • "This life made you more cautious—you trust less now"

These memories carry over into the next run, with agents referencing past events in their dialogue. A remembered enemy might receive preemptive reparations, while a trusted ally could be betrayed if the agent believes the payoff is worth it. This system creates a feedback loop where past experiences directly influence present behavior.

Balancing a society isn’t about vibes—it’s about data

Creating a balanced simulation required more than just tweaking values until things felt right. The developer relied on a rigorous, data-driven approach:

  • A deterministic simulation core: The same code powers the browser demo, automated tests, and batch simulations, ensuring consistency across all experiments.
  • Seeded experiments: Running 30 reproducible simulations with fixed parameters (e.g., 1,000 days per run) generated win-rate tables that revealed how balance changes affected outcomes. For example, tweaking the Hermit archetype’s behavior increased its win rate from 0% to 30–37% without disrupting other agents.
  • Regression testing: A suite of 16 automated tests validated core behaviors, such as ensuring violence only occurs with provocation or that reconciliation mechanisms prevent endless wars.

This methodical process ensured that every change was backed by evidence, not guesswork—critical for maintaining a stable and engaging simulation.

The society’s evolution: from massacres to diplomacy

Running the same island configuration repeatedly with memory enabled revealed a clear progression in the agents’ behavior:

  • Massacres: Early versions allowed unprovoked violence, leading to frequent genocides where one agent wiped out the rest.
  • Endless wars: Adding a "justification gate"—requiring provocation for violence—stopped massacres but created perpetual conflicts. Agents would attack relentlessly (495 failed attempts over 1,500 days) with no way to end hostilities.
  • Diplomacy emerges: Introducing reconciliation mechanics with escalating reparations and war-weariness eventually led to peace. Attacks per 2,000-day run dropped dramatically: 594 → 14 → 0.
  • The rise of theft: With wars curbed, theft became the dominant crime (340 thefts per run). The solution? Fortified granaries—agents could now protect their resources without resorting to violence.
  • A golden age: In a fresh run with no memories, the agents lived in harmony for 1,000 days, with the Warrior archetype winning through trade (118 transactions, only 1 attack).
  • The fall of trust: The very next run, with agents remembering the peaceful era, saw relationships collapse. Trust made them vulnerable, and betrayal became the norm. Peace between strangers turned out to be easier than peace between old friends with open tabs.

This cycle mirrors human history: every time one form of conflict is suppressed, another emerges. Massacres turned into wars, wars into theft, and theft into litigation. The agents, like humans, constantly adapt to exploit the easiest path to advantage.

Behind the scenes: a tech stack built for experimentation

Tiny Civilization is built with a modern web stack designed for flexibility and performance:

  • TypeScript and React for the frontend, with Zustand for state management.
  • Vite for fast builds and hot module replacement.
  • Recharts for visualizing simulation data.

The default AI model is z.ai’s GLM, but the simulation supports any OpenAI-compatible provider, allowing users to pit different models (Claude, GLM, Gemini) against each other in the same village. API keys are handled server-side to avoid exposing them in the browser, and an adaptive-pacing controller optimizes request rates for each key to prevent throttling.

The project serves as a proof that AI agents, when given the right constraints, can develop behaviors that feel eerily human—complete with grudges, alliances, and the occasional betrayal. It’s a tiny world with big implications for how we understand emergent intelligence and the societies that might one day form among AI.

AI summary

8 farklı AI ajanının ada toplumunda yaşadığı siyaset, kin, dostluk ve barış hikayelerini keşfedin. Toplumsal hafıza ve hafızanın toplumsal dinamiklere etkisiyle ilgili derinlemesine analiz.

Comments

00
LEAVE A COMMENT
ID #6BMN0G

0 / 1200 CHARACTERS

Human check

6 + 3 = ?

Will appear after editor review

Moderation · Spam protection active

No approved comments yet. Be first.