Petra: small fixes + reformat debug outputs
This was SVN commit r15540.
This commit is contained in:
parent
1d35d22a7b
commit
3782857333
@ -1,16 +1,25 @@
|
||||
var API3 = function(m)
|
||||
{
|
||||
|
||||
m.debug = function(output){
|
||||
if (m.DebugEnabled){
|
||||
if (typeof output === "string"){
|
||||
m.debug = function(output)
|
||||
{
|
||||
if (m.DebugEnabled)
|
||||
{
|
||||
if (typeof output === "string")
|
||||
warn(output);
|
||||
}else{
|
||||
else
|
||||
warn(uneval(output));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
m.warn = function(output)
|
||||
{
|
||||
if (typeof output === "string")
|
||||
warn("PlayerID " + PlayerID + " | " + output);
|
||||
else
|
||||
warn("PlayerID " + PlayerID + " | " + uneval(output));
|
||||
};
|
||||
|
||||
m.VectorDistance = function(a, b)
|
||||
{
|
||||
var dx = a[0] - b[0];
|
||||
|
@ -122,7 +122,7 @@ m.PetraBot.prototype.initPersonality = function()
|
||||
|
||||
if (this.Config.debug == 0)
|
||||
return;
|
||||
warn(" >>> Petra bot: personality = " + uneval(this.Config.personality));
|
||||
API3.warn(" >>> Petra bot: personality = " + uneval(this.Config.personality));
|
||||
};
|
||||
|
||||
/*m.PetraBot.prototype.Deserialize = function(data, sharedScript)
|
||||
@ -135,18 +135,5 @@ PetraBot.prototype.Serialize = function()
|
||||
return {};
|
||||
};*/
|
||||
|
||||
// For the moment we just use the debugging flag and the debugging function from the API.
|
||||
// Maybe it will make sense in the future to separate them.
|
||||
m.DebugEnabled = function()
|
||||
{
|
||||
return API3.DebugEnabled;
|
||||
}
|
||||
|
||||
m.debug = function(output)
|
||||
{
|
||||
API3.debug(output);
|
||||
}
|
||||
|
||||
|
||||
return m;
|
||||
}());
|
||||
|
@ -53,25 +53,25 @@ m.AttackManager.prototype.update = function(gameState, queues, events)
|
||||
if (this.Config.debug == 2 && gameState.ai.elapsedTime > this.debugTime + 60)
|
||||
{
|
||||
this.debugTime = gameState.ai.elapsedTime;
|
||||
warn(" upcoming attacks =================");
|
||||
API3.warn(" upcoming attacks =================");
|
||||
for (var attackType in this.upcomingAttacks)
|
||||
{
|
||||
for (var i = 0; i < this.upcomingAttacks[attackType].length; ++i)
|
||||
{
|
||||
var attack = this.upcomingAttacks[attackType][i];
|
||||
warn(" type " + attackType + " state " + attack.state + " paused " + attack.isPaused());
|
||||
API3.warn(" type " + attackType + " state " + attack.state);
|
||||
}
|
||||
}
|
||||
warn(" started attacks ==================");
|
||||
API3.warn(" started attacks ==================");
|
||||
for (var attackType in this.startedAttacks)
|
||||
{
|
||||
for (var i = 0; i < this.startedAttacks[attackType].length; ++i)
|
||||
{
|
||||
var attack = this.startedAttacks[attackType][i];
|
||||
warn(" type " + attackType + " state " + attack.state + " paused " + attack.isPaused());
|
||||
API3.warn(" type " + attackType + " state " + attack.state);
|
||||
}
|
||||
}
|
||||
warn(" ==================================");
|
||||
API3.warn(" ==================================");
|
||||
}
|
||||
|
||||
for (var attackType in this.upcomingAttacks)
|
||||
@ -94,9 +94,7 @@ m.AttackManager.prototype.update = function(gameState, queues, events)
|
||||
else if (updateStep === 0 || updateStep === 3)
|
||||
{
|
||||
if (this.Config.debug)
|
||||
warn("Attack Manager: " + attack.getType() + " plan " + attack.getName() + " aborted.");
|
||||
// if (updateStep === 3)
|
||||
// this.attackPlansEncounteredWater = true;
|
||||
API3.warn("Attack Manager: " + attack.getType() + " plan " + attack.getName() + " aborted.");
|
||||
attack.Abort(gameState, this);
|
||||
this.upcomingAttacks[attackType].splice(i--,1);
|
||||
}
|
||||
@ -117,7 +115,7 @@ m.AttackManager.prototype.update = function(gameState, queues, events)
|
||||
gameState.ai.chatTeam(chatText);
|
||||
|
||||
if (this.Config.debug)
|
||||
warn("Attack Manager: Starting " + attack.getType() + " plan " + attack.getName());
|
||||
API3.warn("Attack Manager: Starting " + attack.getType() + " plan " + attack.getName());
|
||||
this.startedAttacks[attackType].push(attack);
|
||||
}
|
||||
else
|
||||
@ -140,7 +138,7 @@ m.AttackManager.prototype.update = function(gameState, queues, events)
|
||||
gameState.ai.chatTeam(chatText);
|
||||
|
||||
if (this.Config.debug)
|
||||
warn("Attack Manager: Starting " + attack.getType() + " plan " + attack.getName());
|
||||
API3.warn("Attack Manager: Starting " + attack.getType() + " plan " + attack.getName());
|
||||
this.startedAttacks[attackType].push(attack);
|
||||
this.upcomingAttacks[attackType].splice(i--,1);
|
||||
}
|
||||
@ -160,7 +158,7 @@ m.AttackManager.prototype.update = function(gameState, queues, events)
|
||||
if (!remaining)
|
||||
{
|
||||
if (this.Config.debug > 0)
|
||||
warn("Military Manager: " + attack.getType() + " plan " + attack.getName() + " is finished with remaining " + remaining);
|
||||
API3.warn("Military Manager: " + attack.getType() + " plan " + attack.getName() + " is finished with remaining " + remaining);
|
||||
attack.Abort(gameState);
|
||||
this.startedAttacks[attackType].splice(i--,1);
|
||||
}
|
||||
@ -179,7 +177,7 @@ m.AttackManager.prototype.update = function(gameState, queues, events)
|
||||
if (!attackPlan.failed)
|
||||
{
|
||||
if (this.Config.debug > 0)
|
||||
warn("Headquarters: Rushing plan " + this.totalNumber + " with maxRushes " + this.maxRushes);
|
||||
API3.warn("Headquarters: Rushing plan " + this.totalNumber + " with maxRushes " + this.maxRushes);
|
||||
this.totalNumber++;
|
||||
this.upcomingAttacks["Rush"].push(attackPlan);
|
||||
}
|
||||
@ -204,7 +202,7 @@ m.AttackManager.prototype.update = function(gameState, queues, events)
|
||||
else
|
||||
{
|
||||
if (this.Config.debug > 0)
|
||||
warn("Military Manager: Creating the plan " + type + " " + this.totalNumber);
|
||||
API3.warn("Military Manager: Creating the plan " + type + " " + this.totalNumber);
|
||||
this.totalNumber++;
|
||||
this.upcomingAttacks[type].push(attackPlan);
|
||||
}
|
||||
@ -229,7 +227,7 @@ m.AttackManager.prototype.update = function(gameState, queues, events)
|
||||
if (!attackPlan.failed)
|
||||
{
|
||||
if (this.Config.debug > 0)
|
||||
warn("Headquarters: Raiding plan " + this.totalNumber);
|
||||
API3.warn("Headquarters: Raiding plan " + this.totalNumber);
|
||||
this.totalNumber++;
|
||||
this.upcomingAttacks["Raid"].push(attackPlan);
|
||||
}
|
||||
@ -238,7 +236,7 @@ m.AttackManager.prototype.update = function(gameState, queues, events)
|
||||
}
|
||||
};
|
||||
|
||||
m.AttackManager.prototype.pausePlan = function(gameState, planName)
|
||||
m.AttackManager.prototype.getPlan = function(planName)
|
||||
{
|
||||
for (var attackType in this.upcomingAttacks)
|
||||
{
|
||||
@ -246,45 +244,36 @@ m.AttackManager.prototype.pausePlan = function(gameState, planName)
|
||||
{
|
||||
var attack = this.upcomingAttacks[attackType][i];
|
||||
if (attack.getName() == planName)
|
||||
attack.setPaused(true);
|
||||
return attack;
|
||||
}
|
||||
}
|
||||
|
||||
for (var attackType in this.startedAttacks)
|
||||
{
|
||||
for (var i in this.startedAttacks[attackType])
|
||||
{
|
||||
var attack = this.startedAttacks[attackType][i];
|
||||
if (attack.getName() == planName)
|
||||
attack.setPaused(true);
|
||||
return attack;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
m.AttackManager.prototype.unpausePlan = function(gameState, planName)
|
||||
m.AttackManager.prototype.pausePlan = function(planName)
|
||||
{
|
||||
for (var attackType in this.upcomingAttacks)
|
||||
{
|
||||
for (var i in this.upcomingAttacks[attackType])
|
||||
{
|
||||
var attack = this.upcomingAttacks[attackType][i];
|
||||
if (attack.getName() == planName)
|
||||
attack.setPaused(false);
|
||||
}
|
||||
}
|
||||
|
||||
for (var attackType in this.startedAttacks)
|
||||
{
|
||||
for (var i in this.startedAttacks[attackType])
|
||||
{
|
||||
var attack = this.startedAttacks[attackType][i];
|
||||
if (attack.getName() == planName)
|
||||
attack.setPaused(false);
|
||||
}
|
||||
}
|
||||
var attack = this.getPlan(planName);
|
||||
if (attack)
|
||||
attack.setPaused(true);
|
||||
};
|
||||
|
||||
m.AttackManager.prototype.pauseAllPlans = function(gameState)
|
||||
m.AttackManager.prototype.unpausePlan = function(planName)
|
||||
{
|
||||
var attack = this.getPlan(planName);
|
||||
if (attack)
|
||||
attack.setPaused(falsee);
|
||||
};
|
||||
|
||||
m.AttackManager.prototype.pauseAllPlans = function()
|
||||
{
|
||||
for (var attackType in this.upcomingAttacks)
|
||||
for (var i in this.upcomingAttacks[attackType])
|
||||
@ -295,7 +284,7 @@ m.AttackManager.prototype.pauseAllPlans = function(gameState)
|
||||
this.startedAttacks[attackType][i].setPaused(true);
|
||||
};
|
||||
|
||||
m.AttackManager.prototype.unpauseAllPlans = function(gameState)
|
||||
m.AttackManager.prototype.unpauseAllPlans = function()
|
||||
{
|
||||
for (var attackType in this.upcomingAttacks)
|
||||
for (var i in this.upcomingAttacks[attackType])
|
||||
|
@ -370,7 +370,7 @@ m.AttackPlan.prototype.updatePreparation = function(gameState, events)
|
||||
// may-be all our previous enemey targets have been destroyed ?
|
||||
this.targetPlayer = this.getEnemyPlayer(gameState);
|
||||
if (this.Config.debug > 0)
|
||||
warn(" === no more target for enemy player " + oldTargetPlayer + " let us switch against player " + this.targetPlayer);
|
||||
API3.warn(" === no more target for enemy player " + oldTargetPlayer + " let us switch against player " + this.targetPlayer);
|
||||
this.target = this.getNearestTarget(gameState, this.rallyPoint);
|
||||
}
|
||||
if (!this.target)
|
||||
@ -456,11 +456,11 @@ m.AttackPlan.prototype.updatePreparation = function(gameState, events)
|
||||
if (this.Config.debug > 0)
|
||||
{
|
||||
var am = gameState.ai.HQ.attackManager;
|
||||
warn(" attacks upcoming: raid " + am.upcomingAttacks["Raid"].length
|
||||
API3.warn(" attacks upcoming: raid " + am.upcomingAttacks["Raid"].length
|
||||
+ " rush " + am.upcomingAttacks["Rush"].length
|
||||
+ " attack " + am.upcomingAttacks["Attack"].length
|
||||
+ " huge " + am.upcomingAttacks["HugeAttack"].length);
|
||||
warn(" attacks started: raid " + am.startedAttacks["Raid"].length
|
||||
API3.warn(" attacks started: raid " + am.startedAttacks["Raid"].length
|
||||
+ " rush " + am.startedAttacks["Rush"].length
|
||||
+ " attack " + am.startedAttacks["Attack"].length
|
||||
+ " huge " + am.startedAttacks["HugeAttack"].length);
|
||||
@ -550,8 +550,8 @@ m.AttackPlan.prototype.trainMoreUnits = function(gameState)
|
||||
|
||||
if (this.Config.debug > 0 && gameState.ai.playedTurn%50 === 0)
|
||||
{
|
||||
warn("====================================");
|
||||
warn("======== build order for plan " + this.name);
|
||||
API3.warn("====================================");
|
||||
API3.warn("======== build order for plan " + this.name);
|
||||
for (var order of this.buildOrder)
|
||||
{
|
||||
var specialData = "Plan_"+this.name+"_"+order[4];
|
||||
@ -559,10 +559,10 @@ m.AttackPlan.prototype.trainMoreUnits = function(gameState)
|
||||
var queue1 = this.queue.countQueuedUnitsWithMetadata("special", specialData);
|
||||
var queue2 = this.queueChamp.countQueuedUnitsWithMetadata("special", specialData);
|
||||
var queue3 = this.queueSiege.countQueuedUnitsWithMetadata("special", specialData);
|
||||
warn(" >>> " + order[4] + " done " + order[2].length + " training " + inTraining
|
||||
API3.warn(" >>> " + order[4] + " done " + order[2].length + " training " + inTraining
|
||||
+ " queue " + queue1 + " champ " + queue2 + " siege " + queue3 + " >> need " + order[3].targetSize);
|
||||
}
|
||||
warn("====================================");
|
||||
API3.warn("====================================");
|
||||
}
|
||||
|
||||
if (this.buildOrder[0][0] < this.buildOrder[0][3]["targetSize"])
|
||||
@ -583,14 +583,14 @@ m.AttackPlan.prototype.trainMoreUnits = function(gameState)
|
||||
if (template === undefined)
|
||||
{
|
||||
if (this.Config.debug > 0)
|
||||
warn("attack no template found " + this.buildOrder[0][1]);
|
||||
API3.warn("attack no template found " + this.buildOrder[0][1]);
|
||||
delete this.unitStat[this.buildOrder[0][4]]; // deleting the associated unitstat.
|
||||
this.buildOrder.splice(0,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.Config.debug > 1)
|
||||
warn("attack template " + template + " added for plan " + this.name);
|
||||
API3.warn("attack template " + template + " added for plan " + this.name);
|
||||
var max = this.buildOrder[0][3]["batchSize"];
|
||||
var specialData = "Plan_" + this.name + "_" + this.buildOrder[0][4];
|
||||
if (gameState.getTemplate(template).hasClass("CitizenSoldier"))
|
||||
@ -600,7 +600,7 @@ m.AttackPlan.prototype.trainMoreUnits = function(gameState)
|
||||
if (trainingPlan.template)
|
||||
queue.addItem(trainingPlan);
|
||||
else if (this.Config.debug > 0)
|
||||
warn("training plan canceled because no template for " + template + " build1 " + uneval(this.buildOrder[0][1])
|
||||
API3.warn("training plan canceled because no template for " + template + " build1 " + uneval(this.buildOrder[0][1])
|
||||
+ " build3 " + uneval(this.buildOrder[0][3]["interests"]));
|
||||
}
|
||||
}
|
||||
@ -886,7 +886,7 @@ m.AttackPlan.prototype.setRallyPoint = function(gameState)
|
||||
m.AttackPlan.prototype.StartAttack = function(gameState)
|
||||
{
|
||||
if (this.Config.debug)
|
||||
warn("start attack " + this.name + " with type " + this.type);
|
||||
API3.warn("start attack " + this.name + " with type " + this.type);
|
||||
|
||||
if (!this.target || !gameState.getEntityById(this.target.id())) // our target was destroyed during our preparation
|
||||
{
|
||||
@ -941,7 +941,7 @@ m.AttackPlan.prototype.StartAttack = function(gameState)
|
||||
if (!this.path[0][0][0] || !this.path[0][0][1])
|
||||
{
|
||||
if (this.Config.debug > 0)
|
||||
warn("StartAttack: Problem with path " + uneval(this.path));
|
||||
API3.warn("StartAttack: Problem with path " + uneval(this.path));
|
||||
return false;
|
||||
}
|
||||
this.state = "walking";
|
||||
@ -1076,7 +1076,7 @@ m.AttackPlan.prototype.update = function(gameState, events)
|
||||
if (this.lastPosition && API3.SquareVectorDistance(this.position, this.lastPosition) < 20 && this.path.length > 0)
|
||||
{
|
||||
if (!this.path[0][0][0] || !this.path[0][0][1])
|
||||
warn("Start: Problem with path " + uneval(this.path));
|
||||
API3.warn("Start: Problem with path " + uneval(this.path));
|
||||
// We're stuck, presumably. Check if there are no walls just close to us. If so, we're arrived, and we're gonna tear down some serious stone.
|
||||
var nexttoWalls = false;
|
||||
gameState.getEnemyEntities().filter(API3.Filters.byClass("StoneWall")).forEach( function (ent) {
|
||||
@ -1087,13 +1087,13 @@ m.AttackPlan.prototype.update = function(gameState, events)
|
||||
if (nexttoWalls && this.unitCollection.filter(API3.Filters.byCanAttack("StoneWall")).length !== 0)
|
||||
{
|
||||
if (this.Config.debug > 0)
|
||||
warn("Attack Plan " + this.type + " " + this.name + " has met walls and is not happy.");
|
||||
API3.warn("Attack Plan " + this.type + " " + this.name + " has met walls and is not happy.");
|
||||
this.state = "arrived";
|
||||
}
|
||||
else if (nexttoWalls) // abort plan
|
||||
{
|
||||
if (this.Config.debug > 0)
|
||||
warn("Attack Plan " + this.type + " " + this.name + " has met walls and gives up.");
|
||||
API3.warn("Attack Plan " + this.type + " " + this.name + " has met walls and gives up.");
|
||||
Engine.ProfileStop();
|
||||
return 0;
|
||||
}
|
||||
@ -1109,7 +1109,7 @@ m.AttackPlan.prototype.update = function(gameState, events)
|
||||
if (API3.SquareVectorDistance(this.position, this.targetPos) < 10000)
|
||||
{
|
||||
if (this.Config.debug > 0)
|
||||
warn("Attack Plan " + this.type + " " + this.name + " has arrived to destination.");
|
||||
API3.warn("Attack Plan " + this.type + " " + this.name + " has arrived to destination.");
|
||||
this.state = "arrived";
|
||||
}
|
||||
else if (this.path.length && API3.SquareVectorDistance(this.position, this.path[0][0]) < 1600)
|
||||
@ -1120,7 +1120,7 @@ m.AttackPlan.prototype.update = function(gameState, events)
|
||||
else
|
||||
{
|
||||
if (this.Config.debug > 0)
|
||||
warn("Attack Plan " + this.type + " " + this.name + " has arrived to destination.");
|
||||
API3.warn("Attack Plan " + this.type + " " + this.name + " has arrived to destination.");
|
||||
this.state = "arrived";
|
||||
}
|
||||
}
|
||||
@ -1377,12 +1377,12 @@ m.AttackPlan.prototype.update = function(gameState, events)
|
||||
if (!this.target || !gameState.getEntityById(this.target.id()))
|
||||
{
|
||||
if (this.Config.debug > 0)
|
||||
warn("Seems like our target has been destroyed. Switching.");
|
||||
API3.warn("Seems like our target has been destroyed. Switching.");
|
||||
this.target = this.getNearestTarget(gameState, this.position, true);
|
||||
if (!this.target)
|
||||
{
|
||||
if (this.Config.debug > 0)
|
||||
warn("No new target found. Remaining units " + this.unitCollection.length);
|
||||
API3.warn("No new target found. Remaining units " + this.unitCollection.length);
|
||||
Engine.ProfileStop();
|
||||
return false;
|
||||
}
|
||||
@ -1480,13 +1480,13 @@ m.AttackPlan.prototype.isSiegeUnit = function(gameState, ent)
|
||||
|
||||
m.AttackPlan.prototype.debugAttack = function()
|
||||
{
|
||||
warn("---------- attack " + this.name);
|
||||
API3.warn("---------- attack " + this.name);
|
||||
for (var unitCat in this.unitStat)
|
||||
{
|
||||
var Unit = this.unitStat[unitCat];
|
||||
warn(unitCat + " num=" + this.unit[unitCat].length + " min=" + Unit["minSize"] + " need=" + Unit["targetSize"]);
|
||||
API3.warn(unitCat + " num=" + this.unit[unitCat].length + " min=" + Unit["minSize"] + " need=" + Unit["targetSize"]);
|
||||
}
|
||||
warn("------------------------------");
|
||||
API3.warn("------------------------------");
|
||||
};
|
||||
|
||||
return m;
|
||||
|
@ -112,7 +112,7 @@ m.BaseManager.prototype.checkEvents = function (gameState, events, queues)
|
||||
// sounds like we lost our anchor. Let's try rebuilding it.
|
||||
// TODO: currently the HQ manager sets us as initgathering, we probably ouht to do it
|
||||
this.anchor = undefined;
|
||||
|
||||
|
||||
this.constructing = true; // let's switch mode.
|
||||
this.workers.forEach( function (worker) { worker.stopMoving(); });
|
||||
queues.civilCentre.addItem(new m.ConstructionPlan(gameState, gameState.ai.HQ.bBase[0], { "base": this.ID, "baseAnchor": true }, ent.position()));
|
||||
@ -816,10 +816,8 @@ m.BaseManager.prototype.assignToFoundations = function(gameState, noRepair)
|
||||
else if (noRepair && !target.hasClass("CivCentre"))
|
||||
continue;
|
||||
|
||||
if (gameState.ai.HQ.territoryMap.getOwner(target.position()) !== PlayerID ||
|
||||
((gameState.ai.HQ.territoryMap.getOwner([target.position()[0] + 10, target.position()[1]]) !== PlayerID) &&
|
||||
gameState.ai.HQ.territoryMap.getOwner([target.position()[0] - 10, target.position()[1]]) !== PlayerID))
|
||||
continue; // TODO find a better way to signal a decaying building
|
||||
if (target.decaying())
|
||||
continue;
|
||||
|
||||
var assigned = gameState.getOwnEntitiesByMetadata("target-foundation", target.id()).length;
|
||||
if (assigned < targetNB/3)
|
||||
|
@ -346,7 +346,7 @@ m.DefenseManager.prototype.checkEvents = function(gameState, events)
|
||||
if (target.hasClass("Ship")) // TODO integrate ships later need to be sure it is accessible
|
||||
continue;
|
||||
var attacker = gameState.getEntityById(evt.attacker);
|
||||
if (!attacker)
|
||||
if (!attacker || !attacker.position())
|
||||
continue;
|
||||
var attackTypes = target.attackTypes();
|
||||
if (!attackTypes || attackTypes.indexOf("Ranged") === -1)
|
||||
|
@ -93,10 +93,10 @@ m.HQ.prototype.init = function(gameState, queues)
|
||||
this.navalRegions.push(i);
|
||||
}
|
||||
}
|
||||
if (this.Config.debug > 0)
|
||||
if (this.Config.debug > 1)
|
||||
{
|
||||
for (var region in this.allowedRegions)
|
||||
warn(" >>> zone " + region + " taille " + gameState.ai.accessibility.regionSize[region]);
|
||||
API3.warn(" >>> zone " + region + " taille " + gameState.ai.accessibility.regionSize[region]);
|
||||
}
|
||||
|
||||
if (this.Config.difficulty === 0)
|
||||
@ -184,7 +184,7 @@ m.HQ.prototype.init = function(gameState, queues)
|
||||
}
|
||||
}
|
||||
if (this.Config.debug > 0)
|
||||
warn("starting size " + startingSize + "(cut at 1500 for fish pushing)");
|
||||
API3.warn("starting size " + startingSize + "(cut at 1500 for fish pushing)");
|
||||
if (startingSize < 1500)
|
||||
{
|
||||
this.Config.Economy.popForDock = Math.min(this.Config.Economy.popForDock, 16);
|
||||
@ -208,7 +208,7 @@ m.HQ.prototype.init = function(gameState, queues)
|
||||
}
|
||||
}
|
||||
if (this.Config.debug > 0)
|
||||
warn("startingWood: " + startingWood + "(cut at 8500 for no rush and 6000 for saveResources)");
|
||||
API3.warn("startingWood: " + startingWood + "(cut at 8500 for no rush and 6000 for saveResources)");
|
||||
if (startingWood < 6000)
|
||||
{
|
||||
this.saveResources = true;
|
||||
@ -253,9 +253,9 @@ m.HQ.prototype.getSeaIndex = function (gameState, index1, index2)
|
||||
{
|
||||
if (this.Config.debug > 0)
|
||||
{
|
||||
warn("bad path from " + index1 + " to " + index2 + " ??? " + uneval(path));
|
||||
warn(" regionLinks start " + uneval(gameState.ai.accessibility.regionLinks[index1]));
|
||||
warn(" regionLinks end " + uneval(gameState.ai.accessibility.regionLinks[index2]));
|
||||
API3.warn("bad path from " + index1 + " to " + index2 + " ??? " + uneval(path));
|
||||
API3.warn(" regionLinks start " + uneval(gameState.ai.accessibility.regionLinks[index1]));
|
||||
API3.warn(" regionLinks end " + uneval(gameState.ai.accessibility.regionLinks[index2]));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@ -294,7 +294,7 @@ m.HQ.prototype.checkEvents = function (gameState, events, queues)
|
||||
{
|
||||
var base = ent.getMetadata(PlayerID, "base");
|
||||
if (!base)
|
||||
warn("Petra: wonder founadtion without base ???");
|
||||
API3.warn("Petra: wonder foundation without base ???");
|
||||
// Let's get a few units out there to build this.
|
||||
var builders = this.bulkPickWorkers(gameState, base, 10);
|
||||
if (builders !== false)
|
||||
@ -375,7 +375,7 @@ m.HQ.prototype.checkEvents = function (gameState, events, queues)
|
||||
else if (ent.getMetadata(PlayerID, "garrisonType"))
|
||||
{
|
||||
// we were supposed to be autogarrisoned, but this has failed (may-be full)
|
||||
ent.getMetadata(PlayerID, "garrisonType", undefined);
|
||||
ent.setMetadata(PlayerID, "garrisonType", undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -773,7 +773,7 @@ m.HQ.prototype.findEconomicCCLocation = function(gameState, template, resource,
|
||||
if (fromStrategic) // be less restrictive
|
||||
cut = 30;
|
||||
if (this.Config.debug)
|
||||
warn("we have found a base for " + resource + " with best (cut=" + cut + ") = " + bestVal);
|
||||
API3.warn("we have found a base for " + resource + " with best (cut=" + cut + ") = " + bestVal);
|
||||
// not good enough.
|
||||
if (bestVal < cut)
|
||||
return false;
|
||||
@ -905,7 +905,7 @@ m.HQ.prototype.findStrategicCCLocation = function(gameState, template)
|
||||
}
|
||||
|
||||
if (this.Config.debug > 0)
|
||||
warn("We've found a strategic base with bestVal = " + bestVal);
|
||||
API3.warn("We've found a strategic base with bestVal = " + bestVal);
|
||||
|
||||
Engine.ProfileStop();
|
||||
|
||||
@ -990,14 +990,14 @@ m.HQ.prototype.findMarketLocation = function(gameState, template)
|
||||
}
|
||||
|
||||
if (this.Config.debug > 0)
|
||||
warn("We found a market position with bestVal = " + bestVal);
|
||||
API3.warn("We found a market position with bestVal = " + bestVal);
|
||||
|
||||
if (bestVal === undefined) // no constraints. For the time being, place it arbitrarily by the ConstructionPlan
|
||||
return [-1, -1, -1];
|
||||
|
||||
var expectedGain = Math.round(bestVal / this.Config.distUnitGain);
|
||||
if (this.Config.debug > 0)
|
||||
warn("this would give a trading gain of " + expectedGain);
|
||||
API3.warn("this would give a trading gain of " + expectedGain);
|
||||
// do not keep it if gain is too small, except if this is our first BarterMarket
|
||||
if (expectedGain < 6 && (!template.hasClass("BarterMarket") || gameState.getOwnStructures().filter(API3.Filters.byClass("BarterMarket")).length > 0))
|
||||
return false;
|
||||
@ -1205,7 +1205,7 @@ m.HQ.prototype.buildMoreHouses = function(gameState,queues)
|
||||
if (count < 5 && index !== -1)
|
||||
{
|
||||
if (this.Config.debug > 0)
|
||||
warn("no room to place a house ... try to be less restrictive");
|
||||
API3.warn("no room to place a house ... try to be less restrictive");
|
||||
this.stopBuilding.splice(index, 1);
|
||||
this.requireHouses = true;
|
||||
}
|
||||
@ -1238,7 +1238,7 @@ m.HQ.prototype.buildMoreHouses = function(gameState,queues)
|
||||
if (index !== -1)
|
||||
{
|
||||
if (this.Config.debug > 0)
|
||||
warn("no room to place a house ... try to improve with technology");
|
||||
API3.warn("no room to place a house ... try to improve with technology");
|
||||
this.researchManager.researchPopulationBonus(gameState, queues);
|
||||
}
|
||||
else if (index === -1)
|
||||
@ -1259,7 +1259,7 @@ m.HQ.prototype.checkBaseExpansion = function(gameState,queues)
|
||||
if (this.stopBuilding.length > 1)
|
||||
{
|
||||
if (this.Config.debug > 1)
|
||||
warn("try to build a new base because not enough room to build " + uneval(this.stopBuilding));
|
||||
API3.warn("try to build a new base because not enough room to build " + uneval(this.stopBuilding));
|
||||
this.buildNewBase(gameState, queues);
|
||||
return;
|
||||
}
|
||||
@ -1272,7 +1272,7 @@ m.HQ.prototype.checkBaseExpansion = function(gameState,queues)
|
||||
if (Math.floor(numUnits/popForBase) >= numCCs)
|
||||
{
|
||||
if (this.Config.debug > 1)
|
||||
warn("try to build a new base because of population " + numUnits + " for " + numCCs + " CCs");
|
||||
API3.warn("try to build a new base because of population " + numUnits + " for " + numCCs + " CCs");
|
||||
this.buildNewBase(gameState, queues);
|
||||
}
|
||||
};
|
||||
@ -1288,7 +1288,7 @@ m.HQ.prototype.buildNewBase = function(gameState, queues, type)
|
||||
|
||||
// base "-1" means new base.
|
||||
if (this.Config.debug > 0)
|
||||
warn("new base planned with type " + type);
|
||||
API3.warn("new base planned with type " + type);
|
||||
queues.civilCentre.addItem(new m.ConstructionPlan(gameState, this.bBase[0], { "base": -1, "type": type }));
|
||||
return true;
|
||||
};
|
||||
@ -1641,7 +1641,7 @@ m.HQ.prototype.updateTerritories = function(gameState)
|
||||
var index = this.baseManagers[baseID].territoryIndices.indexOf(j);
|
||||
if (index === -1)
|
||||
{
|
||||
warn(" problem in headquarters::updateTerritories for base " + baseID);
|
||||
API3.warn(" problem in headquarters::updateTerritories for base " + baseID);
|
||||
continue;
|
||||
}
|
||||
this.baseManagers[baseID].territoryIndices.splice(index, 1);
|
||||
@ -1770,16 +1770,16 @@ m.HQ.prototype.update = function(gameState, queues, events)
|
||||
}
|
||||
if (gameState.ai.playedTurn - ent.getMetadata(PlayerID, "idleTim") < 50)
|
||||
return;
|
||||
warn(" unit idle since " + (gameState.ai.playedTurn-ent.getMetadata(PlayerID, "idleTim")) + " turns");
|
||||
warn(" unitai state " + ent.unitAIState());
|
||||
warn(" >>> base " + ent.getMetadata(PlayerID, "base"));
|
||||
warn(" >>> role " + ent.getMetadata(PlayerID, "role"));
|
||||
warn(" >>> subrole " + ent.getMetadata(PlayerID, "subrole"));
|
||||
warn(" >>> gather-type " + ent.getMetadata(PlayerID, "gather-type"));
|
||||
warn(" >>> target-foundation " + ent.getMetadata(PlayerID, "target-foundation"));
|
||||
warn(" >>> PartOfArmy " + ent.getMetadata(PlayerID, "PartOfArmy"));
|
||||
warn(" >>> plan " + ent.getMetadata(PlayerID, "plan"));
|
||||
warn(" >>> transport " + ent.getMetadata(PlayerID, "transport"));
|
||||
API3.warn(" unit idle since " + (gameState.ai.playedTurn-ent.getMetadata(PlayerID, "idleTim")) + " turns");
|
||||
API3.warn(" unitai state " + ent.unitAIState());
|
||||
API3.warn(" >>> base " + ent.getMetadata(PlayerID, "base"));
|
||||
API3.warn(" >>> role " + ent.getMetadata(PlayerID, "role"));
|
||||
API3.warn(" >>> subrole " + ent.getMetadata(PlayerID, "subrole"));
|
||||
API3.warn(" >>> gather-type " + ent.getMetadata(PlayerID, "gather-type"));
|
||||
API3.warn(" >>> target-foundation " + ent.getMetadata(PlayerID, "target-foundation"));
|
||||
API3.warn(" >>> PartOfArmy " + ent.getMetadata(PlayerID, "PartOfArmy"));
|
||||
API3.warn(" >>> plan " + ent.getMetadata(PlayerID, "plan"));
|
||||
API3.warn(" >>> transport " + ent.getMetadata(PlayerID, "transport"));
|
||||
ent.setMetadata(PlayerID, "idleTim", gameState.ai.playedTurn);
|
||||
});
|
||||
}
|
||||
|
@ -171,10 +171,11 @@ m.QueueManager.prototype.printQueues = function(gameState)
|
||||
warn("Accounts");
|
||||
for (var p in this.accounts)
|
||||
warn(p + ": " + uneval(this.accounts[p]));
|
||||
warn("Current Resources:" + uneval(gameState.getResources()));
|
||||
warn("Available Resources:" + uneval(this.getAvailableResources(gameState)));
|
||||
warn("Wanted Gather Rates:" + uneval(this.wantedGatherRates(gameState)));
|
||||
warn("Current Gather Rates:" + uneval(gameState.ai.HQ.GetCurrentGatherRates(gameState)));
|
||||
warn("Current Resources: " + uneval(gameState.getResources()));
|
||||
warn("Available Resources: " + uneval(this.getAvailableResources(gameState)));
|
||||
warn("Wanted Gather Rates: " + uneval(this.wantedGatherRates(gameState)));
|
||||
warn("Current Gather Rates: " + uneval(gameState.ai.HQ.GetCurrentGatherRates(gameState)));
|
||||
warn("Most needed resources: " + uneval(gameState.ai.HQ.pickMostNeededResources(gameState)));
|
||||
warn("------------------------------------");
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user