Differential D4343 Diff 19161 ps/trunk/binaries/data/mods/public/simulation/ai/petra/queueManager.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/ai/petra/queueManager.js
Show First 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | PETRA.QueueManager.prototype.wantedGatherRates = function(gameState) | ||||
return rates; | return rates; | ||||
}; | }; | ||||
PETRA.QueueManager.prototype.printQueues = function(gameState) | PETRA.QueueManager.prototype.printQueues = function(gameState) | ||||
{ | { | ||||
let numWorkers = 0; | let numWorkers = 0; | ||||
gameState.getOwnUnits().forEach(ent => { | gameState.getOwnUnits().forEach(ent => { | ||||
if (ent.getMetadata(PlayerID, "role") == "worker" && ent.getMetadata(PlayerID, "plan") === undefined) | if (ent.getMetadata(PlayerID, "role") === PETRA.Worker.ROLE_WORKER && ent.getMetadata(PlayerID, "plan") === undefined) | ||||
numWorkers++; | numWorkers++; | ||||
}); | }); | ||||
API3.warn("---------- QUEUES ------------ with pop " + gameState.getPopulation() + " and workers " + numWorkers); | API3.warn("---------- QUEUES ------------ with pop " + gameState.getPopulation() + " and workers " + numWorkers); | ||||
for (let i in this.queues) | for (let i in this.queues) | ||||
{ | { | ||||
let q = this.queues[i]; | let q = this.queues[i]; | ||||
if (q.hasQueuedUnits()) | if (q.hasQueuedUnits()) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | if (this.Config.debug > 1 && gameState.ai.playedTurn%50 === 0) | ||||
this.printQueues(gameState); | this.printQueues(gameState); | ||||
Engine.ProfileStop(); | Engine.ProfileStop(); | ||||
}; | }; | ||||
// Recovery system: if short of workers after an attack, pause (and reset) some queues to favor worker training | // Recovery system: if short of workers after an attack, pause (and reset) some queues to favor worker training | ||||
PETRA.QueueManager.prototype.checkPausedQueues = function(gameState) | PETRA.QueueManager.prototype.checkPausedQueues = function(gameState) | ||||
{ | { | ||||
let numWorkers = gameState.countOwnEntitiesAndQueuedWithRole("worker"); | const numWorkers = gameState.countOwnEntitiesAndQueuedWithRole(PETRA.Worker.ROLE_WORKER); | ||||
let workersMin = Math.min(Math.max(12, 24 * this.Config.popScaling), this.Config.Economy.popPhase2); | let workersMin = Math.min(Math.max(12, 24 * this.Config.popScaling), this.Config.Economy.popPhase2); | ||||
for (let q in this.queues) | for (let q in this.queues) | ||||
{ | { | ||||
let toBePaused = false; | let toBePaused = false; | ||||
if (!gameState.ai.HQ.hasPotentialBase()) | if (!gameState.ai.HQ.hasPotentialBase()) | ||||
toBePaused = q != "dock" && q != "civilCentre"; | toBePaused = q != "dock" && q != "civilCentre"; | ||||
else if (numWorkers < workersMin / 3) | else if (numWorkers < workersMin / 3) | ||||
toBePaused = q != "citizenSoldier" && q != "villager" && q != "emergency"; | toBePaused = q != "citizenSoldier" && q != "villager" && q != "emergency"; | ||||
▲ Show 20 Lines • Show All 170 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator