Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/config.js
PETRA.Config = function(difficulty, behavior) | PETRA.Config = function(difficulty, behavior) | ||||
{ | { | ||||
// 0 is sandbox, 1 is very easy, 2 is easy, 3 is medium, 4 is hard and 5 is very hard. | // 0 is sandbox, 1 is very easy, 2 is easy, 3 is medium, 4 is hard and 5 is very hard. | ||||
this.difficulty = difficulty !== undefined ? difficulty : 3; | this.difficulty = difficulty !== undefined ? difficulty : 3; | ||||
// for instance "balanced", "aggressive" or "defensive" | // for instance "balanced", "aggressive" or "defensive" | ||||
this.behavior = behavior || "random"; | this.behavior = behavior || "random"; | ||||
// debug level: 0=none, 1=sanity checks, 2=debug, 3=detailed debug, -100=serializatio debug | // debug level: 0=none, 1=sanity checks, 2=debug, 3=detailed debug, -100=serialization debug | ||||
this.debug = 0; | this.debug = 0; | ||||
this.chat = true; // false to prevent AI's chats | this.chat = true; // false to prevent AI's chats | ||||
this.popScaling = 1; // scale factor depending on the max population | this.popScaling = 1; // scale factor depending on the max population | ||||
this.Military = { | this.Military = { | ||||
"towerLapseTime": 90, // Time to wait between building 2 towers | "towerLapseTime": 90, // Time to wait between building 2 towers | ||||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | "medium": { | ||||
"default": 0 | "default": 0 | ||||
}, | }, | ||||
"long": { | "long": { | ||||
"default": 0 | "default": 0 | ||||
} | } | ||||
}; | }; | ||||
this.garrisonHealthLevel = { "low": 0.4, "medium": 0.55, "high": 0.7 }; | this.garrisonHealthLevel = { "low": 0.4, "medium": 0.55, "high": 0.7 }; | ||||
// In the emergency mode, the range around the position | |||||
// of all units in which no enemy should be to consider it | |||||
// free from enemies. | |||||
this.enemyDetectionRange = 55; | |||||
// Number of civic centres to lose until emergency | |||||
this.civicCentreLossTrigger = 2; | |||||
// Factors determining, how many percent of structures or | |||||
// population have to be around after a certain timespan to | |||||
// avoid triggering an emergency. | |||||
// [<populationFactor>,<structureFactor>] | |||||
this.emergencyFactors = [ | |||||
// Sandbox, never emergency because of huge losses | |||||
[0.0, 0.0], | |||||
// Very easy | |||||
[0.8, 0.8], | |||||
// Easy | |||||
[0.7, 0.7], | |||||
// Medium | |||||
[0.6, 0.6], | |||||
// Hard | |||||
[0.2, 0.2], | |||||
// Very hard, never emergency because of huge losses | |||||
[0.0, 0.0] | |||||
]; | |||||
// How much of each resource should be saved, when sending | |||||
// tributes in case of emergency. | |||||
this.retainedResourcesAfterTribute = 500; | |||||
// How long to wait until the neutrality requests expire. | |||||
this.neutralityRequestWaitingDuration = 30; | |||||
// The size of the area around the collect point in case | |||||
// of emergency. | |||||
this.patrouilleRange = 75; | |||||
Stan: Patrol? | |||||
// If this percentage was killed in emergency mode, resign if | |||||
// this bot has defensive personality. | |||||
this.lossesForResign = 0.8; | |||||
// These are single phases used to check for steady decline. | |||||
// Each one has a key with the max population and an array. | |||||
// Each number in this array is a "phase". This phase is reached, | |||||
// if this amount of population is reached. | |||||
// If the population is reduced, the phase is reduced, too. | |||||
// If the phase is reduced by phasesToLoseUntilEmergency, this is an emergency. | |||||
this.phasesForSteadyDecline = | |||||
Done Inline ActionsThis values probably have to be balanced a lot. JCWasmx86: This values probably have to be balanced a lot. | |||||
{ | |||||
"50": [ | |||||
10, | |||||
20, | |||||
], | |||||
"100": [ | |||||
40, | |||||
65, | |||||
85 | |||||
], | |||||
"150": [ | |||||
40, | |||||
65, | |||||
85, | |||||
120 | |||||
], | |||||
"200": [ | |||||
40, | |||||
100, | |||||
140, | |||||
170 | |||||
], | |||||
"250": [ | |||||
40, | |||||
100, | |||||
140, | |||||
170, | |||||
220 | |||||
], | |||||
"300": [ | |||||
50, | |||||
150, | |||||
190, | |||||
225, | |||||
260 | |||||
], | |||||
"400": [ | |||||
75, | |||||
125, | |||||
175, | |||||
225, | |||||
275 | |||||
], | |||||
"500": [ | |||||
100, | |||||
175, | |||||
275, | |||||
350, | |||||
450 | |||||
], | |||||
"600": [ | |||||
125, | |||||
200, | |||||
300, | |||||
400, | |||||
500, | |||||
575 | |||||
] | |||||
}; | |||||
// If this amount of phases is lost, trigger an emergency. | |||||
this.phasesToLoseUntilEmergency = 2; | |||||
// If the bot is attacked, this sets the delay for | |||||
// checking, how much percent of units/structures were lost. | |||||
// If this value is higher, it is easier, if it is lower, | |||||
// it is more difficult. | |||||
this.fastDestructionDelay = 60; | |||||
// Limit how long the troops are maximum marching to get to the | |||||
// collect point. | |||||
this.maximumMarchingDuration = 100; | |||||
// How often to check, whether the AI should resign, after it | |||||
// collected on one point. | |||||
this.resignCheckDelay = 5; | |||||
// How often the AI should check, whether there were any losses | |||||
// in emergency mode until it returns to normal. | |||||
this.defensiveStateDuration = 20; | |||||
}; | }; | ||||
PETRA.Config.prototype.setConfig = function(gameState) | PETRA.Config.prototype.setConfig = function(gameState) | ||||
{ | { | ||||
if (this.difficulty > 0) | if (this.difficulty > 0) | ||||
{ | { | ||||
// Setup personality traits according to the user choice: | // Setup personality traits according to the user choice: | ||||
// The parameter used to define the personality is basically the aggressivity or (1-defensiveness) | // The parameter used to define the personality is basically the aggressivity or (1-defensiveness) | ||||
▲ Show 20 Lines • Show All 123 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Patrol?