So i created a guard creep;
Game.spawns.Spawn1.createCreep([Game.ATTACK, Game.ATTACK, Game.TOUGH, Game.TOUGH, Game.MOVE], "guard1", {role:"guard"});
and then i have this as my main:
var harvester = require('harvester');
var guard = require('guard');
for(var nam in Game.creeps) {
var creep = Game.creeps[nam];
if(creep.memory.role == 'guard') {
guard(creep);
}
if(creep.memory.role == 'harvester') {
harvester(creep);
}
if(creep.memory.role == 'builder') {
if(creep.energy === 0) {
creep.moveTo(Game.spawns.Spawn1);
Game.spawns.Spawn1.transferEnergy(creep);
}
else {
var targets = creep.room.find(Game.CONSTRUCTION_SITES);
if(targets.length) {
creep.moveTo(targets[0]);
creep.build(targets[0]);
}
}
}
}
And then the guard script
module.exports = function (creep) {
var targets = creep.room.find(Game.HOSTILE_CREEPS);
if(targets.length) {
creep.moveTo(targets[0]);
creep.attack(targets[0]);
}else{
creep.moveTo(Game.spawns.Spawn1);
}
}
It worked fine in the tutorial, but now in the actual simulation, it doesn't work.
I tested your scripts and they actually worked just fine on Survival Mode. What was the specific problem? Have you checked if you ran out of CPU Time?