Sin Liang LeeSL Lee

Simulacra

Paste a policy and watch a pixel-art city of AI agents react to it.

Role
Top committer; Phaser city, round engine
Team
3 people
Context
YHack Spring 2026 — Best Use of K2 Think V2 (IFM), winner
Stack
Python, FastAPI, LangGraph, asyncio, Socket.IO, React, Phaser 3, K2 Think V2
Simulacra running: a pixel-art city seen from above, its residents talking about the policy in speech bubbles, beside the economy panel for phase 3, round 3 of 5.
From the demo video: a run in progress, round 3 of 5, with residents reacting to the policy in speech bubbles.

What it is

You give it a policy document. A town of up to 100 AI agents (the population is configurable per run), each with a job, an income and a political lean, lives with that policy round by round. You watch them talk in a pixel-art city, open any one of them to ask what they think and read the economic report at the end.

What I built

  • Top committer: 109 of 196 commits.
  • During the hackathon, the Phaser front end: a procedural city generator, NPC movement and events, multi-tile cars that stay on roads, and the economic effects (bankruptcies, money, phase flashes, emotion bubbles).
    A speech bubble in the pixel-art city, over a resident on the road. Judy Mitchell, tipped hospitality worker: “Feelin’ my joy hit absolute peak knowin’ this policy’s lockin’ in our brighter f…”
    Detail A resident reacting to the policy.
  • After the hackathon, the two-phase round: initiators act first, and reactors see those events in memory. Also a relationship graph built from profession overlap, income parity, political alignment and grid distance, and retries for the model’s JSON output.

Technical notes

  • Every agent in a round runs in parallel with asyncio, through a perceive, retrieve, reflect, plan, act loop in LangGraph.
  • An agent reflects once the summed importance of its new memories crosses 25.
  • Opinions move by Deffuant bounded confidence and Baumann controversy amplification: an agent keeps its view, compromises or adopts the other’s.
  • Results stream over Socket.IO to a React front end. An event bridge keeps the data layer separate from the Phaser 3 world.
  • Population and round count are set per run, as parameters of the simulation request rather than constants in the code. Runs go up to 100 agents.
The economy panel for phase 3, round 4 of 5: egg index $1.00, prices +0.0%, unemployment up to 5.4%, interest rate 5.25%, social unrest 0%, businesses open 95%, government approval down to 56%.
Fig. 1 The economy panel (detail).
An agent’s profile, a waitress with mood, income and political lean, beside a chat where the user asks her about the policy.
Fig. 2 Questioning one agent about the policy.
Social graph of agents as nodes, with a legend for family, friend, employer, colleague and neighbor ties.
Fig. 3 The relationship graph.