OpenXcom Forum

Modding => Work In Progress => Topic started by: Thirsk on February 07, 2017, 12:07:26 pm

Title: AI Aggression and Intelligence ranges?
Post by: Thirsk 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?
Title: Re: AI Aggression and Intelligence ranges?
Post by: Nord 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.
Title: Re: AI Aggression and Intelligence ranges?
Post by: The Reaver of Darkness 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.
Title: Re: AI Aggression and Intelligence ranges?
Post by: Thirsk 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?
Title: Re: AI Aggression and Intelligence ranges?
Post by: Meridian 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.
Title: Re: AI Aggression and Intelligence ranges?
Post by: Meridian 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.
Title: Re: AI Aggression and Intelligence ranges?
Post by: Thirsk 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
Title: Re: AI Aggression and Intelligence ranges?
Post by: hellrazor 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.
Title: Re: AI Aggression and Intelligence ranges?
Post by: Meridian 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!
Title: Re: AI Aggression and Intelligence ranges?
Post by: Nord 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.
Title: Re: AI Aggression and Intelligence ranges?
Post by: Meridian 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...
Title: Re: AI Aggression and Intelligence ranges?
Post by: Hobbes 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... ;)
Title: Re: AI Aggression and Intelligence ranges?
Post by: Nord 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.
Title: Re: AI Aggression and Intelligence ranges?
Post by: Meridian 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).
Title: Re: AI Aggression and Intelligence ranges?
Post by: Countdown 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.
Title: Re: AI Aggression and Intelligence ranges?
Post by: Solarius Scorch on February 08, 2017, 08:34:04 pm
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?

Yes, they know where you ARE for as many turns after spotting you as their Intelligence score.
Title: Re: AI Aggression and Intelligence ranges?
Post by: The Reaver of Darkness on February 09, 2017, 03:05:26 am
Simply put, it's not intelligence or memory, but clairvoyance.
Title: Re: AI Aggression and Intelligence ranges?
Post by: Countdown on February 09, 2017, 09:25:16 am
Thanks for the explanation. I always suspected that was the case, but didn't know 100% for sure. Note to self: You can run, but you can't hide.
Title: Re: AI Aggression and Intelligence ranges?
Post by: Thirsk on February 09, 2017, 10:23:56 am
Thanks for the explanation. I always suspected that was the case, but didn't know 100% for sure. Note to self: You can run, but you can't hide.

Lol saying it like that puts the image of a Scream/Friday 13th psychopath chasing you with a knife into mind!
Title: Re: AI Aggression and Intelligence ranges?
Post by: Meridian on February 09, 2017, 10:44:53 am
Note to self: You can run, but you can't hide.

Well, if you just hide around a corner, they need to spend TUs to come closer to you and won't be able to shoot at all (or will get reaction fired at because of low TUs); and be sitting ducks or dead.
This feature (as every other feature) can also be used to your advantage :)
Title: Re: AI Aggression and Intelligence ranges?
Post by: Kjotleik on February 09, 2017, 06:25:57 pm
Well, if you just hide around a corner, they need to spend TUs to come closer to you and won't be able to shoot at all (or will get reaction fired at because of low TUs); and be sitting ducks or dead.
This feature (as every other feature) can also be used to your advantage :)


...so, when will the Alternate Movement-methods be programmed into the AI? Teach them to take advantage of the Mutual Surprise rule for avoiding reaction-fire, and shoot you instead, when rounding corners would make them a bit...hm... harder to deal with, right?    :o ;D

...or does this rule not apply when they know where you are? I'm not sure...
Title: Re: AI Aggression and Intelligence ranges?
Post by: Meridian on February 09, 2017, 06:32:56 pm
It does apply.

And what should really be done, is not allow xcom to strafe (...or trigger reaction fire anyway).
IMO running is fine and can be balanced... strafing is pure cheating of the engine (and not realistic anyway).

And now I should go stand in the corner of shame for using it too... what have I become?!
Title: Re: AI Aggression and Intelligence ranges?
Post by: Kjotleik on February 09, 2017, 06:51:58 pm
And what should really be done, is not allow xcom to strafe (...or trigger reaction fire anyway).
IMO running is fine and can be balanced... strafing is pure cheating of the engine (and not realistic anyway).

Yes, I would welcome a change to not allow strafing. I know I don't have the discipline to avoid using it when it is so....so...available.    :-[
At the same time I feel that running is natural for soldiers in war. It is one of those things that I missed in the original game in the 90s.
The stamina-system is in itself the perfect tool to balance running.
Title: Re: AI Aggression and Intelligence ranges?
Post by: Solarius Scorch on February 09, 2017, 07:08:28 pm
And what should really be done, is not allow xcom to strafe (...or trigger reaction fire anyway).

Wait, so strafing doesn't provoke reaction fire? I didn't know; that's dumb.

But I don't think removing it is a good idea. Yes, the aliens can't use it, but that's a separate problem. Still, without it I would go back to how it worked in the OG: go back one tile so that I could make a diagonal step in order to come out looking at the enemy... It was silly beyond measure, strafing is much better.
Title: Re: AI Aggression and Intelligence ranges?
Post by: Kjotleik on February 09, 2017, 07:35:37 pm
...without it I would go back to how it worked in the OG: go back one tile so that I could make a diagonal step in order to come out looking at the enemy... It was silly beyond measure, strafing is much better.

So the point is (if I understand you correctly) that it is the Mutual Surprise rule that is the problem. Even if you and the alien see each other at the same time, the alien should be able to reaction-fire IF it has the initiative (more TUs remaining x Reaction stats than the player.) And if the player has the initiative, he should be able to turn 90 degrees and fire at the alien after rounding a corner, before getting hit with reaction-fire.

In my head, it should work the same way for both sides no matter what rules are actually in place. It is not equal when strafing now, due to the AI not knowing how to do it.
Title: Re: AI Aggression and Intelligence ranges?
Post by: Solarius Scorch on February 09, 2017, 07:41:46 pm
So the point is (if I understand you correctly) that it is the Mutual Surprise rule that is the problem. Even if you and the alien see each other at the same time, the alien should be able to reaction-fire IF it has the initiative (more TUs remaining x Reaction stats than the player.) And if the player has the initiative, he should be able to turn 90 degrees and fire at the alien after rounding a corner, before getting hit with reaction-fire.

Well, but if you don't see the alien before turning, it'll shoot you, since you have a huge penalty to your initiative check.

In my head, it should work the same way for both sides no matter what rules are actually in place. It is not equal when strafing now, due to the AI not knowing how to do it.

And I perfectly agree... But I don't have a solution other that "make AI smarter". :P
Title: Re: AI Aggression and Intelligence ranges?
Post by: Kjotleik on February 09, 2017, 07:54:58 pm
Well, but if you don't see the alien before turning, it'll shoot you, since you have a huge penalty to your initiative check.

Yes, I've experienced getting shot rounding corners many times in the past. But at least that is equal for both sides.
I don't really know how much of a penalty it is on player/alien rounding the corner, though. You probably know that better than me.

Somebody, please teach the AI how to round corners! No?

I'll say goodbye for today now. I'll have to take a look at FMP 1.9.6c files. You gave me a little bit more work with my "Soldier Specialists" mod by introducing more name-files, you know.   ;D

But that's OK. I'm happy for more nations among my soldiers. I just hope I can get it done this week, or next, so that I can start playing again...   :)
Title: Re: AI Aggression and Intelligence ranges?
Post by: Solarius Scorch on February 09, 2017, 08:29:19 pm
Yes, I've experienced getting shot rounding corners many times in the past. But at least that is equal for both sides.

Yes, but I would still be (kind of) forced to do the diagonal move samba, which the AI can't do... And no, I'm not saying it should. ;)

I don't really know how much of a penalty it is on player/alien rounding the corner, though. You probably know that better than me.

I can't remember, but it should be available on the Ufopedia.

Somebody, please teach the AI how to round corners! No?

You meant teach it to side-step? Tricky; we wouldn't want it to do so all the time... Only when it makes sense.

I'll say goodbye for today now. I'll have to take a look at FMP 1.9.6c files. You gave me a little bit more work with my "Soldier Specialists" mod by introducing more name-files, you know.   ;D

But that's OK. I'm happy for more nations among my soldiers. I just hope I can get it done this week, or next, so that I can start playing again...   :)

What kind of work? It's just a few extra files... Does it cause any problems other than adding a few lines to each type?
Title: Re: AI Aggression and Intelligence ranges?
Post by: ohartenstein23 on February 09, 2017, 08:33:21 pm
There's a penalty for rounding a corner?  I thought it was only a normal reactions check because your soldier suddenly became visible without triggering mutual surprise.
Title: Re: AI Aggression and Intelligence ranges?
Post by: Solarius Scorch on February 09, 2017, 08:36:03 pm
There's a penalty for rounding a corner?  I thought it was only a normal reactions check because your soldier suddenly became visible without triggering mutual surprise.

No no, there's nothing special like that. Only that if you walk straight on, and the alien is to the side, it will see you and you won't. So it is often better to go through a door sideways.

But if you can't go sideways, you can often move diagonally, except through a 1 tile door. Which is the next best thing to do, but it looks silly.
Title: Re: AI Aggression and Intelligence ranges?
Post by: Thirsk on February 09, 2017, 11:43:35 pm
Uh hold on a minute guys..did someone say there was a run option? How does one do that? Or do you just mean long movement on its own is considered running?
Title: Re: AI Aggression and Intelligence ranges?
Post by: Meridian on February 09, 2017, 11:50:59 pm
Uh hold on a minute guys..did someone say there was a run option? How does one do that? Or do you just mean long movement on its own is considered running?

Turn on "Alternate movement methods" in options.

Ctrl+click to run (or strafe when only 1 tile; or move turret when HWP).
Title: Re: AI Aggression and Intelligence ranges?
Post by: Thirsk on February 09, 2017, 11:59:11 pm
Turn on "Alternate movement methods" in options.

Ctrl+click to run (or strafe when only 1 tile; or move turret when HWP).

What the.. I didn't know that! I figured you could strafe but didn't know you could Ctrl+click more than one tile. This game...what have you guys done...not that I'm complaining or anything lol.

So running I guess would use more energy but not trigger reaction fire? Is vision impaired whilst running?
Title: Re: AI Aggression and Intelligence ranges?
Post by: Meridian on February 10, 2017, 12:03:09 am
So running I guess would use more energy but not trigger reaction fire? Is vision impaired whilst running?

Takes one less TU, but one more energy per tile... no other changes in vanilla.

In OXCE+ it also doesn't stop when spotting an enemy.
Title: Re: AI Aggression and Intelligence ranges?
Post by: Thirsk on February 10, 2017, 12:10:04 am
Takes one less TU, but one more energy per tile... no other changes in vanilla.

In OXCE+ it also doesn't stop when spotting an enemy.

That's brilliant! I'm going to try abusing..i mean using this whenever I can haha.

EDIT: So aggression can go up to 9 now?
Title: Re: AI Aggression and Intelligence ranges?
Post by: Kjotleik on February 11, 2017, 03:36:09 am
What kind of work? It's just a few extra files... Does it cause any problems other than adding a few lines to each type?

Yes. But I go through them and make some changes:
Code: [Select]
Random Name
becomes
Random Name (H)
for Heavies
Random Name (A)
for Assaults
etc.

So I duplicate each name-file as many times as I have classes. And go through them manually. Since I cannot code, it would take me longer to learn how to make a script than to just [CTRL]+[V] the " (H)" parts at the end of names...

I don't know about you, but I would never remember the classes if I didn't have those visible in the names.
And now I've decided to add two more as well. Grenadiers and Ninjas (melee). I'm just looking for an experimental game where I can have some fun, you know. Roleplaying a bit, bragging about the lucky-shot sniper, crying for the did-reaction-fire-but-missed-causing-death-to-self Assault, etc.   ;D


PS!
It is not something I would ever consider "problems."   ;D
I like doing stuff like this, since it is so easy. Just ruleset-files with easily understandable syntaxes. No coding-knowledge necessary, really.
But, alas, it does take some time. Time that I enjoy, by the way. But time nonetheless.
Title: Re: AI Aggression and Intelligence ranges?
Post by: Solarius Scorch on February 11, 2017, 04:00:08 pm
Yes, I understand now... I didn't know about the name modifications and I was worried I am missing something. :) Well, good luck with your work!