We’re excited to announce the release of Screeps GPT version 0.151.1, a focused bug fix release that resolves a critical issue affecting claimer creeps during room expansion operations.
Overview
This release addresses a pathfinding edge case where claimer creeps would get stuck in an infinite loop when entering their target room. The bot would successfully guide claimers to the target room, but upon arrival at the room boundary, the pathfinding logic would inadvertently route them back through the exit they just entered—creating a frustrating back-and-forth cycle that prevented successful room claiming.
The Problem: Claimer Room Cycling
When a claimer creep enters a target room at an edge position (x or y coordinate of 0 or 49), the pathfinding system would calculate the optimal path to the controller. However, due to the creep’s position at the room boundary, this calculated path would sometimes lead back through the exit the creep had just traversed. This created an infinite cycle:
- Creep enters target room at edge position (e.g., x=0, y=25)
- Pathfinding calculates route to controller
- Path leads back through the entry point (x=0)
- Creep exits room, re-enters, repeats indefinitely
This behavior completely blocked room expansion, as claimers could never reach the controller to establish control. The issue was particularly insidious because it only manifested at room boundaries—a claimer entering through the middle of a room edge would work fine, but one entering at a corner or specific edge position would cycle forever.
The Solution: Center-Then-Claim Strategy
The fix implements a two-phase approach that ensures claimers are well inside the target room before attempting to path to the controller:
Phase 1: Move to Room Center
When a claimer enters the target room at an edge position, it now moves toward the room center (coordinates 25, 25) before attempting to claim. This ensures the creep has a stable interior position that won’t be affected by boundary pathfinding edge cases.
Phase 2: Proceed to Controller
Once the creep has reached a safe interior position (not on coordinates 0 or 49), normal pathfinding to the controller resumes. At this point, the calculated path is guaranteed to be entirely within the room, eliminating the cycling behavior.
Implementation Details
The fix is implemented in the claimer role logic within packages/bot/src/runtime/behavior/roles/ClaimerRole.ts. The key changes include:
- Edge Position Detection: Check if creep x or y coordinate equals 0 or 49
- Center Movement Priority: When at edge, prioritize moving to room center over claiming
- Safe Position Validation: Only attempt claiming when in a stable interior position
- Visual Feedback: Room visuals indicate when claimers are in “edge safety” mode
This approach is elegant because it requires no changes to the pathfinding system itself—it simply ensures claimers are always in a position where pathfinding will work correctly.
Why This Approach?
We considered several alternative solutions:
Alternative 1: Pathfinding Blacklist
Add recent exit positions to a pathfinding blacklist to prevent immediate backtracking. This would work but adds complexity to the pathfinding system and requires managing state across ticks.
Alternative 2: Exit Memory
Track which exit the creep entered through and avoid pathing toward it. This requires additional memory structures and doesn’t handle all edge cases (what if the optimal path genuinely goes back through that exit for a different reason?).
Alternative 3: Boundary Buffer Zone
Expand the “unsafe” zone from just coordinate 0/49 to coordinates 0-5 and 44-49. This would work but wastes ticks moving unnecessarily far from edges when not needed.
We chose the center-then-claim strategy because:
- Minimal Complexity: No pathfinding system changes required
- Guaranteed Safety: Moving to center eliminates all boundary edge cases
- Clean Separation: Edge handling is localized to the claimer role
- Transparent Behavior: Visual feedback makes the behavior easy to understand and debug
- No State Management: No need to track exit history or maintain blacklists
Testing and Regression Prevention
To ensure this bug never recurs, we’ve added comprehensive regression test coverage in tests/regression/claimer-edge-position-cycling.test.ts:
- All Edge Positions: Tests verify correct behavior at all four room edges (x=0, x=49, y=0, y=49)
- Corner Cases: Validates behavior at all four corners where two edges meet
- Interior Positions: Confirms normal claiming behavior when not at edges
- Multi-Tick Sequences: Validates the entire move-to-center-then-claim flow
These tests use a mockup Screeps environment to simulate the exact conditions that trigger the bug, ensuring we can detect any future regressions before they reach production.
Impact on Bot Strategy
This fix has significant implications for the bot’s expansion strategy:
Before: Room expansion was unreliable. Claimers might successfully claim rooms or might get stuck cycling at boundaries, with no predictable pattern. Manual intervention was occasionally required to unstick claimers.
After: Room expansion is now completely reliable. Claimers will consistently reach and claim their target rooms, regardless of entry position. The bot can confidently pursue multi-room expansion strategies.
The performance impact is negligible—claimers spend a few extra ticks moving to room center, but this is insignificant compared to the travel time to reach the target room in the first place. The reliability improvement far outweighs the minor efficiency cost.
What’s Next
With room expansion now stable, we can focus on higher-level strategic improvements:
- Multi-Room Coordination: Now that expansion is reliable, we can implement more sophisticated colony coordination strategies
- Remote Harvesting: Stable claimers enable confident remote mining operations
- Territory Defense: Reliable expansion supports defensive infrastructure planning
This release exemplifies our commitment to rock-solid foundational behaviors. Every creep role must work perfectly in all edge cases before we can build higher-level strategies on top of it.
For Developers
If you’re working on similar pathfinding issues in your own Screeps bot, consider this pattern:
1 | // Check if at room edge |
This simple pattern can prevent a whole class of boundary-related pathfinding issues.
Conclusion
Release 0.151.1 may be small in scope, but it’s significant in impact. By fixing this claimer cycling bug, we’ve made room expansion completely reliable—a critical foundation for the bot’s long-term strategic success.
The combination of targeted fix, comprehensive testing, and clear documentation ensures this issue stays fixed while providing a reusable pattern for handling similar boundary conditions in other creep roles.
Thank you to the monitoring systems that detected this issue in PTR telemetry, and to the autonomous agent swarm for implementing and testing the fix!
Full Changelog: View on GitHub
Installation: Deploy via yarn deploy or automatic deployment on version tag push