Memory and Code StructureIntermediateReference
Resolve exact Flag names from Game.flags, validate flag.memory fields, recover configured targets by ID before a deterministic local fallback, and report missing or stale configuration without mutating Flags.
Memory and Code StructureIntermediateGuide
Keep one module.exports.loop, export small role functions, validate module shapes, read current Game objects inside each tick, avoid module-scope world snapshots, and preserve diagnostics for missing roles and load failures.
Memory and Code StructureIntermediateGuide
Learn why ordinary variables do not preserve Screeps state, how creep.memory maps to Memory.creeps, what data belongs in Memory, and why object IDs are safer than live game objects.
Memory and Code StructureIntermediateGuide
Build a stable two-phase working state from Store boundaries, keep the previous state at partial Energy, handle initialization and invalid capacity, and separate harvesting from Controller upgrading.
Memory and Code StructureIntermediateGuide
Store an object ID and room name, recover the current object every tick, distinguish missing vision from a destroyed target, validate the restored type, and define an explicit invalidation policy.
Memory and Code StructureIntermediateGuide
Compare Memory.creeps with Game.creeps, remove only confirmed dead-name entries, synchronize explicitly managed task indexes, summarize logs, and avoid TTL-based or global deletion mistakes.
Memory and Code StructureIntermediateGuide
Use the global object as a disposable runtime cache, rebuild after global resets, version and expire entries, cache IDs and derived data instead of live game objects, and return cloned values to prevent accidental mutation.
Memory and Code StructureIntermediateGuide
Validate segment IDs, activate one consolidated set for the next tick, distinguish unavailable from empty data, parse versioned string payloads safely, merge updates, and avoid multiple setActiveSegments calls overwriting each other.