Screeps: An MMO for Programmers
- #1Screeps: An MMO for Programmers Current
- #2Screeps AI: First Rewrite and Moving to TypeScript
- #3Screeps AI: Building an Operating System
- #4Screeps AI: State of the World at the Beginning of 2023
Table of Contents (2 sections)
Hello World! It has been a while.
I recently found out about Screeps, an MMO strategy game with a unique twist: players write real code to control their creeps, harvest energy, defend bases, and manage an empire. There is a hard CPU limit of 20ms to execute all logic on every tick, which means efficiency and algorithms play a crucial role. This post kicks off my journey building an autonomous Screeps AI.
Beginning Steps
The initial tutorial gets you familiar with basic mechanics quickly. However, once you enter the real game world, it becomes abundantly clear that there is a steep learning curve.
The official Discord community is extremely helpful. Building my first rudimentary bot proved to be a slow and steady learning process.
Familiarizing with the API and Basic Tasks
The first iteration of the bot was a simple extension of the tutorial. It featured a generic worker creep that acted as a jack of all trades—harvesting energy, hauling it to the spawn, and upgrading structures. While quick to build, this approach quickly hits scaling bottlenecks. Specializing creep roles became the obvious next step.
While the bot functioned decently, raw JavaScript can be error-prone when refactoring. Furthermore, having no local execution harness without uploading code made catching edge-case bugs tedious.
To build a more resilient system, I decided to rewrite the codebase in TypeScript to take advantage of static typing and modern design patterns.
The initial code checkpoint can be found on GitHub here.
Discussion & Comments
Join the conversation
Share thoughts, ask questions, or discuss technical insights. No account required.