ScreepsAiSLP
Introducing ScreepsAiSLP: Screeps + AI Slop
The pitch
AI is cool, and it can do dope things.
Screeps is cool, and it can do dope things.
They can be cool and do dope things together.
So I present to you Screeps + AI Slop, also known as ScreepsAiSLP.
This is the first post of a new series. Before writing a single line of bot code, I want to explain two things: what Screeps actually is (especially the part where your code plays the game without you), and why I think having an AI agent autonomously write code for another autonomous AI is one of the coolest ideas.
The short version: in Screeps, the thing you build is already an AI. It's a program that runs 24/7, makes its own decisions and fights for survival with nobody at the controls. I want to hand the job of building that AI to another AI that also runs 24/7 with nobody at the controls. Two layers of autonomy, one human reviewing the commits.
The name is self-aware on purpose. "AI slop" is what people call low-effort machine-generated content, and some of what this agent writes will absolutely be slop. The fun part is building the guardrails, tests and feedback loops that turn slop into a colony that actually survives.
(The hardware side, a home server running a local coding model and a sandboxed agent, has its own four-part build series. You don't need it to follow this one.)
So what is Screeps?
Screeps ("scripting creeps") is a massively multiplayer real-time strategy game where you don't click on anything. You can't select a unit and tell it to go mine. Instead, you write JavaScript that the game server runs for you, all the time, whether you're logged in or asleep. Your code is your player.
The main game, Screeps: World, is one big persistent map shared by every player, split into shards (separate world servers) made of square rooms. The basic loop goes like this:
- You start with a spawn, a building that produces units called creeps.
- Creeps are built from body parts:
WORKto harvest and build,CARRYto haul,MOVEto walk, plusATTACK,RANGED_ATTACK,HEAL,CLAIMandTOUGHfor fighting and expanding. More parts mean a more capable creep and a higher energy cost. - Creeps harvest energy from sources in the room, carry it back to the spawn to build more creeps, and feed it into the room's controller.
- Upgrading the controller raises your Room Controller Level (RCL, 1 to 8), which unlocks extensions, towers, storage, links, labs and more.
- Your Global Control Level (GCL) grows across your whole empire and decides how many rooms you can claim.
- Creeps die of old age after 1,500 ticks, so your code has to keep replacing them forever.
(There's also Screeps: Arena, a separate match-based spin-off. This series is about World.)
The fully autonomous part
This is what makes Screeps different from every other strategy game, and it's the heart of this project.
In a normal RTS you're the brain. You see an attack coming, you pull your workers back, you build a tower. In Screeps you are not there. The server runs your code every tick, around the clock, on a shared world alongside everyone else's code, and it never waits for you. Close the browser, go to sleep, go on vacation: your colony keeps harvesting, building, expanding and defending exactly as well as your code tells it to. No better.
That means everything a human player would normally handle has to be written down as logic ahead of time:
- Economy: how many harvesters, haulers and upgraders to keep alive, and what to do when energy runs low.
- Construction: where to place extensions, roads and towers as the room levels up.
- Defense: detecting hostile creeps, firing towers, spawning defenders and triggering safe mode as a last resort.
- Expansion: scouting nearby rooms, deciding which one to claim and bootstrapping a new colony from scratch.
- Recovery: if everything dies, getting back from zero without a human noticing.
Put all of that together and what you've written isn't really "a script" anymore. It's an autonomous agent: something that observes its environment every tick, makes decisions and acts, with nobody supervising. The Screeps community even calls a full codebase "a bot" or "an AI." Your score in Screeps is basically a measure of how good an AI you wrote.
Then there are the neighbors. Other players' bots are on the same map, expanding, trading on the market and sometimes sending armies at you. You don't get to react in real time. Your defense is whatever your code was already going to do.
It's basically a programming job where the boss is a server that never stops, the coworkers are trying to kill you, and the performance review happens every tick.
How it works under the hood
This is the part that makes Screeps a real engineering problem rather than a cute game.
The tick
The world moves in discrete steps called ticks. Each tick, the server calls one function you export from main.js, your code looks at the world and issues orders, and then the server applies everyone's orders at once. On the public shards a tick takes a few seconds, so the world never pauses and neither does your code.
module.exports.loop = function () {
for (const name in Game.creeps) {
const creep = Game.creeps[name];
if (creep.store.getFreeCapacity() > 0) {
const source = creep.pos.findClosestByPath(FIND_SOURCES);
if (creep.harvest(source) === ERR_NOT_IN_RANGE) creep.moveTo(source);
} else {
const spawn = Game.spawns['Spawn1'];
if (creep.transfer(spawn, RESOURCE_ENERGY) === ERR_NOT_IN_RANGE) creep.moveTo(spawn);
}
}
};That's a complete, working (if very dumb) harvester bot. Every Screeps codebase starts something like this and grows into a few thousand lines of state machines, task queues and caching.
CPU: the real resource
Your code gets a CPU limit, measured in milliseconds of run time per tick. Go over and your script is killed mid-tick. On the main shards everyone starts at 20 CPU. With a subscription or CPU unlock it becomes 10 CPU per GCL level, up to 300.
Unused CPU isn't wasted. It goes into a bucket that holds up to 10,000 CPU, and a single tick can draw up to 500 CPU from it. So the bucket covers short bursts (a big pathfinding job, a fight) as long as your average stays under the limit. A bucket that keeps draining is the Screeps equivalent of a memory leak alarm.
CPU is spent in two ways:
- Your own JavaScript: loops,
find()calls and especially pathfinding. - Intents: every action that changes the world (
harvest,move,transferand so on) costs a flat 0.2 CPU. A hundred creeps each doing one thing per tick is 20 CPU before your logic even runs.
Memory
Memory is a global object that persists between ticks, your bot's long-term storage, capped at 2 MB. The catch is that it's stored as a JSON string. The first time you touch Memory in a tick, the whole thing gets JSON.parsed, and at the end of the tick it gets JSON.stringifyed back, and both cost CPU. A bloated Memory slowly eats your CPU budget, so good bots keep it lean and cache everything else in the global heap (plain JavaScript variables that survive between ticks until the server resets your environment, which it does without warning).
The API
Everything goes through the game's API: Game (your creeps, rooms, structures, CPU info), Room.find(), PathFinder, the market and so on. Methods return status codes like OK or ERR_NOT_IN_RANGE instead of throwing, so handling return values properly is half the job. (ERR_NOT_IN_RANGE → move closer is the most common line in all of Screeps.)
So: a hard real-time budget, a persistent world, a weird memory model and an API with lots of edge cases. Sounds like exactly the kind of thing a model trained on a lot of code should be good at, and also exactly the kind of thing it'll confidently get wrong.
An AI that writes an AI
So here's the idea that got me excited enough to build a GPU server for it.
The Screeps bot is an autonomous AI: it runs every tick, makes decisions and keeps the colony alive without me. Normally a human writes that AI by reading logs, spotting what went wrong, changing the code and redeploying, over and over for months.
What if that human loop were also autonomous? An AI coding agent, running unattended on my own hardware, whose whole job is to improve the Screeps AI:
- Read the bot's code and the latest stats from the game server.
- Pick something to improve: a hauler that wastes trips, a tower that ignores healers, a bucket that keeps draining.
- Write the change, build it and run it on a test server.
- Check the numbers. If the colony is better off, commit. If not, try again or back off.
- Repeat. Forever.
That's an AI writing an AI, with both running around the clock. The inner AI plays the game in real time; the outer AI rewrites the inner one over hours and days. I sit at the top as reviewer, reading commit logs over coffee and stepping in when the slop gets out of hand.
Why I think that's genuinely cool, and not just a gimmick:
- It's a closed loop with a real scoreboard. Most "AI writes code" demos end at "it compiled." Here the code has to survive in a hostile, persistent world, and CPU per tick, bucket level, RCL progress, energy harvested and creeps lost are all hard numbers. "Did the agent make it better?" gets answered with data, not vibes.
- It's all code, all the way down. There's no aiming and no reflexes. Everything the game needs from you is text in a Git repo, which is exactly what a coding agent produces.
- It never ends. A Screeps bot is never finished, so an agent that can work for hours unattended has an endless backlog.
- Failure is cheap. On a private server a bad commit costs a few simulated ticks and a
git revert, not a wrecked live colony. - It runs locally. The model lives on my own GPUs, so letting it grind all night costs electricity, not API bills.
- It's a miniature of where software is heading. Agents that maintain other autonomous systems, with humans reviewing instead of typing, are coming whether we're ready or not. Screeps is a safe, fun sandbox to find out what actually works.
And here's where the slop comes in. A language model will happily write code that:
- calls
PathFinderfor every creep every tick and drains the bucket in an hour, - stuffs whole objects into
Memoryuntil serialization eats a third of the CPU, - uses APIs that don't exist, or real ones with the wrong arguments,
- passes a lint check while the colony quietly starves.
It looks plausible, it might even run, and it's still slop. From building the agent setup, I already know that a local model follows numbered, mandatory checklists much better than general advice, and that the checks that really matter have to be enforced outside the model. ScreepsAiSLP is that lesson applied to a game: precise rules, a way for the agent to test its own work, and no commit that hasn't proven itself on a server first.
The ScreepsAiSLP plan
Here's the roadmap. Some of it is decided, and some of it is still on the whiteboard.
- A private Screeps server. The game server is open source, so you can run your own world. On a private server I control the tick rate, so the agent can test a change over thousands of ticks in minutes instead of days. Community tools like
screeps-launcherand various Docker images make setup easier. Where it runs (the AI server or another box) is still to be decided. - A project repo for the agent. It lives in the agent's sandboxed account (a separate Linux user with no admin rights), with Screeps type definitions so the model (and the editor) knows the real API instead of guessing. JavaScript vs. TypeScript is still open. TypeScript catches a whole class of slop at compile time, at the cost of a build step.
- A check step the agent runs before every commit. Build, lint, and ideally run the code on the private server and confirm it's alive. That makes "done and verified" something the agent can actually check.
- Safe uploads. Code gets pushed to the server with an auth token that the agent can never read or commit. The rule is simple: no secrets within the agent's reach.
- Screeps rules for the agent. Numbered, mandatory checklists covering the tick model, CPU budget and bucket,
Memoryhygiene, API conventions and exactly what counts as finished. This is where most of the anti-slop work happens. - Later: scheduled runs. The agent picks up tasks on a schedule and I review its commits over coffee.
The end goal: a colony on a private server, grown mostly by an AI agent running on my own hardware, with me acting as reviewer and occasional cleanup crew. Maybe someday it graduates to the public shards. Maybe it gets wiped out by the first player who notices it. Either way, it'll probably be a little interesting.
Next time: standing up the private server and giving the agent its first Screeps task. Let the slop begin.