XCOM: Enemy Unknown

File information

Last updated

Original upload

Created by

szmind

Uploaded by

szmind

Virus scan

Safe to use

UFO AI for stance picking (11 comments)

  1. szmind
    szmind
    • supporter
    • 30 kudos
    I will start with what I have already presented in 'Posts' section. My thoughts concentrate on how squadron size and formation (composition of stances) should impact UFO stance. Larger squadron should definitely encourage UFO to pick DEF to benefit from lone bullets. Though if majority of supporters is on DEF it is better for UFO to pick BAL. AGG should be considered by UFO against small squadron - cause this 23% becomes much more threat against lots of bullets.
    It is all easy to say, much harder to develop a certain algorithm. Those of you who are skilled at maths may have some ideas. We have the following entries:
    - number reflecting ship's stance: 0 for BAL, 1 for AGG, 2 for DEF
    - aggro stat for every ship in squadron - generally reflecting weapon's level
    - size of squadron
    I would like to ignore ship's offense stat (aim) cause UFO cannot know that. Otherwise I would know how to calculate precisely optimal stance for UFO Algorithm could be long but perfect.
    1. Riwwer
      Riwwer
      • member
      • 0 kudos
      Possible algorithm:

      stance = AGG
      if (mission == Hunt) stance = DEF
      if (mission == Scout or mission == CommandOverwatch) stance = BAL
      if (SquadronSize < 2) stance++
      if (SquadronSize > 4) stance--

      (of course AGG++ remains AGG, as well as DEF--)
      Edit2: In case complete determinism is not desired, then add: stance = stance + Random(-1, 0, 1)

      EDIT: the number reflecting ship's (and UFO's) stance shall be 0(and below)=DEF, 1=BAL, 2(and above)=AGG so that increment arithmetic works correctly.

      While the above is somewhat "euphuistic", in my opinion the following two simple "algorithms" would work just as well:
      1) stance = BAL
      2) stance = Random (DEF, BAL, AGG)
    2. GamerChris9
      GamerChris9
      • member
      • 0 kudos
      Took some time to think about it, this is what i came up with when you asked for details on the stance depending on mission and ufo type:

      (Halfway through i realized that ufos are already characterized by the missions they can be in, so i decided to make it mission only)
      Score = 0
      if (Mission == Scout || Mission == Research) Score = -1
      else if (Mission == Hunt || Mission == Harvest) Score = 0
      else if(Mission == Abduction || Mission == Terror) Score = 1
      else if (Mission == Bomb || Mission == Retaliate) Score = 2;
      else if (Mission == Command Overwatch || Mission == Infiltrate) Score = -2;

      //Including code that evaluates sqaudron size for completeness sake, i quite like the idea of it
      if (SquadronSize < 2) Score++
      if (SquadronSize > 4) Score--

      //Determine the final stance
      roll = roll a 2-sided die
      Stance = BAL //Ufos are balanced by default, and will stay that way if the 50% chances on +1/-1 fail
      if (Score < 0)
      {
      if (Score < 1) Stance = DEF //If the ufo is really cautious because of several modifiers, it always goes defensive
      elseif (roll == 1) Stance = DEF //If the ufo has only one reason to be cautious (mission type, big squadron) it has a 50% chance to go DEF
      }
      if (Score > 0)
      {
      if (Score > 1) Stance = AGG //If the ufo has more reasons to be aggressive it always goes into AGG
      elseif (roll == 1) Stance = AGG //If the ufo has only one reason to be aggressive (mission type, small squadron) it has a 50% chance
      }


      Sorry if its a bit complicated, but this is what i would imagine to be the thinking process of ufos in air combat. Maybe it would need some rebalancing of air stats, based on which ufos can conduct these missions? I am not sure. Anyways, its just a suggestion. I fully understand if its too much work and youd rather not put in the effort for it.
    3. Riwwer
      Riwwer
      • member
      • 0 kudos
      Just making the second part more readable :-) :

      switch (score):
      -4, -3, -2: stance = DEF
      -1: if (Random(0,1) == 0) stance = DEF else stance = BAL
      0: stance = BAL
      1: if (Random(0,1) == 0) stance = BAL else stance = AGG
      2, 3, 4: stance = AGG
    4. szmind
      szmind
      • supporter
      • 30 kudos
      Thanks guys. This is all awesome and valuable suggestions. I truly like the ideas behind. There is though one assumption that you make and you might be wrong :) However leave this one to me. For the time being I read your intentions as: DEF = 'pick a stance that provides greatest chance of survival' while AGG = 'pick a stance that provides highest damage output neglecting survival'.

      Now regarding the 'possibly wrong assumption' - if you are curious.. That is: DEF < BAL < AGG in terms of survival risk :) That is not quite like that in different stages of game. That is because UFO on DEF generally spreads damage over many ships and gives the squadron more time to shoot as a 'whole squadron' thus supporters can shoot longer without major risk (leader bears always the greatest risk). During my tests I had two saves: one was squadron against a Fighter on Hunt mission, second was the same squadron 2-3 days later against Harvester. I was unable to beat the Harvester anyway (cause Phoenix and Laser could not penetrate its armor). But what I have noticed was that my whole squadron used to be squashed or forced to retreat much faster when UFO was on AGG. Cause it would just cut through my squadron like a hot knife through butter - killing one leader after another, effectively and qucikly decreasing the size of squadron within seconds :) 'Best defense is good offense' as we say.

      Or the other way round - think of that: UFO picks DEF for survival, squadron of 5 is all on DEF. What is the benefit of UFO picking DEF? Lone bullets will not harm supporters at all and raw number of 4 supporters makes 23% UFO's dodge rat negligable due to laws of statistics (5 ships firing). It is better for UFO to pick BAL or even AGG (cause with parameters +15/-15 and 23%/23% DEF loses its advantage against AGG - the only advantage is number of supporters) to cut through the squadron quicker.

      But as I said - determining what stance is safest requires additional simulations and calculations. It will take time. For the time being I encourage you to play with default settings and observe how (if at all) efectiveness of the same formation changes with type of UFO and with time (more time passed = more aim for the UFO). Honestly Riwwer - you can safely play with as you call '9 stances' being assured that your 'trick' does not really work :) If you trust my maths skills I tell you that DEF (with its -15 to aim) gives no 'chance-to-hit' advantage against AGG UFO. This is of course the best countermeasure against AGG, but gives no real aim-advantage. On the other hand your experience with UFO always on BAL may yield very valuable conclusions - so maybe you stay with it anyway :)
    5. Riwwer
      Riwwer
      • member
      • 0 kudos
      My problem with your solution (stance = leaderStance) is rather philosophical than game wise: it is not FAIR leader can only face UFO with the same stance while supporters have access to all 9 possibilities.
    6. GamerChris9
      GamerChris9
      • member
      • 0 kudos
      One thing i would include then to make DEF and BAL a viable option for more cautious ufos is to make those stances have shorter engagement times than AGG. Sure, the UFO may only fire a few lone shots at the squadron that wont really harm them, but at the same time it speeds up a lot, making it harder to hit and letting it escape earlier.
    7. szmind
      szmind
      • supporter
      • 30 kudos
      "My problem with your solution (stance = leaderStance) is rather philosophical than game wise: it is not FAIR leader can only face UFO with the same stance while supporters have access to all 9 possibilities."
      I understand you. Still I consider those possibilities as adding great variety into air-game strategy. In fact supporters do not have all 9 possibilities :) Try setting them BAL/AGG while keeping leader (and UFO) on DEF. This is not so easy. It is achievable only if you give superior weapon to the leader and worse to all supporters.
      And about 'fairness' - firstly leader has access to modules and can be withdrawn manually at any stage. Supporters cannot. Also that is the leader who is granted a kill for the job of the whole squadron. I would not say that supporters's access to say DEF vs AGG is any advantage other than immunity to lone bullets.

      Look: UFO has 30 base aim and is set on AGG; your supporter picks DEF with base aim of 45 (quite common)
      Once you supporter becomes the leader:
      UFO chance to hit: (30 + 15) x 0,77 = 35
      DEF jet chance to hit (leader or not): (45 - 15) + 0,23 x [100 - (45 - 15)] = 46
      If the jet picked AGG instead: AGG jet chance to hit (leader or not)= (45 + 15) + 0,23 x [100 - (45 + 15)] = 69!!
      You wanna say that 46% is better (unfair) than 69%?? It is not.

      Your true choice is between:
      1. As long as you DEF supporter is a supporter it hits with 46% chance to hit and is save from lone bullets.
      2. As long as you AGG supporter is a supporter it hits with 69% chance to hit but is vulnerable to lone bullets.

      It looks quite a fair choice. And you do not have to do the peculiar calculations every time - read ADVANCED CONCPETS - "how to read numbers in hangar" section. You can get very good approximation (+/- 1-2%) without calculations.
    8. Riwwer
      Riwwer
      • member
      • 0 kudos
      Pick any of the algorithms presented, or, make a config option to pick an algorithm. IMO nine possibilities in general make the air game unnecessarily more complicated without really adding more to the airgame, while also making the Hangar numbers inaccurate. But this is acceptable. However the fact that the initial leader does not have the same 9 possibilities when fighting UFO as supporters (when they become leaders) do is IMO just plain wrong. It's not about numbers, just philosophically.
      That doesn't mean the mod in general isn't great - it's just this one particular (and rather minor) thing.
    9. szmind
      szmind
      • supporter
      • 30 kudos
      "One thing i would include then to make DEF and BAL a viable option for more cautious ufos is to make those stances have shorter engagement times than AGG. ...."

      Then UFO should always pick the one with shortest engagement time :) Cause its goal is always survival - not shooting down interceptors. Shooting down is just a mean to achive the survival goal. Am I wrong?
    10. GamerChris9
      GamerChris9
      • member
      • 0 kudos
      If the UFO is on a mission that is meant to be aggressive, like terrorizing the country, then shooting the XCOM interceptors down would seem like the better option because it raises public awareness and weakens XCOM's ability to intercept further UFOs. If the intercepting squadron is small and their mission isnt overly cautious, they would think themselves superior and go into a balanced or aggressive stance as well.

      On the other side, if their mission is to stay concealed while scouting or overwatching an area, they would of course try to run rather than pick a fight and risk themselves being captured and exposed. And if the attacking squadron is big, even the UFOs on balanced or aggressive missions would think to themselves that they should be careful and maybe try to run instead of fighting to the death.

      Shooting XCOM down and escaping are both choices the aliens would make, i think.

      Also, something i forgot previously: Ship size could have an effect on what squadron size a UFO considers "small" and "big" when deciding whether they should be more aggressive or defensive. So at example for Scouts and Fighters, the threshold for "small" would be 1, and the threshold for "big" would be 3.
      Meanwhile, for a battleship anything below 4 fighters might be "small", and they might never consider any squadron big at all, so they never go defensive unless their mission tells them to do so.