diff --git a/binaries/data/mods/public/gui/credits/texts/programming.json b/binaries/data/mods/public/gui/credits/texts/programming.json
index d0490d7..0f45fcd 100644
a
|
b
|
|
102 | 102 | {"nick": "kingbasil", "name": "Giannis Fafalios"}, |
103 | 103 | {"nick": "lafferjm", "name": "Justin Lafferty"}, |
104 | 104 | {"nick": "leper", "name": "Georg Kilzer"}, |
| 105 | {"nick": "LittleDev"}, |
105 | 106 | {"nick": "livingaftermidnight", "name": "Will Dull"}, |
106 | 107 | {"nick": "Louhike"}, |
107 | 108 | {"nick": "lsdh"}, |
diff --git a/binaries/data/mods/public/simulation/ai/common-api/entity.js b/binaries/data/mods/public/simulation/ai/common-api/entity.js
index d0fcac2..926b1c4 100644
a
|
b
|
m.Template = m.Class({
|
544 | 544 | |
545 | 545 | visionRange: function() { |
546 | 546 | return +this.get("Vision/Range"); |
| 547 | }, |
| 548 | |
| 549 | gainMultiplier: function() { |
| 550 | if (!this.get("Trader")) |
| 551 | return undefined; |
| 552 | return +this.get("Trader/GainMultiplier"); |
547 | 553 | } |
548 | 554 | }); |
549 | 555 | |
… |
… |
m.Entity = m.Class({
|
912 | 918 | return this; |
913 | 919 | }, |
914 | 920 | |
915 | | research: function(template) { |
| 921 | research: function(template) { |
916 | 922 | Engine.PostCommand(PlayerID,{ "type": "research", "entity": this.id(), "template": template }); |
917 | 923 | return this; |
918 | 924 | }, |
diff --git a/binaries/data/mods/public/simulation/ai/common-api/gamestate.js b/binaries/data/mods/public/simulation/ai/common-api/gamestate.js
index f95b8b3..a1b69df 100644
a
|
b
|
m.GameState.prototype.isEntityLimitReached = function(category)
|
803 | 803 | return (this.playerData.entityCounts[category] >= this.playerData.entityLimits[category]); |
804 | 804 | }; |
805 | 805 | |
| 806 | m.GameState.prototype.getTraderTemplatesGains = function() |
| 807 | { |
| 808 | let shipMechantTemplateName = this.applyCiv("units/{civ}_ship_merchant"); |
| 809 | let supportTraderTemplateName = this.applyCiv("units/{civ}_support_trader"); |
| 810 | let shipMerchantTemplate = (this.isDisabledTemplates(shipMechantTemplateName) ? undefined : this.getTemplate(shipMechantTemplateName)); |
| 811 | let supportTraderTemplate = (this.isDisabledTemplates(supportTraderTemplateName) ? undefined : this.getTemplate(supportTraderTemplateName)); |
| 812 | return { |
| 813 | "navalGainMultiplier" : (shipMerchantTemplate ? shipMerchantTemplate.gainMultiplier() : undefined), |
| 814 | "landGainMultiplier" : (supportTraderTemplate ? supportTraderTemplate.gainMultiplier() : undefined) |
| 815 | }; |
| 816 | }; |
| 817 | |
806 | 818 | return m; |
807 | 819 | |
808 | 820 | }(API3); |
diff --git a/binaries/data/mods/public/simulation/ai/petra/config.js b/binaries/data/mods/public/simulation/ai/petra/config.js
index e9ae59f..8770145 100644
a
|
b
|
m.Config = function(difficulty)
|
34 | 34 | "provisionFields" : 2 |
35 | 35 | }; |
36 | 36 | |
37 | | this.distUnitGain = 115*115; // TODO take it directly from helpers/TraderGain.js |
38 | | |
39 | 37 | // Note: attack settings are set directly in attack_plan.js |
40 | 38 | // defense |
41 | 39 | this.Defense = |
diff --git a/binaries/data/mods/public/simulation/ai/petra/headquarters.js b/binaries/data/mods/public/simulation/ai/petra/headquarters.js
index 27e4d54..0be2980 100644
a
|
b
|
m.HQ.prototype.findMarketLocation = function(gameState, template)
|
1048 | 1048 | var width = this.territoryMap.width; |
1049 | 1049 | var cellSize = this.territoryMap.cellSize; |
1050 | 1050 | |
| 1051 | let traderTemplatesGains = gameState.getTraderTemplatesGains(); |
| 1052 | |
1051 | 1053 | for (var j = 0; j < this.territoryMap.length; ++j) |
1052 | 1054 | { |
1053 | 1055 | // do not try on the border of our territory |
… |
… |
m.HQ.prototype.findMarketLocation = function(gameState, template)
|
1062 | 1064 | var index = gameState.ai.accessibility.landPassMap[i]; |
1063 | 1065 | if (!this.landRegions[index]) |
1064 | 1066 | continue; |
1065 | | |
1066 | 1067 | var pos = [cellSize * (j%width+0.5), cellSize * (Math.floor(j/width)+0.5)]; |
1067 | 1068 | // checking distances to other markets |
1068 | | var maxDist = 0; |
| 1069 | let maxVal = 0; |
| 1070 | let gainMultiplier; |
1069 | 1071 | for (let market of markets) |
1070 | 1072 | { |
1071 | 1073 | if (isNavalMarket && market.hasClass("NavalMarket")) |
1072 | 1074 | { |
1073 | | // TODO check that there are on the same sea. For the time being, we suppose it is true |
| 1075 | if (this.navalManager.getDockIndex(gameState, market, true) !== gameState.ai.accessibility.getAccessValue(pos, true)) |
| 1076 | continue; |
| 1077 | gainMultiplier = traderTemplatesGains.navalGainMultiplier; |
1074 | 1078 | } |
1075 | | else if (gameState.ai.accessibility.getAccessValue(market.position()) != index) |
| 1079 | else if (gameState.ai.accessibility.getAccessValue(market.position()) === index) |
| 1080 | gainMultiplier = traderTemplatesGains.landGainMultiplier; |
| 1081 | else |
| 1082 | continue; |
| 1083 | if (gainMultiplier === undefined) |
1076 | 1084 | continue; |
1077 | | let dist = API3.SquareVectorDistance(market.position(), pos); |
1078 | | if (dist > maxDist) |
1079 | | maxDist = dist; |
| 1085 | let val = API3.SquareVectorDistance(market.position(), pos) * gainMultiplier; |
| 1086 | if (val > maxVal) |
| 1087 | maxVal = val; |
1080 | 1088 | } |
1081 | | if (maxDist == 0) |
| 1089 | if (maxVal === 0) |
1082 | 1090 | continue; |
1083 | | if (bestVal !== undefined && maxDist < bestVal) |
| 1091 | if (bestVal !== undefined && maxVal < bestVal) |
1084 | 1092 | continue; |
1085 | 1093 | if (this.isDangerousLocation(gameState, pos, halfSize)) |
1086 | 1094 | continue; |
1087 | | bestVal = maxDist; |
| 1095 | bestVal = maxVal; |
1088 | 1096 | bestIdx = i; |
1089 | 1097 | bestJdx = j; |
1090 | 1098 | } |
… |
… |
m.HQ.prototype.findMarketLocation = function(gameState, template)
|
1094 | 1102 | |
1095 | 1103 | if (bestVal === undefined) // no constraints. For the time being, place it arbitrarily by the ConstructionPlan |
1096 | 1104 | return [-1, -1, -1, 0]; |
1097 | | |
1098 | | var expectedGain = Math.round(bestVal / this.Config.distUnitGain); |
| 1105 | let expectedGain = Math.round(bestVal / 10000); |
1099 | 1106 | if (this.Config.debug > 1) |
1100 | 1107 | API3.warn("this would give a trading gain of " + expectedGain); |
1101 | 1108 | // do not keep it if gain is too small, except if this is our first BarterMarket |
diff --git a/binaries/data/mods/public/simulation/ai/petra/tradeManager.js b/binaries/data/mods/public/simulation/ai/petra/tradeManager.js
index fc510d8..1f14069 100644
a
|
b
|
m.TradeManager.prototype.checkRoutes = function(gameState, accessIndex)
|
390 | 390 | var potential = { "gain": 0 }; |
391 | 391 | var bestIndex = { "gain": 0 }; |
392 | 392 | var bestLand = { "gain": 0 }; |
| 393 | |
| 394 | let traderTemplatesGains = gameState.getTraderTemplatesGains(); |
| 395 | |
393 | 396 | for (var m1 of market1) |
394 | 397 | { |
395 | 398 | if (!m1.position()) |
… |
… |
m.TradeManager.prototype.checkRoutes = function(gameState, accessIndex)
|
408 | 411 | var sea = (sea1 && sea1 == sea2) ? sea1 : undefined; |
409 | 412 | if (!land && !sea) |
410 | 413 | continue; |
411 | | var gain = Math.round(API3.SquareVectorDistance(m1.position(), m2.position()) / this.Config.distUnitGain); |
| 414 | let gainMultiplier; |
| 415 | if (land && traderTemplatesGains.landGainMultiplier) |
| 416 | gainMultiplier = traderTemplatesGains.landGainMultiplier; |
| 417 | else if (sea && traderTemplatesGains.navalGainMultiplier) |
| 418 | gainMultiplier = traderTemplatesGains.navalGainMultiplier; |
| 419 | else |
| 420 | continue; |
| 421 | let gain = Math.round(API3.SquareVectorDistance(m1.position(), m2.position()) * gainMultiplier / 10000); |
412 | 422 | if (gain < this.minimalGain) |
413 | 423 | continue; |
414 | 424 | if (m1.foundationProgress() === undefined && m2.foundationProgress() === undefined) |