Preview environment - you also see content that isn't published yet.

The world as a model

Before an agent can think, it needs a world. Building an agent means first modelling a slice of reality - and then steering actors within it.

The starting point: Before we even think about "artificial intelligence", we build a world. Building an agent means first modelling a slice of reality - and then letting actors act within it. This chapter sets the concept and the rules. Code comes after.

An agent never lives in a vacuum

An agent is not a free-floating brain. It acts in something: an environment it perceives and changes. With no world there is nothing to perceive and nothing to decide.

For an LLM agent this world is usually invisible: it consists of its tools, its context window, the state of the systems it talks to. That is exactly what makes agents so hard to grasp - you can't see the world they think in.

We flip that around and build a world you can see: an ant colony that collects sugar. Every perception, every decision, every change shows up on screen.

A digital twin - and why playful

What we're doing here has an industrial name: building a digital twin - a runnable model of a slice of reality in which you can observe and steer actors. Factories, logistics and power grids are simulated this way before anyone touches the real thing.

Our twin is deliberately harmless: not a factory, but ants. Yet the discipline is the same - model the world, steer the actors - and the lessons transfer one to one to serious agent systems. The playground is cute; the subject matter is not.

The rules of the world

Before we build, we fix the rules. They are the contract every brain must later obey:

  • Goal: ants find sugar and carry it to the nest.
  • Success metric: only what is delivered counts (delivered) - not what was found or picked up. We measure the result, not the intent.
  • Reflexes (happen automatically): picking up and dropping off trigger on contact. They are innate, not learned.
  • Decision (steerable): an ant decides its navigation - where it turns: ERKUNDE · ZUM_ZUCKER · FOLGE_SPUR · ZUM_BAU (explore, head to sugar, follow a trail, head to the nest - these are the literal constants from the code) - and whether it leaves a marker behind. What a marker can do gets its own chapter.
  • Perception: an ant does not see everything. It gets only a small, local slice of the world.

Why so few actions? The smaller the decision space, the easier it is for a brain to master - whether a fixed rule, a learning network or an LLM. Splitting the world into reflexes (automatic) and decision (steerable) is the single most important design choice in the whole world.

A model is not reality

A model is always a deliberate reduction. Our ants have no hunger, no enemies, no day-night cycle - not yet. Every omission is a choice, and that very reduction decides what an agent can even learn.

At its core every agent runs the same loop. Here as pseudocode - we build the real, runnable version in the next chapters:

while the world runs:
    perception = world.show(actor)        # the reduced view
    action     = decide(perception)       # ← the swappable box
    world.apply(actor, action)            # changes the model

What we're up to

The plan is simple and powerful at once: one world into which we drop four different brains, one after another - from fixed rules through a learning network to an LLM with memory. The world stays exactly the same every time. Only the decision box changes.

The world now stands as a model. Next we turn to the actor that thinks inside it.

→ Have a peek in the lab