Part 10 of 10All parts →Screeps + AI Slop

ScreepsAiSLP Build Log – Part 10: How Everything Works Now

The whole system redrawn after Parts 8 and 9: eight files in, one work loop, three ways back, one run from start to finish, and what changed since the start.

6 min readBuild log#ai#screeps

Why a new map

Part 6 drew the whole system on one page: six files, one work loop, two ways back. Since then, a friend's rules, a scorecard and a night of watching the agent (Parts 8 and 9) have changed a lot of it. New files, a third way back, a launcher that's three versions smarter.

So here's the map again, as it works today. If you only read one post to understand this project, read this one.

The big picture

the whole system today · 8 files in, 1 work loop, 3 ways back
the whole system today · 8 files in, 1 work loop, 3 ways back

Read it top to bottom. At the start of a run, the agent reads the eight files in the top box. The purple ones are mine, and the agent can read them but not change them. The blue ones are written automatically. Then the work loop runs, the gate decides what happens to the work, and the dashed line carries three things back into the next run: the gate's result, the scorecard's numbers, and my feedback.

Compared with Part 6, three things are new: the milestone spec, the scorecard, and the fact that FEEDBACK.md is now live and read first.

The files that steer the agent

The agent has no chat window and no memory between runs. Everything it knows at the start of a run comes from these files:

FileWhat it doesWho writes itWhere it lives
Standing taskWhat every run works on, in which order, and when it may stopMeA protected system folder
Rules 01 to 07Scope, code style, honesty, the Screeps economy playbook (02b) and the run checklist (07)MeIn the project, rules folder
Milestone specGoal, design notes, criteria and which scorecard lines to watchMeProtected copy, restored every run
Acceptance testsWhat "done" means, checked by a real game engineMeProtected copy, restored every run
FEEDBACK.mdMy plain-language hints; the agent must answer each itemMeA protected system folder
status.mdThe agent's own notes, roadmap and change logThe agentIn the project
LAST_GATE.mdWhat passed and failed at the end of the previous runThe launcherIn the project, not on GitHub
Scorecard reportsThe colony's numbers from the last test, next to the run beforeThe testsIn the project; summaries go to GitHub

The rule of thumb: anything that decides what counts as good is mine and protected. Anything that describes what happened is written automatically. The agent only owns its notes and its code.

One run, start to finish

The launcher is a small script that owns every run. The agent can run it but not change it. Here's what it does, in order:

  1. Start. A timer starts a run 15 minutes after the previous one ended. A lock makes sure there's never more than one.
  2. Fill in the task. It writes the date and the run number into the standing task.
  3. Put back the protected files. Acceptance tests, the test helper, the scorecard and the milestone specs are copied from the protected originals.
  4. Let the agent work, in rounds. Four hours is a deadline for the whole run. If the agent stops on its own with more than 45 minutes left and no milestone ticked off, it gets started again with a "continue where you stopped" note, up to six rounds.
  5. Stop everything else. Anything of the agent's that the launcher didn't start itself gets stopped: background workers, test runs, test servers. This is the ghost fix from Part 9.
  6. Put back the protected files again, so nothing the agent changed in them counts.
  7. Fresh packages. The installed packages are replaced with a clean, protected copy. Nothing is downloaded.
  8. Safety net. Anything the agent forgot to commit is committed.
  9. The gate. Lint, then all tests: unit tests first, then every integration test (M1, M2, M3 and the smoke test). The test runner stops at the first failure.
  10. Push, only if everything passed. The commits go to the separate push account, which runs its five checks and pushes to GitHub.
  11. Write LAST_GATE.md for the next run, pass or fail.

The firewall from Part 4 is on the whole time: the agent's user can only talk to the AI model on the same machine, nothing else.

The tests now

Every integration test still does what Part 3 described: build the bot, start a real game engine with a tiny world, run ticks, check the result. What's new is the last box.

inside one test today · build, start, run, check, scorecard
inside one test today · build, start, run, check, scorecard

On every tick, the scorecard asks the game what happened, and at the end it writes a report next to the previous run's numbers. The agent reads that report at the start of its next run as its baseline.

There are five kinds of tests, from quick to slow:

TestLengthWhen it runsWhat it checks
Unit testsSecondsAfter every change, and in the gateSingle functions, with fake game objects
Smoke test500 ticks, about 2 minutesAfter every change, and in the gateThe colony is alive, harvesting and error-free; prints the scorecard
M1 acceptance800 ticks, a few minutesIn the gateCore economy, and no harvester ever freezes
M2 acceptance3,000 ticks, about 15 minutesIn the gateExtensions and roads
M3 acceptance4,000 ticks, about 20 to 25 minutesWhen the agent thinks M3 is done, and in the gateBuild priorities, layout, a filled tower

Old milestone tests never retire. They keep running in every gate, so a new feature can't quietly break an old one. That already happened twice this week.

What changed since the start

At the start (Parts 1 to 3)Now
How a run startsI typed a task by handA timer starts a run 15 minutes after the last one ends, with a standing task and a run checklist
What "done" meansUnit tests and a first integration testA protected acceptance test and a written spec for every milestone
What "better" meansNothing, only pass or failA scorecard on every test, compared with the run before, plus a history file
How I talk to the agentEditing its rulesFEEDBACK.md, which it must answer item by item
Screeps knowledgeThe model, a short rules file, online docsThe model, the rules, an economy playbook, and the type definitions; no internet at all
Getting code to GitHubA separate push account with checksThe same, but only after a full test gate passes
How long a run lastsUp to 4 hours, or until the agent says it's doneA 4-hour deadline; quitting early means being started again
Leftovers after a runNothing cleaned upEverything the launcher didn't start is stopped before the gate
MilestonesM1 just startingM1 and M2 done (v0.1 and v0.2), M3 in progress

What's next

  • Finish M3. The layout and priorities pass; the tower needs to be filled. That's an economy problem: the colony harvests about 3 energy per tick out of a possible 20.
  • M4: containers and static mining. The test is already written, and it's the obvious answer to that economy problem.
  • Live numbers from the real game. The scorecard only sees test worlds. The plan is a small dashboard of my real colony, with a summary the agent can read too.
  • Calmer schedule. Back-to-back runs are for debugging. When things are stable, it goes back to one run every six hours.

The system is bigger than it was in Part 6, but the idea hasn't changed: the agent works inside walls I built, against tests I wrote, and everything it knows is written down in files. What's new is that it now gets a number for "better", not just a yes or no.

Questions, or did I get something wrong?herrera9604@gmail.com