Fixes a few changes in my previous commit. Makes "Medium" the default difficulty setting.

This was SVN commit r13303.
This commit is contained in:
wraitii 2013-03-16 12:55:03 +00:00
parent 77999f6b42
commit 03c3b1daa3
8 changed files with 59 additions and 26 deletions

View File

@ -356,7 +356,7 @@ var Entity = Class({
isFull: function()
{
if (this._entity.resourceSupplyGatherers !== undefined)
return (this.maxGatherers === this._entity.resourceSupplyGatherers.length);
return (this.maxGatherers() === this._entity.resourceSupplyGatherers.length);
return undefined;
},

View File

@ -538,7 +538,7 @@ var Entity = Class({
isFull: function()
{
if (this._entity.resourceSupplyGatherers !== undefined)
return (this.maxGatherers === this._entity.resourceSupplyGatherers.length);
return (this.maxGatherers() === this._entity.resourceSupplyGatherers.length);
return undefined;
},

View File

@ -45,6 +45,8 @@ function aStarPath(gameState, onWater, disregardEntities, targetTerritory) {
this.widthMap[i] = 2;
else if (!disregardEntities && this.map[i] === 42)
this.widthMap[i] = 1;
else if (!onWater && this.map[i] === 201)
this.widthMap[i] = 2;
else
this.widthMap[i] = 255;
}

View File

@ -487,7 +487,7 @@ EconomyManager.prototype.buildNewCC= function(gameState, queues) {
EconomyManager.prototype.updateResourceMaps = function(gameState, events) {
// By how much to divide the resource amount for plotting.
var decreaseFactor = {'wood': 100.0, 'stone': 180.0, 'metal': 180.0, 'food': 80.0};
var decreaseFactor = {'wood': 50.0, 'stone': 90.0, 'metal': 90.0, 'food': 40.0};
// This is the maximum radius of the influence
var dpRadius = 10;
var radius = {'wood':10.0, 'stone': 24.0, 'metal': 24.0, 'food': 24.0};
@ -536,7 +536,7 @@ EconomyManager.prototype.updateResourceMaps = function(gameState, events) {
this.CCResourceMaps[resource].addInfluence(x, z, 15, -strength/2.0,'constant');
} else if (resource === "stone" || resource === "metal")
{
this.resourceMaps[resource].addInfluence(x, z, 3, 50);
this.resourceMaps[resource].addInfluence(x, z, 8, 50);
this.resourceMaps[resource].addInfluence(x, z, 12.0, -strength/1.5);
this.resourceMaps[resource].addInfluence(x, z, 12.0, -strength/2.0,'constant');
this.CCResourceMaps[resource].addInfluence(x, z, 30, -strength,'constant');
@ -588,7 +588,7 @@ EconomyManager.prototype.updateResourceMaps = function(gameState, events) {
self.CCResourceMaps[resource].addInfluence(x, z, 30, strength,'constant');
self.resourceMaps[resource].addInfluence(x, z, 12.0, strength/1.5);
self.resourceMaps[resource].addInfluence(x, z, 12.0, strength/2.0,'constant');
self.resourceMaps[resource].addInfluence(x, z, 3, -50);
self.resourceMaps[resource].addInfluence(x, z, 8, -50);
}
}
});
@ -635,7 +635,7 @@ EconomyManager.prototype.updateResourceMaps = function(gameState, events) {
this.CCResourceMaps[resource].addInfluence(x, z, 30, strength,'constant');
this.resourceMaps[resource].addInfluence(x, z, 12.0, strength/1.5);
this.resourceMaps[resource].addInfluence(x, z, 12.0, strength/2.0,'constant');
this.resourceMaps[resource].addInfluence(x, z, 3, -50);
this.resourceMaps[resource].addInfluence(x, z, 8, -50);
}
}
} else if (ent && ent.position() && ent.resourceDropsiteTypes) {
@ -654,8 +654,8 @@ EconomyManager.prototype.updateResourceMaps = function(gameState, events) {
this.updateNearbyResources(gameState,i);
this.updateResourceConcentrations(gameState,i);
}
/*if (gameState.ai.playedTurn % 20 === 1)
/*
if (gameState.ai.playedTurn % 20 === 1)
{
this.resourceMaps['wood'].dumpIm("s_tree_density_ " + gameState.getTimeElapsed() +".png", 255);
this.resourceMaps['stone'].dumpIm("stone_density_ " + gameState.getTimeElapsed() +".png", 255);
@ -709,7 +709,7 @@ EconomyManager.prototype.getBestResourceBuildSpot = function(gameState, resource
}
}
//friendlyTiles.dumpIm(gameState.getTimeElapsed() + "_" + resource + "_dp_placement_base.png", 1000);
//friendlyTiles.dumpIm(gameState.getTimeElapsed() + "_" + resource + "_dp_placement_base.png", 255);
var isCivilCenter = false;
var best = friendlyTiles.findBestTile(2, obstructions); // try to find a spot to place a DP.
@ -825,7 +825,7 @@ EconomyManager.prototype.updateNearbyResources = function(gameState,resource){
var resourceSupplies;
// By how much to divide the resource amount for plotting.
var decreaseFactor = {'wood': 100.0, 'stone': 180.0, 'metal': 180.0, 'food': 80.0};
var decreaseFactor = {'wood': 50.0, 'stone': 90.0, 'metal': 90.0, 'food': 40.0};
// This is the maximum radius of the influence
var radius = {'wood':10.0, 'stone': 24.0, 'metal': 24.0, 'food': 24.0};
@ -850,7 +850,8 @@ EconomyManager.prototype.updateNearbyResources = function(gameState,resource){
if (distance < bigRadius[resource]) {
if (distance < smallRadius[resource]) {
// it's new to the game, remove it from the resource maps
if (supply.getMetadata(PlayerID, "linked-dropsite") == undefined || supply.getMetadata(PlayerID, "linked-dropsite-nearby") == false) {
if ((supply.getMetadata(PlayerID, "linked-dropsite") == undefined || supply.getMetadata(PlayerID, "linked-dropsite-nearby") == false)
&& supply.resourceSupplyType().generic !== "treasure") {
var x = Math.round(supply.position()[0] / gameState.cellSize);
var z = Math.round(supply.position()[1] / gameState.cellSize);
var strength = Math.round(supply.resourceSupplyMax()/decreaseFactor[resource]);
@ -862,7 +863,7 @@ EconomyManager.prototype.updateNearbyResources = function(gameState,resource){
} else if (resource === "stone" || resource === "metal")
{
self.CCResourceMaps[resource].addInfluence(x, z, 30, -strength,'constant');
self.resourceMaps[resource].addInfluence(x, z, 3, 50);
self.resourceMaps[resource].addInfluence(x, z, 8, 50);
self.resourceMaps[resource].addInfluence(x, z, 12.0, -strength/1.5);
self.resourceMaps[resource].addInfluence(x, z, 12.0, -strength/2.0,'constant');
}

View File

@ -9,8 +9,9 @@ function Map(gameState, originalMap, actualCopy){
this.height = gameMap.height;
this.length = gameMap.data.length;
this.maxVal = 65535;
if (originalMap && actualCopy){
this.maxVal = 65535;
this.map = new Uint16Array(this.length);
for (var i = 0; i < originalMap.length; ++i)
this.map[i] = originalMap[i];
@ -18,7 +19,6 @@ function Map(gameState, originalMap, actualCopy){
this.map = originalMap;
} else {
this.map = new Uint16Array(this.length);
this.maxVal = 65535;
}
this.cellSize = gameState.cellSize;
}

View File

@ -10,7 +10,6 @@ var Worker = function(ent) {
Worker.prototype.update = function(gameState) {
var subrole = this.ent.getMetadata(PlayerID, "subrole");
if (!this.ent.position() || (this.ent.getMetadata(PlayerID,"fleeing") && gameState.getTimeElapsed() - this.ent.getMetadata(PlayerID,"fleeing") < 8000)){
@ -226,7 +225,9 @@ Worker.prototype.startGathering = function(gameState){
return;
}
if (supply.isFull() === true) {
if (supply.isFull() === true || (supply.maxGatherers() - supply.resourceSupplyGatherers().length == 0) ||
(gameState.turnCache["ressGathererNB"] && gameState.turnCache["ressGathererNB"][supply.id()]
&& gameState.turnCache["ressGathererNB"][supply.id()] + supply.resourceSupplyGatherers().length >= supply.maxGatherers())) {
return;
}
@ -313,9 +314,38 @@ Worker.prototype.startGathering = function(gameState){
}
}
if (!tried) {
if (!gameState.turnCache["ressGathererNB"])
{
gameState.turnCache["ressGathererNB"] = {};
gameState.turnCache["ressGathererNB"][nearestSupply.id()] = 1;
} else if (!gameState.turnCache["ressGathererNB"][nearestSupply.id()])
gameState.turnCache["ressGathererNB"][nearestSupply.id()] = 1;
else
gameState.turnCache["ressGathererNB"][nearestSupply.id()]++;
this.maxApproachTime = Math.max(25000, VectorDistance(pos,this.ent.position()) * 1000);
ent.gather(nearestSupply);
ent.setMetadata(PlayerID, "target-foundation", undefined);
// check if the resource we've started gathering from is now full, in which case inform the dropsite.
if (gameState.turnCache["ressGathererNB"][nearestSupply.id()] + nearestSupply.resourceSupplyGatherers().length >= nearestSupply.maxGatherers()
&& nearestSupply.getMetadata(PlayerID, "linked-dropsite") != undefined)
{
var dropsite = gameState.getEntityById(nearestSupply.getMetadata(PlayerID, "linked-dropsite"));
if (dropsite == undefined || dropsite.getMetadata(PlayerID, "linked-resources-" + resource) === undefined)
return;
if (nearestSupply.getMetadata(PlayerID, "linked-dropsite-nearby") == true) {
dropsite.setMetadata(PlayerID, "resource-quantity-" + resource, +dropsite.getMetadata(PlayerID, "resource-quantity-" + resource) - (+nearestSupply.getMetadata(PlayerID, "dp-update-value")));
dropsite.getMetadata(PlayerID, "linked-resources-" + resource).updateEnt(nearestSupply);
dropsite.getMetadata(PlayerID, "nearby-resources-" + resource).updateEnt(nearestSupply);
} else {
dropsite.setMetadata(PlayerID, "resource-quantity-far-" + resource, +dropsite.getMetadata(PlayerID, "resource-quantity-" + resource) - (+nearestSupply.getMetadata(PlayerID, "dp-update-value")));
dropsite.getMetadata(PlayerID, "linked-resources-" + resource).updateEnt(nearestSupply);
}
}
}
} else {
if (resource === "food" && this.buildAnyField(gameState))

View File

@ -6,63 +6,63 @@
"Civ": "gaia",
"Colour": { "r": 255, "g": 255, "b": 255 },
"AI": "",
"AIDiff": 2
"AIDiff": 1
},
{
"Name": "Player 1",
"Civ": "athen",
"Colour": { "r": 46, "g": 46, "b": 200 },
"AI": "",
"AIDiff": 2
"AIDiff": 1
},
{
"Name": "Player 2",
"Civ": "cart",
"Colour": { "r": 150, "g": 20, "b": 20 },
"AI": "qbot-wc",
"AIDiff": 2
"AIDiff": 1
},
{
"Name": "Player 3",
"Civ": "gaul",
"Colour": { "r": 50, "g": 165, "b": 5 },
"AI": "qbot-wc",
"AIDiff": 2
"AIDiff": 1
},
{
"Name": "Player 4",
"Civ": "iber",
"Colour": { "r": 230, "g": 230, "b": 75 },
"AI": "qbot-wc",
"AIDiff": 2
"AIDiff": 1
},
{
"Name": "Player 5",
"Civ": "mace",
"Colour": { "r": 50, "g": 170, "b": 170 },
"AI": "qbot-wc",
"AIDiff": 2
"AIDiff": 1
},
{
"Name": "Player 6",
"Civ": "pers",
"Colour": { "r": 160, "g": 80, "b": 200 },
"AI": "qbot-wc",
"AIDiff": 2
"AIDiff": 1
},
{
"Name": "Player 7",
"Civ": "rome",
"Colour": { "r": 235, "g": 120, "b": 20 },
"AI": "qbot-wc",
"AIDiff": 2
"AIDiff": 1
},
{
"Name": "Player 8",
"Civ": "spart",
"Colour": { "r": 64, "g": 64, "b": 64 },
"AI": "qbot-wc",
"AIDiff": 2
"AIDiff": 1
}
]
}

View File

@ -1193,7 +1193,7 @@ bool Autostart(const CmdLineArgs& args)
CStr name = aiArgs[i].AfterFirst(":");
scriptInterface.SetProperty(player.get(), "AI", std::string(name));
scriptInterface.SetProperty(player.get(), "AIDiff", 2);
scriptInterface.SetProperty(player.get(), "AIDiff", 1);
scriptInterface.SetPropertyInt(playerData.get(), playerID-1, player);
}
}