summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Harley2018-06-26 16:31:58 +0100
committerTom Harley2018-06-26 16:31:58 +0100
commitb3f3642da68077660d8995d14fa907616839ea98 (patch)
tree0890a397d081b056f21fa93b4b3077c7b0f831e9 /src
parentChange builders to withdraw from spawner (diff)
downloadscreeps-ai-b3f3642da68077660d8995d14fa907616839ea98.tar.gz
screeps-ai-b3f3642da68077660d8995d14fa907616839ea98.zip

Track job counts per iteration

Diffstat (limited to 'src')
-rw-r--r--src/main.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/main.js b/src/main.js
index 458ab8e..7a3f1be 100644
--- a/src/main.js
+++ b/src/main.js
@@ -7,20 +7,21 @@ const jobs = {
};
module.exports.loop = () => {
- for (const name in Game.spawns) {
- jobs.spawner.run(Game.spawns[name]);
+ for (const job in Memory.counts) {
+ Memory.counts[job] = 0;
}
for (const name in Game.creeps) {
const creep = Game.creeps[name];
const job = jobs[creep.memory.job];
+ Memory.counts[job]++;
if (job) {
job.run(creep);
} else {
console.log(creep.name + " is missing instructions for job "
+ creep.memory.job);
}
- if (creep.ticksToLive == 1) {
- Memory.counts[creep.memory.job]--;
- }
+ }
+ for (const name in Game.spawns) {
+ jobs.spawner.run(Game.spawns[name]);
}
};