ENDLESS™ Legend

ENDLESS™ Legend

Improved AI
Enchanteur 4 Mar, 2017 @ 4:21am
Technicals Questions about Improved AI
Hi,
I'm doing a mod about techs and improvement. And I'm in the part where I need to make AI parameters. As I would prefer make something accurate about your AI tweaks, I have a tons of questions.
But mostly this one :
I saw you made a big converter and call it from every techs/improvements needing it :

---------------------------------------------------------------------------
<!-- == Must have technology = 1, should any time = 0.5, probability boost = 0.25 == -->
<AIParameterConverter Name="AITechMustHave">
<ToAIParameter AIParameter="AIEmpireMilitaryPower">(0.6 min $(Input)) * 0.15 * $Property(ClassEmpire:MilitaryPower)</ToAIParameter>
<ToAIParameter AIParameter="AIEmpireMoney">(0.6 min $(Input)) * $SumProperty(ClassEmpire/ClassCity:CityMoney) * 0.15</ToAIParameter>
<ToAIParameter AIParameter="AIEmpireGrowth">(0.6 min $(Input)) * $SumProperty(ClassEmpire/ClassCity:CityMoney) * $Count(ClassEmpire,AffinityBrokenLords) * 0.15</ToAIParameter>
<ToAIParameter AIParameter="AIEmpireGrowth">(0.6 min $(Input)) * $SumProperty(ClassEmpire/ClassCity:CityFood) * $Property(ClassEmpire/ClassCity:CityFoodToCityGrowthConversionFactor) * $Property(../EmpireTypeMajor:EmpireScaleFactor) * 0.15</ToAIParameter>
<ToAIParameter AIParameter="AIEmpireProduction">(0.6 min $(Input)) * $SumProperty(ClassEmpire/ClassCity:CityFood) * $Property(ClassEmpire/ClassCity:CityFoodToCityProductionConversionFactor) * $Property(../EmpireTypeMajor:EmpireScaleFactor) * 0.15</ToAIParameter>
<ToAIParameter AIParameter="AIEmpireGrowth">(0.6 min $(Input)) * $SumProperty(ClassEmpire/ClassCity:CityProduction) * $Property(ClassEmpire/ClassCity:CityIndustryToCityGrowthConversionFactor) * $Property(../EmpireTypeMajor:EmpireScaleFactor) * 0.15</ToAIParameter>
<ToAIParameter AIParameter="AIEmpireProduction">(0.6 min $(Input)) * $SumProperty(ClassEmpire/ClassCity:CityProduction) * $Property(ClassEmpire/ClassCity:CityIndustryToCityProductionConversionFactor) * $Property(../EmpireTypeMajor:EmpireScaleFactor) * 0.15</ToAIParameter>
<ToAIParameter AIParameter="AIEmpireMoney">(0.6 min $(Input)) * $SumProperty(ClassEmpire/ClassCity:CityProduction) * $Property(ClassEmpire/ClassCity:NetCityProductionToCityMoneyConversionFactor) * $Property(../EmpireTypeMajor:EmpireScaleFactor) * 0.15</ToAIParameter>
<ToAIParameter AIParameter="AIEmpireResearch">(0.6 min $(Input)) * $SumProperty(ClassEmpire/ClassCity:CityProduction) * $Property(ClassEmpire/ClassCity:NetCityProductionToCityResearchConversionFactor) * $Property(../EmpireTypeMajor:EmpireScaleFactor) * 0.15</ToAIParameter>
<ToAIParameter AIParameter="AIEmpireResearch">(0.6 min $(Input)) * $SumProperty(ClassEmpire/ClassCity:CityResearch) * 0.15</ToAIParameter>
<ToAIParameter AIParameter="AIEmpireEmpirePoint">(0.6 min $(Input)) * $SumProperty(ClassEmpire/ClassCity:CityCityPoint) * 0.15</ToAIParameter>
</AIParameterConverter>
---------------------------------------------------------------------------

But this converter is call even with, for example, any techs giving Food. and the converter add many others things, like military.
If I look a classic Food converter, it look more like this :

---------------------------------------------------------------------------
<!-- Flat food bonus that always applies -->
<AIParameterConverter Name="CityFood">
<!-- city -->
<ToAIParameter AIParameter="AICityGrowth">$(Input) * $Property(CityFoodToCityGrowthConversionFactor)</ToAIParameter>
<ToAIParameter AIParameter="AICityProduction">$(Input) * $Property(CityFoodToCityProductionConversionFactor)</ToAIParameter>
<!-- empire -->
<ToAIParameter AIParameter="AIEmpireGrowth">$(Input) * $Property(ClassEmpire/ClassCity:CityFoodToCityGrowthConversionFactor) * $Property(../EmpireTypeMajor:EmpireScaleFactor)</ToAIParameter>
<ToAIParameter AIParameter="AIEmpireProduction">$(Input) * $Property(ClassEmpire/ClassCity:CityFoodToCityProductionConversionFactor) * $Property(../EmpireTypeMajor:EmpireScaleFactor)</ToAIParameter>
</AIParameterConverter>
---------------------------------------------------------------------------

Why ?
I like the idea to power up some techs, but I don't know if I should use your converter, or make adapted one to each part (food, dust, ...)
My main problem with my mod wil lbe : Doing AI for tech AIParameter/converters. But I would surely need to follow your way and give a boost to some techs.
Thanks
Last edited by Enchanteur; 4 Mar, 2017 @ 4:22am
< >
Showing 1-14 of 14 comments
Enchanteur 4 Mar, 2017 @ 4:30am 
Another question.
As I ever done some parameters, there is some about military upgrade. Like a tech giving a %bonus to attack. So here, I need to know what is base attacks of units/empire, then give to AI information if this is worth it or not to get a % bonus about that.
And I was finding the vanilla game parameter quite good, because it look at exactly what I want, what is attack of units.

----------------------------------------------

<AIParameterConverter Name="EmpireUnitAttackPercent">
<!--<ToAIParameter AIParameter="AIEmpireMilitaryPower">$(Input) * 4 * $SumProperty(ClassEmpire/Garrison/ClassUnit:AttributeAttack)</ToAIParameter>-->
<ToAIParameter AIParameter="AIEmpireMilitaryPower">$(Input) * 0.3 * $Property(ClassEmpire:MilitaryPower)</ToAIParameter>
</AIParameterConverter>

----------------------------------------------

I can see this parameter is put into comment in your code, and replace with a global one.
Why ?
If I want to keep my formula but use your mod, probably I will have to use a new converter. But before I would like to know the reason of your change. Because if it's better, I should choose also that.
Enchanteur 4 Mar, 2017 @ 4:36am 
About this one :

----------------------------------------------------

<!-- "Mill Foundry" -->
<AIParameterDatatableElement Name="TechnologyDefinitionIndustry0">
<AIParameter Name="CityProduction" Value="6"/>
<AIParameter Name="CityProductionPercent" Value="0.15"/>
<AIParameter Name="AITechMustHave" Value="0.25 * (0 max ($Property(../EmpireTypeMajor:CurrentEra) - 1)) * (0 max (1 - $Count(ClassEmpire/ClassResearch,TechnologyIndustry0)))"/>
</AIParameterDatatableElement>

----------------------------------------------------

I have no question. I find this parameters really amazing. Making AI not rushing era and get a stronger position. I will re use this idea.

Enchanteur 4 Mar, 2017 @ 4:39am 
Another question (but I will not use that, I'm just curious).
I saw change in empire plan.

---------------------------------------------------------------------------
@path=AI/AIStrategicPlanDefinition[EconomicFocus].xml

<ParameterModifiers Name="EmpirePlan">
<AIModifier Name="AIEmpirePlanEconomyAndPopulation1" Value="1"/>
<AIModifier Name="AIEmpirePlanEconomyAndPopulation2" Value="1"/>
<AIModifier Name="AIEmpirePlanEconomyAndPopulation3" Value="1"/>
<AIModifier Name="AIEmpirePlanEconomyAndPopulation4" Value="1"/>

<AIModifier Name="AIEmpirePlanEmpireAndExpansion1" Value="0.2"/>
<AIModifier Name="AIEmpirePlanEmpireAndExpansion2" Value="1"/>
<AIModifier Name="AIEmpirePlanEmpireAndExpansion3" Value="0.2"/>
<AIModifier Name="AIEmpirePlanEmpireAndExpansion4" Value="1.2"/>

<AIModifier Name="AIEmpirePlanMilitary1" Value="0.5"/>
<AIModifier Name="AIEmpirePlanMilitary2" Value="0.2"/>
<AIModifier Name="AIEmpirePlanMilitary3" Value="0.2"/>
<AIModifier Name="AIEmpirePlanMilitary4" Value="0.2"/>

<AIModifier Name="AIEmpirePlanScienceAndIndustry1" Value="0.7"/>
<AIModifier Name="AIEmpirePlanScienceAndIndustry2" Value="0.7"/>
<AIModifier Name="AIEmpirePlanScienceAndIndustry3" Value="0.7"/>
<AIModifier Name="AIEmpirePlanScienceAndIndustry4" Value="0.7"/>
</ParameterModifiers>
---------------------------------------------------------------------------

What I don't understand, it's why Military is so much boosted as this Definition is made for the Economic focus phase, and AI should rather focus on empire plan about economy, pop, even science.
ninakoru  [developer] 4 Mar, 2017 @ 4:24pm 
AITechMustHave: This parameter add all FIDSI and Military power, because at war, no matter how high is the non-military tech values, AI will always go for the military one. I tried to multiply x5 all non military-power related values in test games and the AI tech selection was still the same.

I changed the values related to percentage attack / defense / damage to total military value instead of the 'correct' value because military power has so big values that the others are usually ignored by the AI (in vanilla, AI NEVER gets Brigade System or Serum of Iteru because of this).

About why the L1 military tech has usually high values: because AI will spend 80% of their city build orders in units, no matter what empire state they have. This is optimal in any situation for the AI. The 0.2 values are everywhere in the file to fill the situations in which AI has enough Empire points to cover all four empire plan branches.
Enchanteur 4 Mar, 2017 @ 11:48pm 
Thank for yours answers !!
I check that about military.
For now I've in mind something like :

<AIParameterConverter Name="EmpireUnitAttackPercent">
<ToAIParameter AIParameter="AIEmpireMilitaryPower">
$(Input) * (4 * $SumProperty(ClassEmpire/Garrison/ClassUnit:AttributeAttack) + 0.3 * $Property(ClassEmpire:MilitaryPower))
</ToAIParameter>
</AIParameterConverter>

And I will adapt the "0.3" multiplicator, maybe "0.25" or what needed according what I see during analys.
ninakoru  [developer] 5 Mar, 2017 @ 12:58am 
Yeah, here the problem is that we cannot see the values considered for the techs because the research debug is broken. So I gone the hard way of trial and error.
Enchanteur 5 Mar, 2017 @ 1:09am 
I need to keep something relative to real parameter, because in my next mod, I ve a tech giving a bonus to Infantery, and another to Archery.
So AI have to choose the best. If military power is 1000 and bonus is 10% (let's says it become 1000*0.1*0.25 = 25 after calculation), then AI will choose 25+infantery bonus or 25+archery bonus. So it will keep something for make the good choice, a value higher than another.
ninakoru  [developer] 5 Mar, 2017 @ 1:14am 
For that, you may want to use these two variables: from EmpireUnlockUnitRanged -> $(NumberOfAvailableRangedUnits) and from EmpireUnlockUnitInfantry -> $(NumberOfAvailableInfantryUnits).

That way you can reduce the value or boost it if the AI has Ranged/Infantry units available in their designs.
Enchanteur 5 Mar, 2017 @ 2:05am 
I used this :
$Count(ClassEmpire/Garrison/ClassUnit,UnitClassInfantry)
But it was months ago. I didnt release the mod because AI was not ready, and after, last year I didnt mod anything. I'm thinking about release an Alpha version, then work on a better AI. I've done at least a default AI for each tech/improvement, but rather bad.
I don't know what $(NumberOfAvailableRangedUnits), I never saw that, so i will make some search in public and see that. Thanks !
Enchanteur 20 Mar, 2017 @ 12:30pm 
Hi, as I am working on AI parameters of my future mod, I saw something maybe wrong in your :

AIParameterConverters[Military].xml

<AIParameterConverter Name="EmpireUnitDamagePercent">
<!--<ToAIParameter AIParameter="AIEmpireMilitaryPower">$(Input) * 6 * $SumProperty(ClassEmpire/Garrison/ClassUnit:AttributeDamage)</ToAIParameter>-->
<ToAIParameter AIParameter="AIEmpireMilitaryPower">$(Input) * 0.5 $Property(ClassEmpire:MilitaryPower)</ToAIParameter>
</AIParameterConverter>

Here :
<ToAIParameter AIParameter="AIEmpireMilitaryPower">$(Input) * 0.5 $Property(ClassEmpire:MilitaryPower)</ToAIParameter>

there is no " * ", it should be :
<ToAIParameter AIParameter="AIEmpireMilitaryPower">$(Input) * 0.5 * $Property(ClassEmpire:MilitaryPower)</ToAIParameter>

Same with EmpireUnitLifePercent
Enchanteur 20 Mar, 2017 @ 12:49pm 
I will try a formula as I said before : I will take in account original property, but add your bonus. For that, I will put a parameter able to balance it, and I will change the parameter after testing.
If I resume yours army empire modificator, it make that :

?iMilitaryBalance? = 0.5

?iNinakoruAttackPercent? = 0.3 * $Property(ClassEmpire:MilitaryPower) * ?iMilitaryBalance?

?iNinakoruDefensePercent? = 0.3 * $Property(ClassEmpire:MilitaryPower) * ?iMilitaryBalance?

?iNinakoruDamagePercent? = 0.5 * $Property(ClassEmpire:MilitaryPower) * ?iMilitaryBalance?

?iNinakoruLifePercent? = 0.5 * $Property(ClassEmpire:MilitaryPower) * ?iMilitaryBalance?

?iNinakoruFasterMovement? = 0.3 * $Property(ClassEmpire:MilitaryPower) * ?iMilitaryBalance?

?iNinakoruEquipementSlot? = 0.4 * $Property(ClassEmpire:MilitaryPower) * ?iMilitaryBalance?

?iNinakoruArmySize? = 0.8 * $Property(ClassEmpire:MilitaryPower) * ?iMilitaryBalance?

(it look a little strange, but I put all of this in variables, and it will be replace by values, as Im using a selfmade tool for generating xml files of mods).

In your mod, there is no parameters about that :

--- Initiative, UnitRegenModifier, ExperienceRewardAtCreation

Do you have an idea of what multiplicator i should use ?

And about Flat bonus ?, how to use your method and what values to use ?

Thanks.
Enchanteur 20 Mar, 2017 @ 1:32pm 
I show you what it make with this

<!-- == Increase anything of all units in the empire, formula have to be designed in tech/improvement AI files == -->
<AIParameterConverter Name="GenericMilitaryBonus">
<ToAIParameter AIParameter="AIEmpireMilitaryPower">$(Input)</ToAIParameter>
</AIParameterConverter>

(i use this generic converter, as it's more easy for me because i generate AIParameter with variables).
Here this is for a tech giving to all ranged units a bonus damage of 2% x their Vision.
You can see, I added your army bonus inside * iMilitaryBalance :

<AIParameter Name="GenericMilitaryBonus" Value="0.02 * ((6 * $SumProperty(ClassEmpire/Garrison/ClassUnit,UnitClassRanged:VisionRange)
/ $Count(ClassEmpire/Garrison/ClassUnit,UnitClassRanged) * $SumProperty(ClassEmpire/Garrison/ClassUnit,UnitClassRanged:AttributeDamage))+(0.5 * $Property(ClassEmpire:MilitaryPower) * 0.5))" />

ninakoru  [developer] 20 Mar, 2017 @ 3:45pm 
Yeah, flat bonuses on "AIEmpireMilitaryPower" for for some reason doesn't work very well unless is Military Power related. The exception are the strategic techs, but the calculations result in huge numbers anyways.

For "ExperienceRewardAtCreation", to have chances to be selected, I would use something like:

$(Input) * ($Property(ClassEmpire:MilitaryPower) / 200)

"EmpireUnitInitiativePercent":

$(Input) * 0.75 * $Property(ClassEmpire:MilitaryPower)

"UnitRegenModifier":

$(Input) * $Property(ClassEmpire:MilitaryPower)

Another option would be to not use (ClassEmpire:MilitaryPower) in any tech, but that would need lots of testing I guess.
ninakoru  [developer] 20 Mar, 2017 @ 3:46pm 
By the way, many thanks for the correction, for some reason is working properly anyways, AI should be headed for Serum of Iteru if is at war when it starts the Era 6 techs.
< >
Showing 1-14 of 14 comments
Per page: 1530 50