Part 1 of the series Building a Screeps AI.
I wanted to learn JavaScript. What I ended up with is an empire of more than 500 small robots that runs day and night without me, trades on a market, builds its own cities and occasionally goes to war.
This is the first part of a series about that journey. It is less about clever algorithms (those come later) and more about the question every side project has to answer at some point: why on earth am I doing this?
What is Screeps?
Imagine a real-time strategy game in which you never click a unit. Instead you write code, upload it, and the game server runs it for you — every single game tick, around the clock, against other players who do exactly the same.
That is Screeps. A few core ideas are enough to follow the rest of the series (the official documentation has the full picture):

- The world is a huge grid of rooms. Each room is a 50 × 50 tile map with energy sources, sometimes a mineral, and a controller you can claim.
- Creeps are your units. You design their bodies from parts (work, carry, move, attack, heal …), spawn them, and they die of old age after roughly 1500 ticks. Nothing lives forever — everything has to be replaced.
- A tick is one game step. Each tick the server calls your code once. Whatever your code decides in that moment is what happens.
- CPU is the real currency. Every player gets a fixed CPU budget per tick. Smart code does more with less; sloppy code hits the limit and simply stops thinking for a while.
- The controller level (RCL) of a room unlocks buildings, and your global control level (GCL) decides how many rooms you may own at all.
Quick glossary
- Tick: one game step; your code runs once per tick.
- Creep: a unit you design, spawn and program.
- Room: a 50 × 50 tile map; the world is a grid of them.
- Spawn: the building that produces creeps.
- Controller / RCL: the heart of an owned room; its level unlocks buildings.
- GCL: your global control level; it limits how many rooms you can own.
- CPU budget: the computing time you get per tick.
- Bucket: unused CPU that is saved up for busy ticks.
- Shard: one of several separate copies of the world map.
The twist is that you are never really “playing”. You are designing a system that plays. If it fails at 3 a.m., it fails alone.
Where this bot comes from

2018: one room and a lot of flags
I found Screeps in 2018, at a time when I knew very little JavaScript. My first attempts could barely build up a single room. Most of what happened was steered by hand: I placed coloured flags in the game, and the code reacted to them — “build here”, “attack there”, “claim this room”.
It worked, sort of. But it was a remote control, not an AI. The bot did what I told it; the moment I stopped watching, it stopped improving.
2021: the restart
In 2021 I came back with more experience from my day job as a developer, and I saw Screeps as the perfect place to try out things I could not easily try at work. TypeScript replaced plain JavaScript early on.
What kept me going was simple: the deeper I went, the more complex and interesting it became. Every solved problem revealed two new “construction sites”. Energy logistics led to remote mining, remote mining led to neighbours who did not like that, neighbours led to defence, defence led to CPU problems. The autumn of 2021 was the most intense phase of that first restart — November alone saw more than fifty commits.
The quiet years
Then life happened. A professional change and a personal reorientation, and between 2022 and 2025 again a lot going on at work and at home. The bot kept running in the background with only occasional touches. Screeps is forgiving in that way: a decent bot survives a long time on autopilot. It just doesn’t get any smarter.
2026: a proper engineering setup
The real comeback in 2026 had a lot to do with AI. With it I could finally set up what a project like this deserves: an automatic build pipeline, full CI/CD, linting, and an extensive test suite — almost entirely generated, and the code quality went up massively. For the first time the bot became something I could change confidently without breaking a live world that never pauses.
Since then the history looks very different: hundreds of commits per month, more than a thousand unit tests, a private test server as a laboratory, and features I would never have dared to ship before.
What the bot is supposed to do
Today the bot runs on the persistent main world with more than twenty rooms and over five hundred creeps. Its job, roughly from the bottom up:
- Keep every room economically stable — energy must flow, spawns must stay full, nothing may starve.
- Grow — raise new rooms quickly, mine neighbouring rooms, expand into new territory.
- Defend — towers, ramparts, defenders, and knowing when to avoid a room entirely.
- Scale — trade on the market, run labs and boosts, plan buildings, remember what it has learned.
Architecturally that maps onto four layers: a thin tick shell, an empire-level orchestrator, room systems, and unit behaviour. Part 2 of this series walks through a single tick from start to finish.

The rules I gave myself
Over the years a few principles turned out to matter more than any single feature:
- Autonomy first. The bot should claim, build, defend, trade and even fight without me. The 2018 flag remote control is the opposite of what I want today.
- Never fix the game by hand. If the bot is stuck because it believes something wrong about the world, I don’t correct its memory or plant a flag. I fix the code so it detects the situation itself. Manual fixes hide the bug.
- Measure before optimising. CPU is the scarcest resource; every new feature has to pay for itself, and the only way to know is to measure.
- Test first, document everything. Every change gets a test; every session gets written down. A live world forgives slow code, but not a broken economy.
The moments that keep me hooked
People sometimes ask what the highlight was. Honestly: all of them.
- My first room — watching the first spawn produce the first creep that actually did what I wrote.
- My first lost room — painful, and the best teacher this game has.
- The first autonomous expansion — the bot picked a room, sent a claimer and started building, without me.
- The first lab jobs — chemistry running in the background, boosts appearing in a terminal.
- The first market sales — my code trading with other players’ code, while I was asleep.
- Every reset — whether I got wiped out or gave up all my rooms myself. Each restart is a clean slate, and each one showed me which parts of the bot were really robust and which only worked because the world happened to be kind.
Where I want to go
My goal is a bot that can react to anything new that comes along — new neighbours, new threats, new game mechanics — without me stepping in. That means optimising again and again, so there is always CPU left for the next feature.
The next big step is to go beyond a single shard: a bot that is present on all shards of the world, purely through its own automatic expansion.
What you can expect from this series
Roughly in the order the bot grew up:
- How a tick is structured, and why the order of things matters.
- The task system that turns “something should be done” into “this creep does it”.
- Room planning, bunkers and extension crosses.
- Creep roles, body design and the energy logistics that keep everything alive.
- Remote mining, expansion, towers, ramparts and the minimum-cut trick for walls.
- Markets, terminals, labs and boosts — and the industrial features that weren’t worth it.
- CPU: profiling, a near-death spiral, and a bot that learned to throttle itself.
- The private server as a lab, and then warfare: scouting, squads, formations, sieges and strongholds.
- A season server, a loss, and peace.
- The “cycle room”: turning surplus energy into control level by claiming, maxing and releasing a room over and over.
- And finally: what I learned.
Next time: what actually happens inside a single tick?














