Changeset 25600

Timestamp:
May 30, 2021, 11:07:27 AM (3 years ago)
Author:
Silier
Message:

[PetraAI] - Make easy difficulties of AI weaker

This patch decreases the popScaling so that the easy AI difficulties have lower targeted population.
And it also decreases the size & priority of the attacks from the easy an very easy AI.

Refs: #6149
Differential revision: D3997
Patch by: @marder
Tested by: @Langbart
Comments by: @wraitii, @Freagarach

Location:
ps/trunk/binaries/data/mods/public/simulation/ai/petra
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js

    r25584 r25600  
    174174    if (this.Config.difficulty < 2)
    175175    {
    176         priority *= 0.6;
    177         variation *= 0.5;
     176        priority *= 0.;
     177        variation *= 0.;
    178178    }
    179179    else if (this.Config.difficulty < 3)
    180180    {
    181181        priority *= 0.8;
    182         variation *= 0.8;
    183     }
    184     for (let cat in this.unitStat)
    185     {
    186         this.unitStat[cat].targetSize = Math.round(variation * this.unitStat[cat].targetSize);
    187         this.unitStat[cat].minSize = Math.min(this.unitStat[cat].minSize, this.unitStat[cat].targetSize);
     182        variation *= 0.6;
     183    }
     184
     185    if (this.Config.difficulty < 2)
     186    {
     187        for (const cat in this.unitStat)
     188        {
     189            this.unitStat[cat].targetSize = Math.ceil(variation * this.unitStat[cat].targetSize);
     190            this.unitStat[cat].minSize = Math.min(this.unitStat[cat].targetSize, Math.min(this.unitStat[cat].minSize, 2));
     191            this.unitStat[cat].batchSize = this.unitStat[cat].minSize;
     192        }
     193    }
     194    else
     195    {
     196        for (const cat in this.unitStat)
     197        {
     198            this.unitStat[cat].targetSize = Math.ceil(variation * this.unitStat[cat].targetSize);
     199            this.unitStat[cat].minSize = Math.min(this.unitStat[cat].minSize, this.unitStat[cat].targetSize);
     200        }
    188201    }
    189202
     
    192205    for (let cat in this.unitStat)
    193206    {
    194         this.unitStat[cat].targetSize = Math.round(this.Config.popScaling * this.unitStat[cat].targetSize);
     207        this.unitStat[cat].targetSize = Math.(this.Config.popScaling * this.unitStat[cat].targetSize);
    195208        this.unitStat[cat].minSize = Math.ceil(this.Config.popScaling * this.unitStat[cat].minSize);
    196209    }
     
    707720    }
    708721
    709     // Finally add also some workers,
     722    // Finally add also some workers,
    710723    // If Rush, assign all kind of workers, keeping only a minimum number of defenders
    711724    // Otherwise, assign only some idle workers if too much of them
     725
     726
     727
    712728    let num = 0;
    713     let numbase = {};
     729    t numbase = {};
    714730    let keep = this.type != "Rush" ?
    715731        6 + 4 * gameState.getNumPlayerEnemies() + 8 * this.Config.personality.defensive : 8;
    716732    keep = Math.round(this.Config.popScaling * keep);
    717     for (let ent of gameState.getOwnEntitiesByRole("worker", true).values())
     733    for (t ent of gameState.getOwnEntitiesByRole("worker", true).values())
    718734    {
    719735        if (!ent.hasClass("CitizenSoldier") || !this.isAvailableUnit(gameState, ent))
    720736            continue;
    721         let baseID = ent.getMetadata(PlayerID, "base");
     737        t baseID = ent.getMetadata(PlayerID, "base");
    722738        if (baseID)
    723739            numbase[baseID] = numbase[baseID] ? ++numbase[baseID] : 1;
  • ps/trunk/binaries/data/mods/public/simulation/ai/petra/config.js

    r24758 r25600  
    209209    if (this.difficulty < 2)
    210210    {
     211
    211212        this.Economy.supportRatio = 0.5;
    212213        this.Economy.provisionFields = 1;
     
    215216    else if (this.difficulty < 3)
    216217    {
     218
    217219        this.Economy.supportRatio = 0.4;
    218220        this.Economy.provisionFields = 1;
     
    255257
    256258    if (maxPop < 300)
    257     {
    258         this.popScaling = Math.sqrt(maxPop / 300);
    259         this.Military.popForBarracks1 = Math.min(Math.max(Math.floor(this.Military.popForBarracks1 * this.popScaling), 12), Math.floor(maxPop/5));
    260         this.Military.popForBarracks2 = Math.min(Math.max(Math.floor(this.Military.popForBarracks2 * this.popScaling), 45), Math.floor(maxPop*2/3));
    261         this.Military.popForForge = Math.min(Math.max(Math.floor(this.Military.popForForge * this.popScaling), 30), Math.floor(maxPop/2));
    262         this.Economy.popPhase2 = Math.min(Math.max(Math.floor(this.Economy.popPhase2 * this.popScaling), 20), Math.floor(maxPop/2));
    263         this.Economy.workPhase3 = Math.min(Math.max(Math.floor(this.Economy.workPhase3 * this.popScaling), 40), Math.floor(maxPop*2/3));
    264         this.Economy.workPhase4 = Math.min(Math.max(Math.floor(this.Economy.workPhase4 * this.popScaling), 45), Math.floor(maxPop*2/3));
    265         this.Economy.targetNumTraders = Math.round(this.Economy.targetNumTraders * this.popScaling);
    266     }
     259        this.popScaling *= Math.sqrt(maxPop / 300);
     260
     261    this.Military.popForBarracks1 = Math.min(Math.max(Math.floor(this.Military.popForBarracks1 * this.popScaling), 12), Math.floor(maxPop/5));
     262    this.Military.popForBarracks2 = Math.min(Math.max(Math.floor(this.Military.popForBarracks2 * this.popScaling), 45), Math.floor(maxPop*2/3));
     263    this.Military.popForForge = Math.min(Math.max(Math.floor(this.Military.popForForge * this.popScaling), 30), Math.floor(maxPop/2));
     264    this.Economy.popPhase2 = Math.min(Math.max(Math.floor(this.Economy.popPhase2 * this.popScaling), 20), Math.floor(maxPop/2));
     265    this.Economy.workPhase3 = Math.min(Math.max(Math.floor(this.Economy.workPhase3 * this.popScaling), 40), Math.floor(maxPop*2/3));
     266    this.Economy.workPhase4 = Math.min(Math.max(Math.floor(this.Economy.workPhase4 * this.popScaling), 45), Math.floor(maxPop*2/3));
     267    this.Economy.targetNumTraders = Math.round(this.Economy.targetNumTraders * this.popScaling);
    267268    this.Economy.targetNumWorkers = Math.max(this.Economy.targetNumWorkers, this.Economy.popPhase2);
    268269    this.Economy.workPhase3 = Math.min(this.Economy.workPhase3, this.Economy.targetNumWorkers);
Note: See TracChangeset for help on using the changeset viewer.