所以我一直在尝试这个自动生成小兵占总生存小兵的百分比。但是,当我运行它时,它只是继续产卵收割机,即使 console.log 返回预期结果,也完全忽略了条件。
现在我对出了什么问题一无所知
//creepManager.creations() == counts total creeps and spawns creeps in function of total
var spawnCreep = require('spawnCreep');
var counter = require('counter');
exports.creations=function(){
if( counter.guardCount()/counter.totalCount()<0.5 && counter.harvesterCount()>1){
spawnCreep.guard();
} else if (counter.harvesterCount()/counter.totalCount()<0.3){
spawnCreep.harvester();
} else if(counter.builderCount()/counter.totalCount()<0.2){
spawnCreep.builder();
} else {
spawnCreep.guard(); //default
}
}; // 5guards, 3harvesters, 2 builder per 10CREEPS`
(spawnCreep 是另一个跟踪爬行者如何建造的模块)