Advanced Screeps MMO bot development with semi-automated colony management, proper git workflow, code architecture patterns, and MCP integration for testing/deployment.
Advanced AI bot development for Screeps MMO with semi-automated colony management. Handles routine tasks automatically while requiring console commands for strategic decisions like colonization, combat, and resource management.
The codebase is organized into three main categories:
1. **Overloads** (`overloads_*.js`): Prototype extensions for game objects
2. **Definitions** (`definitions_*.js`): Global systems and logic
3. **Main Entry** (`main.js`): Game loop and module loading
**Never commit directly to master. Always use branch-and-PR workflow.**
1. **Create feature branch** from master
2. **Make changes** following code architecture patterns
3. **Commit** with conventional commit format: `type: description`
4. **Push** to remote feature branch
5. **Create Pull Request** targeting master
6. **Merge** after approval
Place in appropriate `overloads_*.js` file:
```javascript
// overloads_creep.js
Creep.prototype.myNewMethod = function() {
return this.property;
};
```
Place in appropriate `definitions_*.js` file:
```javascript
// definitions_my_system.js
global.MySystem = {
init: function() {
// Initialization
},
processRoom: function(room) {
// Processing logic
}
};
```
Add to `definitions_console_commands.js`:
```javascript
global.myCommand = function(params) {
console.log("Command executed");
};
// Update help system
global.help = function(category) {
if (category === "my_category") {
console.log("myCommand(param) - Description");
}
};
```
```javascript
// CORRECT - Safe with defaults
let value = _.get(Memory, ["rooms", roomName, "field"], defaultValue);
let controller = _.get(Game, ["rooms", roomName, "controller"]);
// INCORRECT - Can cause undefined errors
let value = Memory.rooms[roomName].field;
```
```javascript
// Create task
creep.memory.task = {
type: "withdraw",
target: targetId,
resource: "energy",
timer: 30
};
// Get task (returns task or null)
creep.memory.task = creep.getTask_Withdraw_Storage("energy", false);
// Task priority chain
creep.memory.task = creep.memory.task || creep.getTask_Boost();
creep.memory.task = creep.memory.task || creep.getTask_Withdraw_Storage("energy");
creep.memory.task = creep.memory.task || creep.getTask_Pickup();
// Run task
creep.runTask(creep);
```
```javascript
// Check before expensive operations
if (hasCPU()) {
// Expensive operation
}
// Pulse timing for periodic tasks
if (isPulse_Short()) {
// Frequent task
}
if (isPulse_Long()) {
// Infrequent task
}
```
```javascript
if (creep.memory.state == "refueling") {
if (_.sum(creep.carry) == creep.carryCapacity) {
creep.memory.state = "working";
delete creep.memory.task;
return;
}
// Refueling tasks
}
```
```javascript
// Always validate objects exist
let controller = _.get(Game, ["rooms", roomName, "controller"]);
if (!controller) return;
// Validate parameters
if (!roomName || !resource) {
console.log("Error: Missing parameters");
return;
}
// Use try-catch for risky operations
try {
// Risky operation
} catch (e) {
console.log("Error:", e.message);
}
```
```javascript
// Upload entire directory (PREFERRED)
mcp_screeps_upload_code({
mainJsPath: "/home/azcoigreach/repos/azc-screeps",
branch: "default"
});
```
```javascript
// Get console logs
mcp_screeps_get_console({ clearBuffer: false });
// Execute commands
mcp_screeps_execute_command({ command: "help()" });
mcp_screeps_execute_command({ command: "system_status()" });
// Check for errors
mcp_screeps_check_for_errors({});
// Troubleshoot
mcp_screeps_troubleshoot_bot({});
```
```javascript
// Get memory
mcp_screeps_get_memory({ path: "" }); // Full memory
mcp_screeps_get_memory({ path: "rooms.W1N1" }); // Specific path
// Set memory
mcp_screeps_set_memory({
path: "config.setting",
value: JSON.stringify(value)
});
```
```javascript
// Room information
mcp_screeps_get_room_terrain({ roomName: "W1N1", shard: "shard0" });
mcp_screeps_get_room_status({ roomName: "W1N1", shard: "shard0" });
mcp_screeps_get_room_objects({ roomName: "W1N1" });
// Performance analysis
mcp_screeps_analyze_performance({});
// User info
mcp_screeps_get_user_info({});
```
1. **Local Development**
- Edit files following architecture patterns
- Use appropriate coding patterns
- Add console commands to help system
2. **Upload to Screeps**
- Use `mcp_screeps_upload_code()` with directory path
3. **Verify Upload**
- Check console: `mcp_screeps_get_console()`
- Check errors: `mcp_screeps_check_for_errors()`
4. **Test Functionality**
- Execute test commands via MCP
- Test new console commands
5. **Profile Performance**
- Use `mcp_screeps_analyze_performance()`
- Or in-game profiler: `profiler.run(100)` then `profiler.analyze()`
1. **Body Config** (`definitions_creep_body.js`):
```javascript
global.body_types.myRole = function(level) {
// Return body parts array
};
```
2. **Role Behavior** (`definitions_creep_roles.js`):
```javascript
global.Creep_Roles.MyRole = function(creep) {
// Role logic
};
```
3. **Population** (`definitions_populations.js`):
```javascript
{
class: "myRole",
body: "myRole",
level: 5,
count: 2
}
```
1. Create `definitions_my_system.js`
2. Define global object with init/run methods
3. Add to `main.js` requires
4. Call in game loop
1. Edit `base_layouts/base_layouts.xlsx`
2. Export to CSV
3. Update `definitions_blueprint_layouts.js`
4. Test: `blueprint.set_layout(room, x, y, "layout")`
Always document:
Use section comments:
```javascript
/* ***********************************************************
* [sec##x] SECTION NAME
* *********************************************************** */
// Subsection: Purpose
// Implementation details
// Example usage:
// global.myFunction(param);
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/screeps-bot-development/raw