Screeps AI: First Rewrite and Moving to TypeScript
- #1Screeps: An MMO for Programmers
- #2Screeps AI: First Rewrite and Moving to TypeScript Current
- #3Screeps AI: Building an Operating System
- #4Screeps AI: State of the World at the Beginning of 2023
Table of Contents (5 sections)
This is the second part of my journey in Screeps. In the first post, I discussed how building the bot in vanilla JavaScript made large refactors error-prone. The goal was to migrate to TypeScript and build a scalable architecture.
Getting the tooling and type definitions dialed in took some initial effort. The screeps-typescript-starter repository provided an excellent baseline for configuring the build pipeline.
Design of the AI
At the foundation of the AI is a hierarchical Manager architecture that coordinates tasks across the empire:
- Room Managers: Responsible for high-level room economics, controller levels, and construction.
- Worker Managers: Supervise creep behavior, assignment queues, and task dispatching.
- Building Managers: Coordinate infrastructure planning, road placement, and extensions.
Creep Specialization
- Harvester: Dedicated to harvesting energy from sources and depositing into spawns and extensions.
- Upgrader: Focuses exclusively on upgrading the Room Controller (RCL).
- Builder: Constructs placed sites and repairs damaged structures.
- Continuous Harvester: Static mining creeps equipped with maximum
WORKparts positioned permanently on energy nodes.
Current AI Features
The bot automatically progresses to RCL 2, constructs 5 extensions, and builds paved roads connecting the spawn to energy sources. Higher-level structures are currently placed manually, with the AI automatically assigning builders to construct them.
Defense
Basic defensive routines are in place. Once a tower is erected, the AI automatically targets hostile creeps spawned by NPC invaders.
Future Plans
The next milestones include automating extension placement at RCL 3 and introducing container-based mining for enhanced energy efficiency.
Discussion & Comments
Join the conversation
Share thoughts, ask questions, or discuss technical insights. No account required.