Tactical varfare.
This was SVN commit r14528.
This commit is contained in:
parent
8cc1ddf6de
commit
baf6925b66
@ -176,7 +176,7 @@ function startHost(playername, servername)
|
|||||||
// Disallow identically named games in the multiplayer lobby
|
// Disallow identically named games in the multiplayer lobby
|
||||||
if (Engine.HasXmppClient())
|
if (Engine.HasXmppClient())
|
||||||
{
|
{
|
||||||
for each (g in Engine.GetGameList())
|
for each (var g in Engine.GetGameList())
|
||||||
{
|
{
|
||||||
if (g.name === servername)
|
if (g.name === servername)
|
||||||
{
|
{
|
||||||
|
@ -193,7 +193,7 @@ function updateGameList()
|
|||||||
var showFullFilter = showFullFilterCB.checked;
|
var showFullFilter = showFullFilterCB.checked;
|
||||||
|
|
||||||
var c = 0;
|
var c = 0;
|
||||||
for each (g in gameList)
|
for each (var g in gameList)
|
||||||
{
|
{
|
||||||
if(displayGame(g, mapSizeFilter, playersNumberFilter, mapTypeFilter, showFullFilter))
|
if(displayGame(g, mapSizeFilter, playersNumberFilter, mapTypeFilter, showFullFilter))
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,7 @@ m.AegisBot = function AegisBot(settings) {
|
|||||||
|
|
||||||
// this.queues can only be modified by the queue manager or things will go awry.
|
// this.queues can only be modified by the queue manager or things will go awry.
|
||||||
this.queues = {};
|
this.queues = {};
|
||||||
for (i in this.priorities)
|
for (var i in this.priorities)
|
||||||
this.queues[i] = new m.Queue();
|
this.queues[i] = new m.Queue();
|
||||||
|
|
||||||
this.queueManager = new m.QueueManager(this.Config, this.queues, this.priorities);
|
this.queueManager = new m.QueueManager(this.Config, this.queues, this.priorities);
|
||||||
|
@ -134,7 +134,7 @@ m.BaseManager.prototype.initGatheringFunctions = function(HQ, gameState, specTyp
|
|||||||
var self = this;
|
var self = this;
|
||||||
var count = 0;
|
var count = 0;
|
||||||
|
|
||||||
for (i in types)
|
for (var i in types)
|
||||||
{
|
{
|
||||||
var type = types[i];
|
var type = types[i];
|
||||||
// TODO: set us as "X" gatherer
|
// TODO: set us as "X" gatherer
|
||||||
@ -148,7 +148,7 @@ m.BaseManager.prototype.initGatheringFunctions = function(HQ, gameState, specTyp
|
|||||||
{
|
{
|
||||||
var needFarm = true;
|
var needFarm = true;
|
||||||
// Let's check again for food
|
// Let's check again for food
|
||||||
for (base in HQ.baseManagers)
|
for (var base in HQ.baseManagers)
|
||||||
if (HQ.baseManagers[base].willGather["food"] === 1)
|
if (HQ.baseManagers[base].willGather["food"] === 1)
|
||||||
needFarm = false;
|
needFarm = false;
|
||||||
if (needFarm)
|
if (needFarm)
|
||||||
@ -161,7 +161,7 @@ m.BaseManager.prototype.initGatheringFunctions = function(HQ, gameState, specTyp
|
|||||||
}
|
}
|
||||||
|
|
||||||
m.BaseManager.prototype.checkEvents = function (gameState, events, queues) {
|
m.BaseManager.prototype.checkEvents = function (gameState, events, queues) {
|
||||||
for (i in events)
|
for (var i in events)
|
||||||
{
|
{
|
||||||
if (events[i].type == "Destroy")
|
if (events[i].type == "Destroy")
|
||||||
{
|
{
|
||||||
@ -197,7 +197,7 @@ m.BaseManager.prototype.checkEvents = function (gameState, events, queues) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i in events)
|
for (var i in events)
|
||||||
{
|
{
|
||||||
if (events[i].type == "ConstructionFinished")
|
if (events[i].type == "ConstructionFinished")
|
||||||
{
|
{
|
||||||
@ -216,7 +216,7 @@ m.BaseManager.prototype.checkEvents = function (gameState, events, queues) {
|
|||||||
if(ent.hasTerritoryInfluence())
|
if(ent.hasTerritoryInfluence())
|
||||||
this.territoryBuildings.push(ent.id());
|
this.territoryBuildings.push(ent.id());
|
||||||
if (ent.resourceDropsiteTypes())
|
if (ent.resourceDropsiteTypes())
|
||||||
for (ress in ent.resourceDropsiteTypes())
|
for (var ress in ent.resourceDropsiteTypes())
|
||||||
this.initializeDropsite(gameState, ent, ent.resourceDropsiteTypes()[ress]);
|
this.initializeDropsite(gameState, ent, ent.resourceDropsiteTypes()[ress]);
|
||||||
if (ent.resourceSupplyAmount() && ent.resourceSupplyType()["specific"] == "grain")
|
if (ent.resourceSupplyAmount() && ent.resourceSupplyType()["specific"] == "grain")
|
||||||
this.assignResourceToDP(gameState,ent);
|
this.assignResourceToDP(gameState,ent);
|
||||||
@ -249,7 +249,7 @@ m.BaseManager.prototype.assignResourceToDP = function (gameState, supply, specif
|
|||||||
{
|
{
|
||||||
var closest = -1;
|
var closest = -1;
|
||||||
var dist = Math.min();
|
var dist = Math.min();
|
||||||
for (i in this.dropsites)
|
for (var i in this.dropsites)
|
||||||
{
|
{
|
||||||
var dp = gameState.getEntityById(i);
|
var dp = gameState.getEntityById(i);
|
||||||
var distance = API3.SquareVectorDistance(supply.position(), dp.position());
|
var distance = API3.SquareVectorDistance(supply.position(), dp.position());
|
||||||
@ -378,7 +378,7 @@ m.BaseManager.prototype.scrapDropsite = function (gameState, ent) {
|
|||||||
if (this.dropsites[ent.id()] === undefined)
|
if (this.dropsites[ent.id()] === undefined)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (i in this.dropsites[ent.id()])
|
for (var i in this.dropsites[ent.id()])
|
||||||
{
|
{
|
||||||
var type = i;
|
var type = i;
|
||||||
var dp = this.dropsites[ent.id()][i];
|
var dp = this.dropsites[ent.id()][i];
|
||||||
@ -495,9 +495,9 @@ m.BaseManager.prototype.updateDropsite = function (gameState, ent, type) {
|
|||||||
// Updates dropsites.
|
// Updates dropsites.
|
||||||
m.BaseManager.prototype.updateDropsites = function (gameState) {
|
m.BaseManager.prototype.updateDropsites = function (gameState) {
|
||||||
// for each dropsite, recalculate
|
// for each dropsite, recalculate
|
||||||
for (i in this.dropsites)
|
for (var i in this.dropsites)
|
||||||
{
|
{
|
||||||
for (type in this.dropsites[i])
|
for (var type in this.dropsites[i])
|
||||||
{
|
{
|
||||||
this.updateDropsite(gameState,gameState.getEntityById(i),type);
|
this.updateDropsite(gameState,gameState.getEntityById(i),type);
|
||||||
}
|
}
|
||||||
@ -516,7 +516,7 @@ m.BaseManager.prototype.getWorkerCapacity = function (gameState, type) {
|
|||||||
return 1000000; // TODO: perhaps return something sensible here.
|
return 1000000; // TODO: perhaps return something sensible here.
|
||||||
if (type === "stone" || type === "metal")
|
if (type === "stone" || type === "metal")
|
||||||
{
|
{
|
||||||
for (id in this.dropsites)
|
for (var id in this.dropsites)
|
||||||
if (this.dropsites[id][type])
|
if (this.dropsites[id][type])
|
||||||
this.dropsites[id][type][1].forEach(function (ent) {// }){
|
this.dropsites[id][type][1].forEach(function (ent) {// }){
|
||||||
if (ent.resourceSupplyAmount() > 500)
|
if (ent.resourceSupplyAmount() > 500)
|
||||||
@ -524,7 +524,7 @@ m.BaseManager.prototype.getWorkerCapacity = function (gameState, type) {
|
|||||||
});
|
});
|
||||||
} else if (type === "wood")
|
} else if (type === "wood")
|
||||||
{
|
{
|
||||||
for (id in this.dropsites)
|
for (var id in this.dropsites)
|
||||||
if (this.dropsites[id][type] && (this.dropsites[id][type][4]) > 1000)
|
if (this.dropsites[id][type] && (this.dropsites[id][type][4]) > 1000)
|
||||||
count += Math.min(15, this.dropsites[id][type][4] / 200);
|
count += Math.min(15, this.dropsites[id][type][4] / 200);
|
||||||
}
|
}
|
||||||
@ -546,7 +546,7 @@ m.BaseManager.prototype.getResourceLevel = function (gameState, type, searchType
|
|||||||
if (searchType == "dropsites")
|
if (searchType == "dropsites")
|
||||||
{
|
{
|
||||||
// for each dropsite, recalculate
|
// for each dropsite, recalculate
|
||||||
for (i in this.dropsites)
|
for (var i in this.dropsites)
|
||||||
if (this.dropsites[i][type] !== undefined)
|
if (this.dropsites[i][type] !== undefined)
|
||||||
count += this.dropsites[i][type][4];
|
count += this.dropsites[i][type][4];
|
||||||
return count;
|
return count;
|
||||||
@ -554,7 +554,7 @@ m.BaseManager.prototype.getResourceLevel = function (gameState, type, searchType
|
|||||||
if (searchType == "dropsitesClose")
|
if (searchType == "dropsitesClose")
|
||||||
{
|
{
|
||||||
// for each dropsite, recalculate
|
// for each dropsite, recalculate
|
||||||
for (i in this.dropsites)
|
for (var i in this.dropsites)
|
||||||
if (this.dropsites[i][type] !== undefined)
|
if (this.dropsites[i][type] !== undefined)
|
||||||
count += this.dropsites[i][type][3];
|
count += this.dropsites[i][type][3];
|
||||||
return count;
|
return count;
|
||||||
@ -565,7 +565,7 @@ m.BaseManager.prototype.getResourceLevel = function (gameState, type, searchType
|
|||||||
if (threshold)
|
if (threshold)
|
||||||
seuil = threshold;
|
seuil = threshold;
|
||||||
// for each dropsite, recalculate
|
// for each dropsite, recalculate
|
||||||
for (i in this.dropsites)
|
for (var i in this.dropsites)
|
||||||
if (this.dropsites[i][type] !== undefined)
|
if (this.dropsites[i][type] !== undefined)
|
||||||
{
|
{
|
||||||
if (this.dropsites[i][type][4] > seuil)
|
if (this.dropsites[i][type][4] > seuil)
|
||||||
@ -578,7 +578,7 @@ m.BaseManager.prototype.getResourceLevel = function (gameState, type, searchType
|
|||||||
|
|
||||||
// check our resource levels and react accordingly
|
// check our resource levels and react accordingly
|
||||||
m.BaseManager.prototype.checkResourceLevels = function (gameState,queues) {
|
m.BaseManager.prototype.checkResourceLevels = function (gameState,queues) {
|
||||||
for (type in this.willGather)
|
for (var type in this.willGather)
|
||||||
{
|
{
|
||||||
if (this.willGather[type] === 0)
|
if (this.willGather[type] === 0)
|
||||||
continue;
|
continue;
|
||||||
@ -600,7 +600,7 @@ m.BaseManager.prototype.checkResourceLevels = function (gameState,queues) {
|
|||||||
}
|
}
|
||||||
} else if (!this.isFarming && count < 650)
|
} else if (!this.isFarming && count < 650)
|
||||||
{
|
{
|
||||||
for (i in queues.field.queue)
|
for (var i in queues.field.queue)
|
||||||
queues.field.queue[i].isGo = function() { return true; }; // start them
|
queues.field.queue[i].isGo = function() { return true; }; // start them
|
||||||
this.isFarming = true;
|
this.isFarming = true;
|
||||||
}
|
}
|
||||||
@ -674,12 +674,12 @@ m.BaseManager.prototype.setWorkersIdleByPriority = function(gameState){
|
|||||||
|
|
||||||
var avgOverdraft = 0;
|
var avgOverdraft = 0;
|
||||||
|
|
||||||
for (i in types.types)
|
for (var i in types.types)
|
||||||
avgOverdraft += types[types.types[i]];
|
avgOverdraft += types[types.types[i]];
|
||||||
|
|
||||||
avgOverdraft /= 4;
|
avgOverdraft /= 4;
|
||||||
|
|
||||||
for (i in types.types)
|
for (var i in types.types)
|
||||||
if (types[types.types[i]] > avgOverdraft + 200 || (types[types.types[i]] > avgOverdraft && avgOverdraft > 200))
|
if (types[types.types[i]] > avgOverdraft + 200 || (types[types.types[i]] > avgOverdraft && avgOverdraft > 200))
|
||||||
if (this.gatherersByType(gameState,types.types[i]).length > 0)
|
if (this.gatherersByType(gameState,types.types[i]).length > 0)
|
||||||
{
|
{
|
||||||
|
@ -78,7 +78,7 @@ m.HQ.prototype.init = function(gameState, events, queues){
|
|||||||
if (hasCC)
|
if (hasCC)
|
||||||
{
|
{
|
||||||
var CC = ents.filter(API3.Filters.byClass("CivCentre")).toEntityArray()[0];
|
var CC = ents.filter(API3.Filters.byClass("CivCentre")).toEntityArray()[0];
|
||||||
for (i in treasureAmount)
|
for (var i in treasureAmount)
|
||||||
gameState.getResourceSupplies(i).forEach( function (ent) {
|
gameState.getResourceSupplies(i).forEach( function (ent) {
|
||||||
if (ent.resourceSupplyType().generic === "treasure" && API3.SquareVectorDistance(ent.position(), CC.position()) < 5000)
|
if (ent.resourceSupplyType().generic === "treasure" && API3.SquareVectorDistance(ent.position(), CC.position()) < 5000)
|
||||||
treasureAmount[i] += ent.resourceSupplyMax();
|
treasureAmount[i] += ent.resourceSupplyMax();
|
||||||
@ -178,7 +178,7 @@ m.HQ.prototype.init = function(gameState, events, queues){
|
|||||||
};
|
};
|
||||||
|
|
||||||
m.HQ.prototype.checkEvents = function (gameState, events, queues) {
|
m.HQ.prototype.checkEvents = function (gameState, events, queues) {
|
||||||
for (i in events)
|
for (var i in events)
|
||||||
{
|
{
|
||||||
if (events[i].type == "Destroy")
|
if (events[i].type == "Destroy")
|
||||||
{
|
{
|
||||||
@ -452,7 +452,7 @@ m.HQ.prototype.bulkPickWorkers = function(gameState, newBaseID, number) {
|
|||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
for (i in baseBest)
|
for (var i in baseBest)
|
||||||
{
|
{
|
||||||
if (baseBest[i].workers.length > number)
|
if (baseBest[i].workers.length > number)
|
||||||
{
|
{
|
||||||
@ -471,7 +471,7 @@ m.HQ.prototype.GetCurrentGatherRates = function(gameState) {
|
|||||||
for (var type in this.wantedRates)
|
for (var type in this.wantedRates)
|
||||||
currentRates[type] = 0;
|
currentRates[type] = 0;
|
||||||
|
|
||||||
for (i in this.baseManagers)
|
for (var i in this.baseManagers)
|
||||||
this.baseManagers[i].getGatherRates(gameState, currentRates);
|
this.baseManagers[i].getGatherRates(gameState, currentRates);
|
||||||
|
|
||||||
return currentRates;
|
return currentRates;
|
||||||
@ -488,7 +488,7 @@ m.HQ.prototype.pickMostNeededResources = function(gameState) {
|
|||||||
for (var type in this.wantedRates)
|
for (var type in this.wantedRates)
|
||||||
currentRates[type] = 0;
|
currentRates[type] = 0;
|
||||||
|
|
||||||
for (i in this.baseManagers)
|
for (var i in this.baseManagers)
|
||||||
{
|
{
|
||||||
var base = this.baseManagers[i];
|
var base = this.baseManagers[i];
|
||||||
for (var type in this.wantedRates)
|
for (var type in this.wantedRates)
|
||||||
@ -528,7 +528,7 @@ m.HQ.prototype.buildNewCC= function(gameState, queues) {
|
|||||||
|
|
||||||
// no use trying to lay foundations that will be destroyed
|
// no use trying to lay foundations that will be destroyed
|
||||||
if (gameState.defcon() > 2)
|
if (gameState.defcon() > 2)
|
||||||
for ( var i = numCCs; i < 1; i++) {
|
for (var i = numCCs; i < 1; i++) {
|
||||||
gameState.ai.queueManager.clear();
|
gameState.ai.queueManager.clear();
|
||||||
this.baseNeed["food"] = 0;
|
this.baseNeed["food"] = 0;
|
||||||
this.baseNeed["wood"] = 50;
|
this.baseNeed["wood"] = 50;
|
||||||
@ -789,10 +789,10 @@ m.HQ.prototype.checkBasesRessLevel = function(gameState,queues) {
|
|||||||
var need = { "wood" : true, "stone" : true, "metal" : true };
|
var need = { "wood" : true, "stone" : true, "metal" : true };
|
||||||
var posss = [];
|
var posss = [];
|
||||||
|
|
||||||
for (i in this.baseManagers)
|
for (var i in this.baseManagers)
|
||||||
{
|
{
|
||||||
var base = this.baseManagers[i];
|
var base = this.baseManagers[i];
|
||||||
for (type in count)
|
for (var type in count)
|
||||||
{
|
{
|
||||||
if (base.getResourceLevel(gameState, type, "all") > 1500*Math.max(this.Config.difficulty,2))
|
if (base.getResourceLevel(gameState, type, "all") > 1500*Math.max(this.Config.difficulty,2))
|
||||||
count[type]++;
|
count[type]++;
|
||||||
@ -801,7 +801,7 @@ m.HQ.prototype.checkBasesRessLevel = function(gameState,queues) {
|
|||||||
need[type] = false;
|
need[type] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (type in count)
|
for (var type in count)
|
||||||
{
|
{
|
||||||
if (count[type] === 0 || need[type]
|
if (count[type] === 0 || need[type]
|
||||||
|| capacity[type] < gameState.getOwnEntities().filter(API3.Filters.and(API3.Filters.byMetadata(PlayerID, "subrole", "gatherer"), API3.Filters.byMetadata(PlayerID, "gather-type", type))).length * 1.05)
|
|| capacity[type] < gameState.getOwnEntities().filter(API3.Filters.and(API3.Filters.byMetadata(PlayerID, "subrole", "gatherer"), API3.Filters.byMetadata(PlayerID, "gather-type", type))).length * 1.05)
|
||||||
@ -833,9 +833,9 @@ m.HQ.prototype.buildDefences = function(gameState, queues){
|
|||||||
|
|
||||||
if (gameState.countEntitiesAndQueuedByType(gameState.applyCiv('structures/{civ}_defense_tower'))
|
if (gameState.countEntitiesAndQueuedByType(gameState.applyCiv('structures/{civ}_defense_tower'))
|
||||||
+ queues.defenceBuilding.length() < gameState.getEntityLimits()["DefenseTower"] && queues.defenceBuilding.length() < 4 && gameState.currentPhase() > 1) {
|
+ queues.defenceBuilding.length() < gameState.getEntityLimits()["DefenseTower"] && queues.defenceBuilding.length() < 4 && gameState.currentPhase() > 1) {
|
||||||
for (i in this.baseManagers)
|
for (var i in this.baseManagers)
|
||||||
{
|
{
|
||||||
for (j in this.baseManagers[i].dropsites)
|
for (var j in this.baseManagers[i].dropsites)
|
||||||
{
|
{
|
||||||
var amnts = this.baseManagers[i].dropsites[j];
|
var amnts = this.baseManagers[i].dropsites[j];
|
||||||
var dpEnt = gameState.getEntityById(j);
|
var dpEnt = gameState.getEntityById(j);
|
||||||
@ -1092,7 +1092,7 @@ m.HQ.prototype.update = function(gameState, queues, events) {
|
|||||||
this.buildDefences(gameState, queues);
|
this.buildDefences(gameState, queues);
|
||||||
Engine.ProfileStop();
|
Engine.ProfileStop();
|
||||||
|
|
||||||
for (i in this.baseManagers)
|
for (var i in this.baseManagers)
|
||||||
{
|
{
|
||||||
this.baseManagers[i].checkEvents(gameState, events, queues)
|
this.baseManagers[i].checkEvents(gameState, events, queues)
|
||||||
if ( ( (+i + gameState.ai.playedTurn) % (m.playerGlobals[PlayerID].uniqueIDBases - 1)) === 0)
|
if ( ( (+i + gameState.ai.playedTurn) % (m.playerGlobals[PlayerID].uniqueIDBases - 1)) === 0)
|
||||||
|
@ -112,7 +112,7 @@ m.NavalManager.prototype.canReach = function (gameState, regionA, regionB) {
|
|||||||
|
|
||||||
|
|
||||||
m.NavalManager.prototype.checkEvents = function (gameState, queues, events) {
|
m.NavalManager.prototype.checkEvents = function (gameState, queues, events) {
|
||||||
for (i in events)
|
for (var i in events)
|
||||||
{
|
{
|
||||||
if (events[i].type == "Destroy")
|
if (events[i].type == "Destroy")
|
||||||
{
|
{
|
||||||
@ -155,7 +155,7 @@ m.NavalManager.prototype.askForTransport = function(entity, startPos, endPos) {
|
|||||||
m.NavalManager.prototype.createPlans = function(gameState) {
|
m.NavalManager.prototype.createPlans = function(gameState) {
|
||||||
var startID = {};
|
var startID = {};
|
||||||
|
|
||||||
for (i in this.askedPlans)
|
for (var i in this.askedPlans)
|
||||||
{
|
{
|
||||||
var plan = this.askedPlans[i];
|
var plan = this.askedPlans[i];
|
||||||
var startIndex = gameState.ai.accessibility.getAccessValue(plan[1]);
|
var startIndex = gameState.ai.accessibility.getAccessValue(plan[1]);
|
||||||
@ -227,7 +227,7 @@ m.NavalManager.prototype.assignToPlans = function(gameState, queues, events) {
|
|||||||
var zone = plan.neededShipsZone();
|
var zone = plan.neededShipsZone();
|
||||||
if (zone)
|
if (zone)
|
||||||
{
|
{
|
||||||
for each (ship in this.seaTpShips[zone]._entities)
|
for each (var ship in this.seaTpShips[zone]._entities)
|
||||||
{
|
{
|
||||||
if (!ship.getMetadata(PlayerID, "tpplan"))
|
if (!ship.getMetadata(PlayerID, "tpplan"))
|
||||||
{
|
{
|
||||||
|
@ -340,7 +340,7 @@ m.TransportPlan.prototype.carryOn = function(gameState, navalManager)
|
|||||||
{
|
{
|
||||||
// could have died or could have be full
|
// could have died or could have be full
|
||||||
// we'll pick a new one, one that isn't full
|
// we'll pick a new one, one that isn't full
|
||||||
for (i in this.transportShips._entities)
|
for (var i in this.transportShips._entities)
|
||||||
{
|
{
|
||||||
if (this.transportShips._entities[i].canGarrisonInside())
|
if (this.transportShips._entities[i].canGarrisonInside())
|
||||||
{
|
{
|
||||||
|
@ -137,7 +137,7 @@ m.QueueManager.prototype.wantedGatherRates = function(gameState) {
|
|||||||
{
|
{
|
||||||
// assume 2 minutes.
|
// assume 2 minutes.
|
||||||
// TODO work on this.
|
// TODO work on this.
|
||||||
for (type in qCosts)
|
for (var type in qCosts)
|
||||||
qCosts[type] += cost[type];
|
qCosts[type] += cost[type];
|
||||||
qTime += 120000;
|
qTime += 120000;
|
||||||
break; // disregard other stuffs.
|
break; // disregard other stuffs.
|
||||||
@ -146,20 +146,20 @@ m.QueueManager.prototype.wantedGatherRates = function(gameState) {
|
|||||||
{
|
{
|
||||||
// estimate time based on priority + cost + nb
|
// estimate time based on priority + cost + nb
|
||||||
// TODO: work on this.
|
// TODO: work on this.
|
||||||
for (type in qCosts)
|
for (var type in qCosts)
|
||||||
{
|
{
|
||||||
qCosts[type] += (cost[type] + Math.min(cost[type],this.priorities[name]));
|
qCosts[type] += (cost[type] + Math.min(cost[type],this.priorities[name]));
|
||||||
}
|
}
|
||||||
qTime += 30000;
|
qTime += 30000;
|
||||||
} else {
|
} else {
|
||||||
// TODO: work on this.
|
// TODO: work on this.
|
||||||
for (type in qCosts)
|
for (var type in qCosts)
|
||||||
qCosts[type] += (cost[type] + Math.min(cost[type],this.priorities[name]));
|
qCosts[type] += (cost[type] + Math.min(cost[type],this.priorities[name]));
|
||||||
// TODO: refine based on % completed.
|
// TODO: refine based on % completed.
|
||||||
qTime += (elem.endTime-elem.startTime);
|
qTime += (elem.endTime-elem.startTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (j in qCosts)
|
for (var j in qCosts)
|
||||||
{
|
{
|
||||||
qCosts[j] -= this.accounts[name][j];
|
qCosts[j] -= this.accounts[name][j];
|
||||||
var diff = Math.min(qCosts[j], currentRess[j]);
|
var diff = Math.min(qCosts[j], currentRess[j]);
|
||||||
@ -191,7 +191,7 @@ m.QueueManager.prototype.wantedGatherRates = function(gameState) {
|
|||||||
var currentRates = {};
|
var currentRates = {};
|
||||||
for (var type in array)
|
for (var type in array)
|
||||||
currentRates[type] = 0;
|
currentRates[type] = 0;
|
||||||
for (i in gameState.ai.HQ.baseManagers)
|
for (var i in gameState.ai.HQ.baseManagers)
|
||||||
{
|
{
|
||||||
var base = gameState.ai.HQ.baseManagers[i];
|
var base = gameState.ai.HQ.baseManagers[i];
|
||||||
for (var type in array)
|
for (var type in array)
|
||||||
@ -222,7 +222,7 @@ m.QueueManager.prototype.wantedGatherRates = function(gameState) {
|
|||||||
if (gameState.getTimeElapsed() > 20*60*1000 && !this.once)
|
if (gameState.getTimeElapsed() > 20*60*1000 && !this.once)
|
||||||
{
|
{
|
||||||
this.once = true;
|
this.once = true;
|
||||||
for (j in array)
|
for (var j in array)
|
||||||
{
|
{
|
||||||
log (j + ";");
|
log (j + ";");
|
||||||
for (var i = 0; i < this.totor.length; ++i)
|
for (var i = 0; i < this.totor.length; ++i)
|
||||||
@ -231,7 +231,7 @@ m.QueueManager.prototype.wantedGatherRates = function(gameState) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
log();
|
log();
|
||||||
for (j in array)
|
for (var j in array)
|
||||||
{
|
{
|
||||||
log (j + ";");
|
log (j + ";");
|
||||||
for (var i = 0; i < this.totor.length; ++i)
|
for (var i = 0; i < this.totor.length; ++i)
|
||||||
@ -240,7 +240,7 @@ m.QueueManager.prototype.wantedGatherRates = function(gameState) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
log();
|
log();
|
||||||
for (j in array)
|
for (var j in array)
|
||||||
{
|
{
|
||||||
log (j + ";");
|
log (j + ";");
|
||||||
for (var i = 0; i < this.totor.length; ++i)
|
for (var i = 0; i < this.totor.length; ++i)
|
||||||
@ -249,7 +249,7 @@ m.QueueManager.prototype.wantedGatherRates = function(gameState) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
log();
|
log();
|
||||||
for (j in array)
|
for (var j in array)
|
||||||
{
|
{
|
||||||
log (j + ";");
|
log (j + ";");
|
||||||
for (var i = 0; i < this.totor.length; ++i)
|
for (var i = 0; i < this.totor.length; ++i)
|
||||||
@ -296,7 +296,7 @@ m.QueueManager.prototype.HTMLprintQueues = function(gameState){
|
|||||||
|
|
||||||
var q = this.queues[i];
|
var q = this.queues[i];
|
||||||
var str = "<th>" + i +"<br>";
|
var str = "<th>" + i +"<br>";
|
||||||
for each (k in this.accounts[i].types)
|
for each (var k in this.accounts[i].types)
|
||||||
if(k != "population")
|
if(k != "population")
|
||||||
{
|
{
|
||||||
str += this.accounts[i][k] + k.substr(0,1).toUpperCase() ;
|
str += this.accounts[i][k] + k.substr(0,1).toUpperCase() ;
|
||||||
@ -375,7 +375,7 @@ m.QueueManager.prototype.update = function(gameState) {
|
|||||||
// check that we're not too forward in this resource compared to others.
|
// check that we're not too forward in this resource compared to others.
|
||||||
/*var maxp = this.accounts[j][ress] / (queueCost[ress]+1);
|
/*var maxp = this.accounts[j][ress] / (queueCost[ress]+1);
|
||||||
var tooFull = false;
|
var tooFull = false;
|
||||||
for (tempRess in availableRes)
|
for (var tempRess in availableRes)
|
||||||
if (tempRess !== ress && queueCost[tempRess] > 0 && (this.accounts[j][tempRess] / (queueCost[tempRess]+1)) - maxp < -0.2)
|
if (tempRess !== ress && queueCost[tempRess] > 0 && (this.accounts[j][tempRess] / (queueCost[tempRess]+1)) - maxp < -0.2)
|
||||||
tooFull = true;
|
tooFull = true;
|
||||||
if (tooFull)
|
if (tooFull)
|
||||||
|
@ -334,7 +334,7 @@ m.Accessibility.prototype.getAccessValue = function(position, onWater) {
|
|||||||
{
|
{
|
||||||
// quick spiral search.
|
// quick spiral search.
|
||||||
var indx = [ [-1,-1],[-1,0],[-1,1],[0,1],[1,1],[1,0],[1,-1],[0,-1]]
|
var indx = [ [-1,-1],[-1,0],[-1,1],[0,1],[1,1],[1,0],[1,-1],[0,-1]]
|
||||||
for (i in indx)
|
for (var i in indx)
|
||||||
{
|
{
|
||||||
ret = this.landPassMap[gamePos[0]+indx[0] + this.width*(gamePos[1]+indx[0])]
|
ret = this.landPassMap[gamePos[0]+indx[0] + this.width*(gamePos[1]+indx[0])]
|
||||||
if (ret !== undefined && ret !== 1)
|
if (ret !== undefined && ret !== 1)
|
||||||
@ -431,7 +431,7 @@ m.Accessibility.prototype.getTrajectToIndex = function(istart, iend, noBound){
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var rgs = this.regionLinks[startRegion];
|
var rgs = this.regionLinks[startRegion];
|
||||||
for (p in rgs)
|
for (var p in rgs)
|
||||||
{
|
{
|
||||||
if (this.regionLinks[rgs[p]].indexOf(endRegion) !== -1)
|
if (this.regionLinks[rgs[p]].indexOf(endRegion) !== -1)
|
||||||
return [startRegion, rgs[p], endRegion];
|
return [startRegion, rgs[p], endRegion];
|
||||||
|
Loading…
Reference in New Issue
Block a user