← Systems and automation

Distributed system / ESP32

Civilization Zero.

Three devices. Three independent worlds.

How it works

Residents’ decisions

An original agent-civilisation system for three ESP32-S3 devices. Each runs its own world, preserves its history, and exchanges information with the others. I built the shared engine, communication, data persistence, and an observatory for following the development of these worlds.

History and scope of the work

Three worlds without one central engine

Each device runs its own civilisation engine and retains its own state. One node also provides a local page with public information, while decisions remain distributed across the three worlds. Knowledge about neighbours comes from received messages. I built shared software sources for all nodes and separated a world’s identity from the profile used to compile its firmware.

Residents, families, and society

The model includes individual residents, households, work, property, memory, and beliefs. Social relationships and institutions emerge from these agents’ actions and needs. I developed rules for local decisions and their consequences for the whole world. The observer names larger phenomena but does not pass those labels to residents or prescribe an expected scenario for the simulation.

Communication that accounts for a lost message

I prepared communication over ESP-NOW with packet-integrity checks, acknowledgments, retries, and duplicate detection. An exchange that requires agreement passes through separate stages of preparation, acceptance, commitment, and outcome confirmation. I tested scenarios involving lost messages, changed order, and a participant restart. It was important that a late or repeated packet not execute the same operation again.

A history that survives a restart

I developed on-device state and journal storage, as well as identity recovery after a restart. Stopping one node affects its own time, while the others continue their worlds. The work also included recovery from earlier problems and preservation of existing histories. The system keeps software changes, record restoration, and the creation of a new civilisation as separate operations.

One engine: computer and devices

I separated the C++ logic from the hardware layer, allowing the same model to be studied on a computer and prepared for ESP32. The simulator can vary network conditions, disconnect nodes, and replay the same course of events. The work also included runs on physical boards and checks of memory constraints. A simulator result and a hardware observation answer different questions, so I retain both paths.

A real problem: residents’ spatial memory

While investigating the collapse of two worlds, I found a bug in limited spatial memory: the order in which surroundings were examined displaced useful resource information. The fix selected the best observed food, material, and most important threat. I compared many runs to verify the cause without tuning mortality or reproduction towards a chosen ending. The civilisations could still develop along different paths.

The observatory and the worlds’ newspaper

I built a layer that collects public information and presents the histories of the three worlds side by side. It includes a local page, an external observation record, and the development of a newspaper for the worlds. The view shows data freshness and presents only information received from a neighbouring node. The observer remains outside the decision engine, so watching events does not change their outcome.

What this work makes possible

The project combines device programming, a distributed system, an agent model, and observation tools. It also shows how I investigate errors: from event history to a fix for their actual cause.

The portfolio presents the components I built and the history of the research. It is not a live view of the devices’ current state.