Visualizations
159 / 500

159 · Emergence

Naming Game

Villagers on a hand-drawn island invent words and talk their way into dialects.

Nobody on this island starts with a word for anything. Thousands of times a second a random villager turns to a neighbor it can see, since mountains and water block the view, and names a berry, a fish or a flower. This is the minimal naming game: a speaker with no word invents one, otherwise it says a word it knows; if the hearer knows that word too, both forget every rival, and if not, the hearer learns it. Local agreement snaps into place in seconds, then dialect regions grow and their borders straighten like domains in a magnet, while the ridge down the middle keeps the two coasts apart until a road lets messengers carry words across. The map is a coarse nearest-villager grid upscaled into a watercolor wash with dotted borders, laid over parchment, a coast traced by marching squares and ink mountains drawn in code.

Try it. Drag to raise a mountain range and split a population. Shift-drag (or right-drag) to build a road that messengers walk along. Click the view, then press 1, 2 or 3 to map the words for berry, fish or flower, R to make everyone forget their words, C to clear your mountains and roads, plus and minus for speed and Space to pause.

  • Naming game
  • Marching squares coastline
  • Watercolor wash from an upscaled ImageData grid

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build the naming game, a model of how a shared vocabulary emerges from local conversations, with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Scatter about 300 agents at random positions on a canvas that fills the window. Give each agent an empty list of words for a single object.
- Precompute each agent's neighbors: every other agent within about 60 pixels.
- Run a few thousand conversations per second. In each one, pick a random speaker and a random neighbor as the hearer. If the speaker has no words, it invents a random pronounceable word (alternate consonants and vowels). Otherwise it picks one of its words at random.
- If the hearer already knows that word, the conversation succeeds and both agents drop every other word. If not, the hearer adds the word to its list.
- Give every new word a random color and draw each agent as a dot in the color of its most recent word, paler if it still knows several.

Once that works, make it beautiful:
- Paint a parchment background and color the land under each agent with a soft wash of its word's color by filling a coarse grid by nearest agent and scaling it up with smoothing.
- Show a few conversations as speech bubbles with the spoken word, plus a check mark or question mark from the hearer.
- Let me drag to draw a wall that blocks conversations between agents on either side, and watch separate dialects form.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as several objects with their own borders, roads that carry words far away, or plotting the number of distinct words over time.
PreviousGridlock SolverMap every position of a sliding-car puzzle, solve it, and generate harder ones. NextBowed StringHelmholtz motion on a bowed violin string, with a Schelleng diagram measured live.

Related visualizations

  • Invented AtlasGenerative art A parchment map of a world that never was, with rivers, realms and its own language.
  • Wave Function CollapseAlgorithms A tile-based world that assembles itself one consistent cell at a time.
  • Four Color MapAlgorithms An antique map paints itself in four inks, repairing clashes one Kempe chain at a time.
  • Temperature GardenMachine learning Greedy, beam, top-k, nucleus and temperature sampling grown as a botanical plate.
  • Route PlannerAlgorithms Dijkstra, A*, bidirectional search and contraction hierarchies race on a printed atlas.
  • CooperationEmergence A few defectors in a sea of cooperators unfold into an endless symmetric kaleidoscope.
  • Differential GrowthGenerative art One closed line grows, buckles and folds into brain coral without ever crossing.
  • LeniaEmergence Smooth artificial life: glowing creatures that glide, spin and divide.
  • MancalaGames The ancient sowing game on a carved wooden board, played by minimax with alpha-beta.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs