By Kevsoft on Jul 17, 2021 at 6:07 PM
  1. Kevsoft

    Kevsoft XLiveless Dev
    Staff Member Administrator

    Joined:
    Oct 24, 2017
    Messages:
    318
    Likes Received:
    319
    Trophy Points:
    63
    Header_-_Prioritization.png
    "Behind the BANG!" is a new irregular blog series that looks behind the scenes of the mechanics of the game engine.

    Micromanagement is a key skill in AOEO, especially in PvP. Still, it would be lame if you had to command every single unit all the time. Therefore, there are times when units are automatically commanded, such as when an enemy unit comes near. When a single enemy unit comes along, it's pretty clear what's being attacked. But what about when a whole army comes? Which unit from the army should be attacked first? Now you could say it's clear anyway: the unit closest to you will be attacked. But this is not the case, or at least not exclusively. Here a system called "target selector" is used which tries to calculate the best possible target. This system is not only used in AOEO, but also in AOE3 + (DE) and AOM, whereby there are differences between the versions.

    == The Target Selector ==
    The target selector is used when there are several possible targets. However, it is not only used for attacking, but also in other (non-military) situations. The target selector offers 4 different modes:
    Target_Selector_Modes.png

    Generally, the target selector is used when the last action is finished and no further actions have been set by the player. The game tries to select the best possible target for the given action.

    == The process ==

    But how does the target selector work? This process is divided into 4 parts:
    • Determination/filtering of the valid targets.
    • Calculation of factors to determine a priority score.
    • Special adjustments of the score.
    • Sorting the valid targets according to the score.
    At the end of this process, the goal with the highest priority score is selected.

    == Filtering ==

    First of all, it must be determined which targets are actually valid. Depending on the situation, these filter parameters can be used. For example, in an attack scenario, the filters are set very loosely. Here you would search for those targets that you can attack. In a healing scenario, for example, you would only search for friendly targets. The filters can be set according to certain unit types, abstract types, player ID, relations (friendly or hostile) and many other settings. All valid targets that match these filter rules are collected in a list.

    == The Factors ==
    As mentioned before, distance is not the only value used for prioritization. The target selector can use the following factors to calculate the priority score:

    Target_Selection_Factors.png

    There are also other factors, but they are not currently used (1). For each of these factors, the respective minimum and maximum value is calculated from all possible targets, and then a relative value between 0 and 1 is calculated for each possible target.

    Health_Score_Example.png
    Small example:
    • 3 possible targets:
      • Target 1: 10 HP
      • Target 2: 70 HP
      • Target 3: 110 HP
    • Accordingly, minimum value: 10 HP and maximum value: 110 HP
    • Accordingly, value range = maximum value - minimum value = 110 HP - 10 HP = 100 HP
    • Calculation of the relative value: (maximum value - target hp) / value range
      • Target 1: (110 HP - 10 HP) / 100 HP = 1.0
      • Target 2: (110 HP - 70 HP) / 100 HP = 0.4
      • Target 3: (110 HP - 110 HP) / 100 HP = 0.0
    The calculation in AOE3 is basically the same, only with the factor "Working Unit" AOEO makes a difference: Here the maximum value is capped at 5. This means that if a unit is attacked by more than 5 enemy units then it makes no difference. This also means that the values from 0 to 5 are weighted more differently. The "working unit" factor is also calculated differently depending on the prioritization mode. In attack mode, smaller values are preferred, which means that units that are not yet attacked by another unit are preferred. In gathering mode, for example, resources that are already being mined by another villager are preferred.


    Now the individual factors are weighted and the base score is calculated. These are (for AOEO):
    • Distance: x95
    • Hitpoints: x5
    • Working Units: x35

    There are special cases where one or the other factor is adapted, but by default these weightings are used. This means that the different factors have a different influence on the score. The score is now added up from all factors with the respective weights for each individual target:

    base score = distance factor * 95 + hitpoints factor * 5 + working unit factor * 35

    For our example, the weighted HP factor would then be:
    • Target 1: 1.0 * 5 = 5.0
    • Target 2: 0.4 * 5 = 2.0
    • Target 3: 0.0 * 5 = 0.0
    Thus, a base score has now been calculated for each individual possible target.

    == Special Adjustments ==
    Depending on the priority mode and situation, this score is added and subtracted with absolute values to prioritize different groups differently in special cases.

    In attack mode, units are treated equally in principle. Anyone who has played AOEO/AOE3 for a long time will have noticed that enemy units are preferred over enemy buildings. For buildings, however, an extra distinction is made.

    The prioritization is as follows:
    Target_Selection_Priority.png

    An exception (AOEO exclusive) are units with the flag "AttackBuildingsFirst", which is set for siege units, like rams or palintonons. In this case, buildings are preferred over units. Only if there are no buildings in the list, units are prioritized.

    Then the prioritization is as follows:
    Target_Selection_Priority_Anti_Building.png

    There is also a special case for the gathering mode. If the respective target is within 10 meters, then a distinction is made between resource types. So the prioritization is as follows:
    Gathering_Mode_Priority.png

    == Sorting & Finalization ==

    Now the list is sorted according to the priority score. The best result can then be processed.

    In conclusion, we can say:
    • Distance is still the primary value, but not the exclusive one.
    • Units that have low HP and are not yet attacked by another unit are attacked preferentially.
    • Low HP is also preferred for healing and building, but only to a very small extent.
    • Building types are prioritized very differently when attacking.
    • In gathering mode, certain types of resources are preferred and resources that are already being mined by other villagers.
    What do you think about the blog? Let us know in the comments below!

    ========
    Previous Behind the BANG! blogs:
    ========

    All current and future content will stay 100% free and accessible to everyone.

    ========
    Thank you so much for reading, and we will see you all next time!

    Project Celeste Development Team

    ========
    The Romans are here! Watch the Overview Trailer.

    Project Celeste is completely free and always will be. However, we gladly accept donations for our overhead costs, which are larger than we have budgeted. If you want to support us, you can do so HERE.

    Read every Romans related blog HERE.

    Tell your friends! Join our Discord HERE.
    ========

    (1) Damage and Angle
     
    zenorhk, purpleganja, BOSAIF and 15 others like this.
  2. Loading...

    Similar Threads - Behind BANG Prioritize
    1. Kevsoft
      Replies:
      12
      Views:
      2,229
    2. Kevsoft
      Replies:
      16
      Views:
      2,176
    3. PF2K
      Replies:
      3
      Views:
      1,064

Comments

Discussion in 'News' started by Kevsoft, Jul 17, 2021.

    1. MsMuffins

      MsMuffins Champion

      Joined:
      May 3, 2019
      Messages:
      57
      Likes Received:
      85
      Trophy Points:
      18
      Very interesting, love these, keep it up!

      Some kinda aware of but dont know stuff too (especially not the detailed maths part), anyways helps a lot to clarify everything, but the villager resource priority completely new!. Never noticed this. Just thought kinda splits them equally according to distance.
       
      Kevsoft likes this.
    2. frogs.poison

      frogs.poison Hippikon

      Joined:
      May 19, 2020
      Messages:
      165
      Likes Received:
      104
      Trophy Points:
      43
      The target selection helps to explain why units will AFK for 5+ seconds at a time at a wall before finally attacking the wall.
       
    3. Kevsoft

      Kevsoft XLiveless Dev
      Staff Member Administrator

      Joined:
      Oct 24, 2017
      Messages:
      318
      Likes Received:
      319
      Trophy Points:
      63
      Well probably not "AFK", but rather focusing on different buildings first. Basically when other buildings are near, walls are the last target to be focused.
       
    4. Andy P XIII

      Andy P XIII Moderator
      Moderator

      Joined:
      Nov 14, 2017
      Messages:
      514
      Likes Received:
      762
      Trophy Points:
      93
      Could we plausibly change this stuff on a unit-by-unit basis? Like create a unit that prioritizes differently?
       
    5. Kevsoft

      Kevsoft XLiveless Dev
      Staff Member Administrator

      Joined:
      Oct 24, 2017
      Messages:
      318
      Likes Received:
      319
      Trophy Points:
      63
      If you mean on a per unit-type basis then yes. (Siege for example has the "AttackBuildingsFirst" flag)
       
      Andy P XIII likes this.
    6. purpleganja

      purpleganja Champion

      Joined:
      Jul 29, 2019
      Messages:
      72
      Likes Received:
      53
      Trophy Points:
      18
      Thanks, I love this blog! This explains a lot of what I have seen in games.

      Would be nice if balista, catapult and onagers and their ship version prioritized like siège units! Well balista is nice for unit dmg, but i would really like balista ships to prioritize buildings or a way to switch like attack stance ( just dreaming here ;)
       
      Andy P XIII likes this.
    7. Andy P XIII

      Andy P XIII Moderator
      Moderator

      Joined:
      Nov 14, 2017
      Messages:
      514
      Likes Received:
      762
      Trophy Points:
      93
      Yeah, off hand I have no reason why we *would* do this, but it sounds like we at least *could* create a unit that, I don't know, prioritizes attacking Farms or Walls or something first.
       
    8. frogs.poison

      frogs.poison Hippikon

      Joined:
      May 19, 2020
      Messages:
      165
      Likes Received:
      104
      Trophy Points:
      43
      Perhaps it could be something for Priests? I.E. Priest with +Convert rate staves could prioritize whatever unit type the staffs for?

      Going a step further, perhaps it could be something to add to +% bonus damage vs X unit type gear as well, so if you equip, say, bonus cav damage arrows on Mounted Archers, said Mounted Archers would prioritize Cavalry units a bit more compared to, say, max damage Mounted Archers which would go by whatever is closer/lower health.
       
      Gara V likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice