Esempio n. 1
0
    public void UpdateScore()
    {
        this.UpdateLists();
        this.DebugContext = null;
        if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools)
        {
            this.DebugContext = new AIHeuristicAnalyser.Context();
            string empty = string.Empty;
            this.PrintRegions(ref empty);
        }
        float num  = 0f;
        float num2 = 0f;

        for (int i = 0; i < this.Orbs.Count; i++)
        {
            num2 += this.Orbs[i].CurrentOrbCount;
        }
        float num3 = 0.05f;
        float num4 = Mathf.Min(1f, num3 * num2);
        float num5 = 0.5f;

        num4 *= num5;
        num   = AILayer.Boost(num, num4);
        float num6 = (float)this.Ruins.Count;
        float num7 = 0.1f;
        float num8 = Mathf.Min(1f, num7 * num6);
        float num9 = 0.3f;

        num8 *= num9;
        num   = AILayer.Boost(num, num8);
        this.MantaZoneScore = num;
    }
Esempio n. 2
0
 private float ComputeAttitudeBoostValue(StaticString outputName, AIHeuristicAnalyser.Context debugContext, float attitudeBoost)
 {
     if (outputName == "AIEmpirePillageDefense")
     {
         float attitudeValue  = this.GetAttitudeValue(AILayer_Attitude.AttitudeScoreDefinitionReferences.PillageSucceed, debugContext);
         float attitudeValue2 = this.GetAttitudeValue(AILayer_Attitude.AttitudeScoreDefinitionReferences.Pillaging, debugContext);
         attitudeBoost = Mathf.Max(attitudeValue, attitudeValue2);
     }
     else if (outputName == "AIEmpireAntiSpy")
     {
         attitudeBoost = this.GetAttitudeValue(AILayer_Attitude.AttitudeScoreDefinitionReferences.Spy, debugContext);
     }
     return(attitudeBoost);
 }
Esempio n. 3
0
    private float GetAttitudeValue(StaticString modifierName, AIHeuristicAnalyser.Context debugContext)
    {
        float        num     = 0f;
        IGameService service = Services.GetService <IGameService>();
        global::Game game    = service.Game as global::Game;

        for (int i = 0; i < game.Empires.Length; i++)
        {
            MajorEmpire majorEmpire = game.Empires[i] as MajorEmpire;
            if (majorEmpire != null && majorEmpire.Index != base.AIEntity.Empire.Index)
            {
                AILayer_Attitude.Attitude attitude = this.aiLayerAttitude.GetAttitude(majorEmpire);
                num = Mathf.Max(num, attitude.Score.GetNormalizedScoreByName(modifierName));
            }
        }
        return(num);
    }
Esempio n. 4
0
 private static float Normalize(AIHeuristicAnalyser.Context debugContext, float minimumUtilityValue, float maximumUtilityValue, float utility)
 {
     Diagnostics.Assert(maximumUtilityValue > minimumUtilityValue);
     utility = Mathf.Sign(utility) * Mathf.Clamp01((Mathf.Abs(utility) - minimumUtilityValue) / (maximumUtilityValue - minimumUtilityValue));
     return(utility);
 }
Esempio n. 5
0
 private static float UtilityFunc_WorldMercenaryMarketPrice(SeasonEffect aiEvaluableElement, InterpreterContext context, float aiParameterValue, AIHeuristicAnalyser.Context debugContext)
 {
     return(aiParameterValue);
 }
Esempio n. 6
0
    private static float UtilityFunc_WorldPeace(SeasonEffect aiEvaluableElement, InterpreterContext context, float aiParameterValue, AIHeuristicAnalyser.Context debugContext)
    {
        global::Empire empire = context.Get("Empire") as global::Empire;

        Diagnostics.Assert(empire != null);
        float propertyValue  = empire.GetPropertyValue(SimulationProperties.PeaceCount);
        float propertyValue2 = empire.GetPropertyValue(SimulationProperties.AllianceCount);
        float num            = (2f * propertyValue2 + propertyValue) / 7f;

        return(aiParameterValue * num);
    }
Esempio n. 7
0
    private static float UtilityFunc_WorldWar(SeasonEffect aiEvaluableElement, InterpreterContext context, float aiParameterValue, AIHeuristicAnalyser.Context debugContext)
    {
        global::Empire empire = context.Get("Empire") as global::Empire;

        Diagnostics.Assert(empire != null);
        IGameService service = Services.GetService <IGameService>();

        Diagnostics.Assert(service != null);
        global::Game game = service.Game as global::Game;

        Diagnostics.Assert(game != null);
        float propertyValue = empire.GetPropertyValue(SimulationProperties.MilitaryPower);
        float num           = 0f;

        for (int i = 0; i < game.Empires.Length; i++)
        {
            num += game.Empires[i].GetPropertyValue(SimulationProperties.MilitaryPower);
        }
        num /= (float)game.Empires.Length;
        float num2 = propertyValue / Mathf.Max(100f, num) - 1f;

        return(aiParameterValue * num2);
    }
Esempio n. 8
0
    private static float UtilityFunc_WorldSpy(SeasonEffect aiEvaluableElement, InterpreterContext context, float aiParameterValue, AIHeuristicAnalyser.Context debugContext)
    {
        global::Empire empire = context.Get("Empire") as global::Empire;

        Diagnostics.Assert(empire != null);
        float num = 0f;
        DepartmentOfEducation agency = empire.GetAgency <DepartmentOfEducation>();

        for (int i = 0; i < agency.Heroes.Count; i++)
        {
            num += agency.Heroes[i].GetPropertyValue("NetInfiltrationPoint");
        }
        float num2 = num * 0.05f;

        return(aiParameterValue * num2);
    }
Esempio n. 9
0
    private static float UtilityFunc_WorldNavy(SeasonEffect aiEvaluableElement, InterpreterContext context, float aiParameterValue, AIHeuristicAnalyser.Context debugContext)
    {
        IDownloadableContentService service = Services.GetService <IDownloadableContentService>();

        if (!service.IsShared(DownloadableContent16.ReadOnlyName))
        {
            return(0f);
        }
        global::Empire empire = context.Get("Empire") as global::Empire;

        Diagnostics.Assert(empire != null);
        float num = AILayer_Altar.ComputeMyNavyImportance(empire);

        return(aiParameterValue * (num - 1f));
    }
Esempio n. 10
0
    private static float UtilityFunc_EmpireCityDefense(SeasonEffect aiEvaluableElement, InterpreterContext context, float aiParameterValue, AIHeuristicAnalyser.Context debugContext)
    {
        global::Empire empire = context.Get("Empire") as global::Empire;

        Diagnostics.Assert(empire != null);
        DepartmentOfTheInterior agency = empire.GetAgency <DepartmentOfTheInterior>();

        Diagnostics.Assert(agency != null);
        float num = Mathf.Max(1f, AILayer_Altar.GetCityPropertySumValue(empire, SimulationProperties.CityDefensePoint)) / (float)agency.Cities.Count;

        if (float.IsNaN(num))
        {
            return(0f);
        }
        float utility = aiParameterValue / num;

        return(AILayer_Altar.Normalize(debugContext, 0f, 3f, utility));
    }
Esempio n. 11
0
    private static float UtilityFunc_EmpirePillageDefense(SeasonEffect aiEvaluableElement, InterpreterContext context, float aiParameterValue, AIHeuristicAnalyser.Context debugContext)
    {
        global::Empire empire = context.Get("Empire") as global::Empire;

        Diagnostics.Assert(empire != null);
        DepartmentOfTheInterior agency = empire.GetAgency <DepartmentOfTheInterior>();

        Diagnostics.Assert(agency != null);
        int   num   = 0;
        float num2  = 0f;
        int   count = agency.Cities.Count;

        for (int i = 0; i < count; i++)
        {
            for (int j = 0; j < agency.Cities[i].Region.PointOfInterests.Length; j++)
            {
                float propertyValue = agency.Cities[i].Region.PointOfInterests[j].GetPropertyValue(SimulationProperties.MaximumPillageDefense);
                num2 += propertyValue;
                num++;
            }
        }
        float b = num2 / (float)num;

        return(aiParameterValue / Mathf.Max(1f, b));
    }
Esempio n. 12
0
    private static float UtilityFunc_EmpireMilitaryPower(SeasonEffect aiEvaluableElement, InterpreterContext context, float aiParameterValue, AIHeuristicAnalyser.Context debugContext)
    {
        global::Empire empire = context.Get("Empire") as global::Empire;

        Diagnostics.Assert(empire != null);
        float num = Mathf.Max(1f, empire.GetPropertyValue(SimulationProperties.MilitaryPower));

        return(aiParameterValue / num);
    }
Esempio n. 13
0
    private static float UtilityFunc_EmpireLuxury(SeasonEffect aiEvaluableElement, InterpreterContext context, float aiParameterValue, AIHeuristicAnalyser.Context debugContext)
    {
        global::Empire empire = context.Get("Empire") as global::Empire;

        Diagnostics.Assert(empire != null);
        DepartmentOfScience     agency  = empire.GetAgency <DepartmentOfScience>();
        DepartmentOfTheInterior agency2 = empire.GetAgency <DepartmentOfTheInterior>();
        float num;
        float num2;

        AILayer_Altar.GetResourceUnitMarketPrice(empire, out num, out num2);
        float b = 0f;

        if (agency.GetTechnologyState(TechnologyDefinition.Names.MarketplaceResources) == DepartmentOfScience.ConstructibleElement.State.Researched)
        {
            float propertyValue = empire.GetPropertyValue(SimulationProperties.NetEmpireMoney);
            b = num2 / Mathf.Max(propertyValue, 1f);
        }
        float technologyUnlockedCount = agency.GetTechnologyUnlockedCount();
        float a    = (float)agency2.Cities.Count;
        float a2   = technologyUnlockedCount / (15f * Mathf.Max(a, 1f));
        float num3 = Mathf.Max(a2, b);

        return(aiParameterValue * num3);
    }
Esempio n. 14
0
    private static float UtilityFunc_EmpirePoint(SeasonEffect aiEvaluableElement, InterpreterContext context, float aiParameterValue, AIHeuristicAnalyser.Context debugContext)
    {
        global::Empire empire = context.Get("Empire") as global::Empire;

        Diagnostics.Assert(empire != null);
        float num     = Mathf.Max(1f, empire.GetPropertyValue(SimulationProperties.NetEmpirePoint));
        float utility = aiParameterValue / num;

        return(AILayer_Altar.Normalize(debugContext, 0.5f, 4f, utility));
    }
Esempio n. 15
0
    private float DecisionParameterContextModifier(SeasonEffect aievaluableelement, InterpreterContext context, StaticString outputName, AIHeuristicAnalyser.Context debugContext)
    {
        float num  = 1f;
        float num2 = 0f;

        num2 = this.ComputeAttitudeBoostValue(outputName, debugContext, num2);
        num  = AILayer.Boost(num, num2);
        float  num3        = 1f;
        string regitryPath = "AI/MajorEmpire/AIEntity_Empire/AILayer_Altar/ElementEvaluatorContextMultiplier/" + outputName;

        num3 = this.personalityHelper.GetRegistryValue <float>(base.AIEntity.Empire, regitryPath, num3);
        return(num * num3);
    }
Esempio n. 16
0
    private static float UtilityFunc_EmpireResearch(SeasonEffect aiEvaluableElement, InterpreterContext context, float aiParameterValue, AIHeuristicAnalyser.Context debugContext)
    {
        global::Empire empire = context.Get("Empire") as global::Empire;

        Diagnostics.Assert(empire != null);
        if (empire.SimulationObject.Tags.Contains("AffinityReplicants"))
        {
            return(0f);
        }
        float num     = Mathf.Max(1f, empire.GetPropertyValue(SimulationProperties.NetEmpireResearch));
        float utility = aiParameterValue / num;

        return(AILayer_Altar.Normalize(debugContext, 0f, 1.7f, utility));
    }