Author Topic: AI Aggression and Intelligence ranges?  (Read 17390 times)

Offline Thirsk

  • Captain
  • ***
  • Posts: 62
    • View Profile
AI Aggression and Intelligence ranges?
« on: February 07, 2017, 12:07:26 pm »
I had a look at the nightly ruleset for reference to AI units but the values only show Aggression from 0 to 2, whereas nothing is specified for Intelligence. Does anyone know the exact ranges we can use?
« Last Edit: February 07, 2017, 12:09:16 pm by Thirsk »

Offline Nord

  • Commander
  • *****
  • Posts: 1747
  • The Gate is open.
    • View Profile
Re: AI Aggression and Intelligence ranges?
« Reply #1 on: February 07, 2017, 12:35:58 pm »
Agression lower than 5 is for range fighter, 5 and more - melee(but because of game mechanic there will be not much difference)
Intelligence is simple quantity of turns, when alien remembers your units positions, if he has seen them once.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: AI Aggression and Intelligence ranges?
« Reply #2 on: February 07, 2017, 01:13:51 pm »
If any alien sees one of your units, all of them see it. Their intelligence then determines how fast they forget that. Even with an intelligence of zero, they still can remember for one turn. This means if your whole squad is hiding in the same place and an Ethereal with intelligence 0 successfully mind controls any of your units every turn, they can keep making attempts because they can still see your whole squad. They have to fail for an entire turn to forget your squad.

In practice, I find any intelligence value above 2 is essentially infinite: once you've been seen they always know where you are.
« Last Edit: February 07, 2017, 01:16:02 pm by The Reaver of Darkness »

Offline Thirsk

  • Captain
  • ***
  • Posts: 62
    • View Profile
Re: AI Aggression and Intelligence ranges?
« Reply #3 on: February 07, 2017, 02:07:15 pm »
Thanks guys, I'll try and play around and see what the differences are between the aggression numbers. Is 5 the limit to aggression or can it go higher?

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9102
    • View Profile
Re: AI Aggression and Intelligence ranges?
« Reply #4 on: February 07, 2017, 02:25:55 pm »
Agression lower than 5 is for range fighter, 5 and more - melee(but because of game mechanic there will be not much difference)
Intelligence is simple quantity of turns, when alien remembers your units positions, if he has seen them once.

As far as I can read in the source code, relevant aggression values are 0, 1, 2 and 3+.

3+ (e.g. 3 and 7) work exactly the same with the exception of melee odds, which increase with higher aggression. Going over 9 is not desirable, because melee odds would already be above 100% (and combatOdds and escapeOdds, see below, would overflow).

There is some code for combatOdds and escapeOdds for aggression 3+ ... but I don't think it works at all, because:
 - (_unit->getAggression() / 10) for aggression < 10 is 0... no effect
 - (_unit->getAggression() / 10) for aggresion >= 10 is 1 or more... no effect because of std::min/max
Might be a bug: https://github.com/SupSuper/OpenXcom/blob/master/src/Battlescape/AIModule.cpp#L1301
I'll ask Warboy.
« Last Edit: February 07, 2017, 02:42:42 pm by Meridian »

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9102
    • View Profile
Re: AI Aggression and Intelligence ranges?
« Reply #5 on: February 07, 2017, 03:00:30 pm »
I'll ask Warboy.

Consulted with Warboy on IRC and...
...yeah, definitely a bug.
Tested in Visual Studio (both Debug and Release mode) and as standalone EXE on Windows too... all 3 interpret the division as integer division.

I'll PR a fix today.

Offline Thirsk

  • Captain
  • ***
  • Posts: 62
    • View Profile
Re: AI Aggression and Intelligence ranges?
« Reply #6 on: February 07, 2017, 03:35:03 pm »
Woah now there's a lot more numbers to try.

So far I've tested aggression 5 but when the AI has both melee and throwable in hand, it ends up using the throwable rather than melee. I was hoping it would come in close for a melee attack but have yet to come across that scenario yet. Unless I drop their throwable completely and give them nothing but grenades and melee weapons, they never seem to go into a melee fight.

Oh what a strange coincidence I actually helped indirectly with bug testing haha! I'll try aggression 7 when it's all fixed  :D

Offline hellrazor

  • Commander
  • *****
  • Posts: 2027
  • Deep Ruleset Digger & Bughunter
    • View Profile
    • Github Account
Re: AI Aggression and Intelligence ranges?
« Reply #7 on: February 07, 2017, 03:40:06 pm »
Hm.., I guess Chryssalids will now charge any reachable target in the future, same goes for Berserkers muahahahaha!.
Thanks for the 3+ option Meridian wasn't aware of that will conduct some tests on the melee units in my mod.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9102
    • View Profile
Re: AI Aggression and Intelligence ranges?
« Reply #8 on: February 07, 2017, 04:16:05 pm »
Oh what a strange coincidence I actually helped indirectly with bug testing haha! I'll try aggression 7 when it's all fixed  :D

Actually, it was Nord's post, which made me look and check... because it just sounded too weird. Arbitrary number 5 just makes no sense, can't imagine someone would code it like that. And it is also not in line with documentation.

Usually I stay a mile away from AI code.... because spoilers!

Offline Nord

  • Commander
  • *****
  • Posts: 1747
  • The Gate is open.
    • View Profile
Re: AI Aggression and Intelligence ranges?
« Reply #9 on: February 07, 2017, 06:40:46 pm »
Woah now there's a lot more numbers to try.

So far I've tested aggression 5 but when the AI has both melee and throwable in hand, it ends up using the throwable rather than melee.
Keep in mind, that melee will be chosed only when distance to target is short enough.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9102
    • View Profile
Re: AI Aggression and Intelligence ranges?
« Reply #10 on: February 07, 2017, 07:07:09 pm »
Keep in mind, that melee will be chosed only when distance to target is short enough.

What exactly is "short enough"?

I don't see any limitation other than 20 tiles (=visibility limit).
Also, from experience, Chryssalids can charge from far far away...

Offline Hobbes

  • Commander
  • *****
  • Posts: 2102
  • Infiltration subroutine in progress
    • View Profile
Re: AI Aggression and Intelligence ranges?
« Reply #11 on: February 07, 2017, 09:09:18 pm »
Usually I stay a mile away from AI code.... because spoilers!

It is a losing battle with curiosity... ;)

Offline Nord

  • Commander
  • *****
  • Posts: 1747
  • The Gate is open.
    • View Profile
Re: AI Aggression and Intelligence ranges?
« Reply #12 on: February 07, 2017, 09:20:37 pm »
What exactly is "short enough"?

I don't see any limitation other than 20 tiles (=visibility limit).
Also, from experience, Chryssalids can charge from far far away...
You mean, that chryssalid will run to my units even if he have not enough t.u. to attack them in this turn? Odd, never saw that.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9102
    • View Profile
Re: AI Aggression and Intelligence ranges?
« Reply #13 on: February 07, 2017, 09:44:16 pm »
You mean, that chryssalid will run to my units even if he have not enough t.u. to attack them in this turn? Odd, never saw that.

No, I didn't say specifically that.
If he doesn't have enough TUs, he may decide otherwise. But if he does have enough TUs, then the distance doesn't matter.

That's why I asked what you mean by "short enough"... if you define that by time units, instead of actual distance, you're right (i.e. it doesn't always have to choose to charge).
« Last Edit: February 07, 2017, 09:46:11 pm by Meridian »

Offline Countdown

  • Colonel
  • ****
  • Posts: 246
    • View Profile
Re: AI Aggression and Intelligence ranges?
« Reply #14 on: February 08, 2017, 10:34:40 am »
If any alien sees one of your units, all of them see it. Their intelligence then determines how fast they forget that. Even with an intelligence of zero, they still can remember for one turn. This means if your whole squad is hiding in the same place and an Ethereal with intelligence 0 successfully mind controls any of your units every turn, they can keep making attempts because they can still see your whole squad. They have to fail for an entire turn to forget your squad.

In practice, I find any intelligence value above 2 is essentially infinite: once you've been seen they always know where you are.
I've always wondered about this. By "remembering" your position, does that mean that all the alien units remember where you WERE or do they know where you ARE? Like if I'm spotted, and move away and hide, is that pointless since they automatically know where I am even if it's far away from where I was spotted?

Based on my experience I assume they remember where you ARE even if you move because there have been times when I thought I'd be successful in running and hiding, but I'm found immediately anyway and it seems unlikely the AI would have just happen to walk to the random corner where I was.