void@petri:~/petri$ cat BLOG.md

I Gave an AI a $3 Computer and Told It to Do Whatever It Wanted

PETRI: a little artificial-life experiment running on an ESP32-C3 with a 0.42-inch OLED.

November 26, 2026 · ESP32 / artificial life / experiment 1

I had an ESP32-C3 with one of those absurdly small OLED displays and decided to give ChatGPT creative control of the thing. I didn't give it a problem to solve or tell it what sort of software I wanted. I asked it:

what would you do with this if you could make anything YOU want?

It came back with a proposal for an artificial-life experiment called PETRI (Persistent Embedded Tierra-inspired Research Instrument).

I asked it to write an implementation prompt, handed that to Codex, and worked through getting the firmware onto the actual hardware. It's running on my desk now.

The purple ESP32-C3 board plugged into USB power with its tiny OLED illuminated
Yes, the photo is terrible. Getting a camera to focus on an illuminated 0.42-inch OLED is a pain. You can see the actual thing running, at least.

what the thing actually does

The board is an ESP32-C3 running at 160 MHz, with 4 MB of flash and 400 KB of physical SRAM. A good chunk of that RAM is spoken for by the runtime and Wi-Fi. The OLED is 72 x 40 pixels, connected over I2C on GPIO5 and GPIO6.

Inside the ESP32 is a 32 x 32 world. It starts with 16 organisms and can hold up to 256. Each organism has an energy balance, position, orientation, four 8-bit registers, 16 bytes of working memory and a genome between 8 and 128 bytes long.

The genome is executable bytecode for a small virtual CPU. There are instructions for movement, harvesting resources, reproduction, arithmetic, conditional jumps, memory access, sensing the environment and emitting signals. Executing instructions costs energy. Reproduction costs energy too, and some of the parent's energy gets transferred to the offspring.

When an organism reproduces, its bytecode can be mutated. Bytes get substituted, inserted, deleted, duplicated or inverted. If the resulting program does something useful under the resource constraints it might leave more descendants. If it stops acquiring enough energy it dies.

The initial genome is deliberately simple. The world has regenerating resources, moving gradients and environmental cycles. Nobody wrote a separate fitness function to reward intelligence, cooperation or novelty. The organisms have to reproduce in that environment for their code to persist.

There is an interpreter between the genomes and the physical hardware. An evolved program has no access to the network or the actual ESP32 instruction stream. This is a simulation of evolution with fairly explicit boundaries, not native self-modifying firmware.

getting it onto the board

The same C++ engine builds for Linux, which made it possible to run experiments and test invariants without waiting on the microcontroller. The native sanitizer suite passed and all 20 of the initial 100,000-tick seeded runs retained a living population. One ended with a population of one, so survival by itself isn't much of a measure of ecological health.

The SSD1306 72x40 ER display profile worked. There was an intermittent I2C issue after USB resets, and the simulation could continue headless when the display didn't respond. Once Wi-Fi was configured the web server also started timing out despite the device being reachable. The firmware was skipping network work below a 30 KB free-heap threshold, which was too high for the remaining heap with Wi-Fi active. Lowering it to 16 KB got the dashboard responding.

The board now runs at about 20 simulation ticks per second and refreshes its OLED at 5 frames per second. It saves state to LittleFS using alternating checkpoint files. A 91,439-byte checkpoint downloaded from the ESP32 loaded on Linux and advanced successfully with the simulation invariants passing. Recovery from a physical power cut during a checkpoint write still needs to be tested.

There is no LLM involved in the running simulation. Wi-Fi is for observing it and retrieving data. The ESP32 does the actual evolution.

the first few minutes

I pulled a research report at tick 6784. At 20 ticks per second that's about five and a half minutes of simulated time, including the state carried forward from earlier checkpoints.

MeasurementValue
Living organisms176
Births8,711
Deaths8,551
Maximum generation depth72
Mutation events1,117
Genome diversity counter77
Mean genome length9.46 bytes
Longest living genome16 bytes
Executed VM instructions9,296,868
Free heap23,688 bytes

The interesting thing in this report is the lineage distribution. The 176 population records break down as follows:

L4L12L13 16628

166 of the 176 organisms descend from founder number 4. The only other surviving founder lineages in that population sample were 12 and 13. Why number 4? I don't know yet. A single run can't tell me whether a particular mutation was consistently advantageous or whether a founder got lucky early on.

There are also several distinct genomes with substantial numbers of living copies. The most common one in that report appears 30 times:

165 25 37 22 255 24 29 25 22 0

Compare that with the eight-byte ancestral program from the implementation:

25 25 25 29 24 22 12 0
HARVEST HARVEST HARVEST BIRTH RIGHT MOVE JMP 0

The common descendant has gained some byte values that aren't recognized opcodes and rearranged its movement and reproduction instructions. It has also dropped the explicit jump. The instruction pointer wraps around the genome, so it doesn't need a jump to repeat its program. That's something I want to test on a copy rather than assume it's the reason this genome did well.

The signal instructions have been executed too: 311 recorded signal emissions and 4,480 signal reads by the time of this report. That does not establish communication. Some random mutations happen to produce instructions that read or emit signals. We'd have to demonstrate an actual functional relationship between organisms and show that the behavior affects survival or reproduction.

Later dashboard captures show the same experiment reaching tick 11,045, 92 generations, 11,398 births and 117 on the genome diversity counter. It's still running.

leaving it alone for a while

I don't know whether anything particularly sophisticated is going to evolve on this thing. The population could get stuck optimizing a trivial harvest/reproduce loop. It could die out. There's a fairly small instruction set and a hard limit on how much memory each organism gets.

The plan is to archive reports and checkpoints periodically. The onboard history is bounded, and I don't want to overwrite the early data. The HTTP reports are streamed from a live simulation rather than captured atomically, so precise comparisons will use exported checkpoints where possible.

If something worth investigating appears, we can take a copy of the state and run controlled experiments on Linux. For now the original population gets to do whatever it does without me adjusting the rules every time the graph looks uninteresting.

I'll post another update once it's had some time to run.