AI and over stacking of defensive units on Capitals

  • Beware guesswork follows;

    This bit of code it taken from here
    line 582
    // Calculate defense value for prioritization
    final double territoryValue =
    * (2.0 * production
    + 10.0 * isFactory
    + 0.5 * cantMoveUnitValue
    + 0.5 * neighborValue)
    * (1 + 10.0 * isMyCapital)
    * (1 + 4.0 * isEnemyOrAlliedCapital);

    Having looked through the whole file, a pure guess is that the isMyCapital and isFactory and production all combine to have a very high defensive value that causes over stacking of Defensive units?

    I notice that 2.0 * production + 10.0 * isFactory will give a value that exceeds the isMyCapital alone, does this mean that a Factory with 3 production with have a value of 16 verses 11 for isMyCapital ?

    Also should there more brackets in the math to make sure the logic is clear?

    If so I think this is wrong, maybe the following values might go towards fixing the over stacking of defensive units.
    1.0 * production
    2.0 * isFactory
    This would still give a working production 3 isFactory a value of 5, that would equal isEnemyOrAlliedCapital, so these values might have to be lower?

  • Just found this;

    This bit of code it taken from here
    line 635
    // Calculate defense value for prioritization
    final double territoryValue =
    (2.0 * production + 4.0 * isFactory + 0.5 * defendingUnitValue)
    * (1 + isFactory)
    * (1 + 10.0 * isMyCapital);

    Note the difference in the isFactory values, 1 for above but in the previous post 10, I would expect them to be similar, if not the same.

    Maybe the 10 in the previous post should be 1 like above?

    Also note the use of isFactory twice, this is a BIG value and can be bigger than isMyCapital, if a Factory is not in the isMyCapital terrirtory.

    Could this cause the AI to abandon the Capital in favour of a factory?

  • Thinking about this a bit more, maybe the formula is incomplete?

    Perhaps the variable enemyDistance should be taken into account and checked if the enemy is 4+ territories away?

    If so, then the following might be considered?

    In both files ProNonCombatMoveAi and ProPurchaseAi
    The Capital values should not be calculated, as its not under threat?

    In ProPurchaseAi the defendingUnitValue could also be excluded, as that territory is not under threat?

  • Is it possible to design a specific AI for particular maps by containing its files along zips?

  • I would say yes, but the ends dont justify the means, which translates as, it would take too long to customise the AI for just one map verses the hours played, it would just not be worth the time spent, unless you did it for yourself.

  • But how could a common AI perform well in any maps even if developed well enough? I mean games uses very different rules just wondering if a common AI could be capable of dealing these differences.

  • Redrum (i think) was hoping to eventually make a map specific AI properties file to help it with individual maps.

  • Are users allowed to change the codes? If yes how long it will take for the new ai adopt the changes? Did you ever test the ai with these changes?

  • Currently users cannot change the codes/values.

    In case you have not seen Trevan post here

    No I did not test the AI, Im just best guessing at what to do as the AI is complicated.

  • Admin

    @TheDog The value is used to prioritize which territories to try to defend (do I defend my capital or this factory or this random territory) not how much to defend them with. So this probably is not causing overstacking of capitals.

Log in to reply