OpenXcom Forum

OpenXcom => Suggestions => Topic started by: Bobit on January 31, 2020, 12:54:25 am

Title: Should the AI consider enemy range and partial cover?
Post by: Bobit on January 31, 2020, 12:54:25 am
There are some very smart things about the AI like not giving away ally positions. But after digging through AIModule.cpp I can safely conclude that the AI only looks at whether it can spot enemies/allies. It doesn't consider


I propose that when an AI unit tries to take cover, instead of an enemy counting as 0 or 1 spotters, it should be able to count as a fraction of a spotter if one of the following is true:



The AI also might want to consider prioritizing shots on targets that are not partially obscured. This will be especially important if cover is buffed by giving it an accuracy reduction even if its model is not physically touched, which is what I've been trying to do today. Adding light cover is pretty pointless if the AI doesn't use it. This could be a fun addition to the game which makes the AI not just stand there and get slaughtered by shotgunners. Or it could simply be too much work or too non-vanilla, let me know.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: memmaker on January 31, 2020, 01:51:49 am
I believe some more variety in AI behaviour would be great. One could add them as additional options activated by mods.

Gesendet von meinem Pixel 3 mit Tapatalk

Title: Re: Should the AI consider enemy range and partial cover?
Post by: Bobit on January 31, 2020, 02:28:16 am
It does need an engine modification to work though.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Meridian on January 31, 2020, 03:27:50 pm
It doesn't consider

  • That a melee enemy can't even reach it this turn
  • That it could enter a "hulldown" or "light cover" position.
  • That a panicked enemy isn't a threat.

1/ AI doesn't know how much TUs your units have and how far can they go... knowing it (without mind probe) would be cheating

2/ there is a "Sneaky AI" user option for full cover/LOS break... "light cover" is (for practical purposes) no cover in xcom, and aliens can't kneel or "hulldown", there's no sprites for that

3/ AI doesn't know which enemy units are panicked... how are they supposed to know? the player could have dropped a weapon or shoot around aimlessly also with non-panicked units for example.
(the player is visually informed when an enemy unit is panicking... which is a cheat btw., that's why an option exists to turn it off ... but AI units don't get such info)
Title: Re: Should the AI consider enemy range and partial cover?
Post by: memmaker on January 31, 2020, 04:57:25 pm
1/ AI doesn't know how much TUs your units have and how far can they go... knowing it (without mind probe) would be cheating

3/ AI doesn't know which enemy units are panicked... how are they supposed to know? the player could have dropped a weapon or shoot around aimlessly also with non-panicked units for example.
(the player is visually informed when an enemy unit is panicking... which is a cheat btw., that's why an option exists to turn it off ... but AI units don't get such info)

1) That's a strange argument to make. The AI already cheats in order to be able to make interesting decisions. For example:

How does an alien know how good a soldier is at dodging?

Code: [Select]
float dodgeChanceDiff = target->getArmor()->getMeleeDodge(target) * target->getArmor()->getMeleeDodgeBackPenalty() * _attackAction->diff / 160.0f;

And the AI isn't able to use a mind probe, or am I missing something?

3) Hmm, I would have thought this allows for checking the status of a unit:

Code: [Select]
UnitStatus status = unit->getStatus();
if (status == STATUS_PANICKING)...

What does this check do then?
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Meridian on January 31, 2020, 05:16:52 pm
1) That's a strange argument to make. The AI already cheats in order to be able to make interesting decisions. For example:

How does an alien know how good a soldier is at dodging?

Code: [Select]
float dodgeChanceDiff = target->getArmor()->getMeleeDodge(target) * target->getArmor()->getMeleeDodgeBackPenalty() * _attackAction->diff / 160.0f;

That's not vanilla AI.
I have made the same argument for melee dodge (oxce-only feature)... the AI should not know how good a soldier is at dodging, it's cheating.

3) Hmm, I would have thought this allows for checking the status of a unit:

Code: [Select]
UnitStatus status = unit->getStatus();
if (status == STATUS_PANICKING)...

What does this check do then?

Where do you see this check? I can't find anything like that in the AI.

And the AI isn't able to use a mind probe, or am I missing something?

I didn't say AI can use the mind probe.
I only said that this would be the only non-cheating way of determining enemy TUs.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: memmaker on January 31, 2020, 05:22:49 pm
1) Since we are already dealing with non-vanilla AI, I do not understand why it can't be changed further? Albeit completely optional, of course.

I am not sure what you are saying here. Is it: "We did that once and won't do it again?"

And what about the mind probe? You explicitly mention it. I believe it would be a neat option to have aliens use them and implement advanced tactics based on the knowledge gained. Would level the playing field, since X-COM can already use the mind probe.

3) That last one is not used in the AI but elsewhere.

I was just wondering why that couldn't be used to check for panic.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Meridian on January 31, 2020, 05:41:17 pm
1) Since we are already dealing with non-vanilla AI, I do not understand why it can't be changed further? Albeit completely optional, of course.

I am not sure what you are saying here. Is it: "We did that once and won't do it again?"

"We" didn't do it... I would definitely not add such a feature, it was added (probably) by Yankes when OXCE and OXCE+ were still separate forks (or maybe even before OXCE+ even existed).

I'm saying that I am against AI cheating, and will not allow adding any new AI cheating features.

And what about the mind probe? You explicitly mention it. I believe it would be a neat option to have aliens use them and implement advanced tactics based on the knowledge gained. Would level the playing field, since X-COM can already use the mind probe.

It would be a "nice to have", I don't have anything against it, it's not cheating.

But saying that AI being able to use a mind probe would "level the playing field" is... a gigantic overstatement at least.

3) That last one is not used in the AI but elsewhere.

I was just wondering why that couldn't be used to check for panic.

Because that would be cheating.
Just because it is possible implementing a cheating AI, doesn't mean we have to do it... I prefer a non-cheating AI.

I don't get the argument here at all to be honest... it's possible to implement a never missing AI, an all knowing AI, never dying aliens... whatever you want... as a developer you have access to 100% of the game state... but the AI should NOT have access to 100% of the game state.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: memmaker on January 31, 2020, 05:46:30 pm
but the AI should NOT have access to 100% of the game state.

That completely depends on the design and I was just not aware of this design choice until now.
But you made yourself clear now.

So, one could implement the ability for aliens to use a mind probe and check the stats of X-COM soldiers?

And what about checking the weapons of soldiers? Is that considered cheating? And checking the Soldier Type? And Armor Type?

Title: Re: Should the AI consider enemy range and partial cover?
Post by: Meridian on January 31, 2020, 05:54:40 pm
Do you really expect an answer for that?
I don't think there is one.
But I'll try... please note that the following statement isn't and cannot be 100% correct, there are always exceptions:

The AI should have, at maximum, the same abilities and access to the same information as a player controlling the aliens would have, if openxcom supported multi-player mode.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: memmaker on January 31, 2020, 05:57:27 pm
The AI should have, at maximum, the same abilities and access to the same information as a player controlling the aliens would have, if openxcom supported multi-player mode.

I figured as much, so weapons and armor would be fine then.

But soldier type is questionable?
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Meridian on January 31, 2020, 06:05:21 pm
I figured as much, so weapons and armor would be fine then.

Not necessarily.

Since openxcom is not a multiplayer game, it's purely theoretical... but if it was, I don't think the player controlling the aliens would have access to the exact information about xcom armor values or xcom weapon stats.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: memmaker on January 31, 2020, 06:08:43 pm
Ok, we can agree on that.

But the alien should at least be able to distinguish which type of armor is being worn (would be visually different to a human) and which weapon type the enemy has (same argument), right?
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Meridian on January 31, 2020, 06:12:06 pm
Ok, we can agree on that.

But the alien should at least be able to distinguish which type of armor is being worn (would be visually different to a human) and which weapon type the enemy has (same argument), right?

Yes, all such visual information would be available to both players.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: memmaker on January 31, 2020, 06:22:08 pm
Alright, thanks again for your patience, Meridian ;D
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Countdown on January 31, 2020, 09:57:05 pm
That's not vanilla AI.
I have made the same argument for melee dodge (oxce-only feature)... the AI should not know how good a soldier is at dodging, it's cheating.
Just asking out of curiosity, then why not remove it? Is this a difference of opinion with Yankes or too difficult for another reason?
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Yankes on January 31, 2020, 10:14:46 pm
"We" didn't do it... I would definitely not add such a feature, it was added (probably) by Yankes when OXCE and OXCE+ were still separate forks (or maybe even before OXCE+ even existed).
This my code, this was added prevent alines from doing stupid things. Player can know after couple of tries that attacking some unit from front is not effective, but aliens do not remember this (and even if remember they can't carry this knowledge between missions).
I agree we should keep behaviors like this to minimum, but in some corner cases we could help a bit AI do not have big disadvantage.
Another place where AI use behavior like this is psi attacks.

As always, question is how much "a bit" is.
One way this both cases could be fixed is count numbers of attack on unit, each time AI have better "knowledge" and can use more units stats to plan next move.
But current TU would not be accessible because you can't determine it without seeing unit movements on previous turn (and this could be only way to know it).
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Bobit on January 31, 2020, 10:36:13 pm
1/ AI doesn't know how much TUs your units have and how far can they go... knowing it (without mind probe) would be cheating

Fair enough, they could make a reasonable assumption by taking (minTU+maxTU)/2 using the stats for the class. But overall I don't think it would be a huge impact.

2a/ aliens can't "hulldown"

Everyone can hulldown on hills by walking to the spot where they can just barely peek over the hill to shoot at an enemy. Even tanks, which cannot crouch. That is why it is called hulldown. This is VERY effective cover, in a good position maybe 40% of shots hit the hill. I would like to be able to teleport enemies in debug mode to test exactly how effective this is though, any way to do that?

Probably the most reasonable counterargument to adding this is that even with the current code the AI is still more likely to enter a "hulldown" position with the rational that some of the enemies are totally obstructed, which is better than no enemies being obstructed.

2b/ "light cover" is (for practical purposes) no cover in xcom

Correct, except as outlined by 2a above. But I could implement it by making spread non-binary. Doing that would be an easy way to allow modders to add balance light cover, which I see as a huge improvement. However it's pointless if the AI doesn't understand it, hence one of the motivations for this thread.

Instead of adding spread, it could also take a less "realistic" approach like XCOM2 where shooting through a space with cover (even if not hitting the cover) gives a flat accuracy reduction. But that's somewhat besides the point.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Rubber Cannonball on January 31, 2020, 10:46:31 pm
I would like to be able to teleport enemies in debug mode to test exactly how effective this is though, any way to do that?

try ctrl w to "warp" the selected unit to the cursor position in debug mode.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Bobit on January 31, 2020, 10:52:39 pm
try ctrl w to "warp" the selected unit to the cursor position in debug mode.

How do I select an enemy?
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Rubber Cannonball on January 31, 2020, 10:58:52 pm
You should be able to do it after the enemy moves on the enemy turn while debug mode is active (ctrl -d to activate) and before pressing the end turn button.  Going into the units inventory will also refill its TUs so you should also be able to move and position it how you want.

Edit:
Actually going into one enemy units inventory will refill all the enemy units' TUs.  And to clarify, just wait until the enemy units stop moving before trying to move one.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Bobit on January 31, 2020, 11:10:44 pm
That's very difficult with the constantly recentering camera. Still I'll keep trying and let you know if I succeed.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Bobit on January 31, 2020, 11:25:50 pm
Alright alright, I've done more testing and it's pretty darn negligible  ::)

I'm will try to fork and add modding capabilities for:


Is forking OXCE to add modding capabilities common practice? People do it for event hooks.

I do think it's reasonable that the AI should know the player panicked, because it's pretty easy to tell even without the screen. But sure it should be a mod feature.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Meridian on January 31, 2020, 11:37:52 pm
Just asking out of curiosity, then why not remove it? Is this a difference of opinion with Yankes or too difficult for another reason?

Because:
1/ one oxce dev reverting the work of another oxce dev would just be childish and stupid
2/ Yankes has given convincing arguments to justify it
3/ unless you read the code, you'll never be able to find out that it even exists
4/ my playtests didn't show any increase in AI ability to kill me, so I consider it a "harmless cheat"

Besides, if I removed all features I don't like, I would remove 30% of oxc code, 30% of oxce code not made by me and probably even 30% of oxce code made by me... but I do respect other people's work, opinions and tastes... and life is full of compromises (alternative is a pretty miserable life).
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Rubber Cannonball on February 01, 2020, 12:28:34 am
As for cheating AI,  I find the whole spotter sniper mechanic in OXCE more "cheaty" than the ai knowing xcom units' stats or their equipment stats.  For instance, even one shot killing a spotter from behind will make the shooting unit visible to at least the AI sniper units for several turns (depends on ruleset)  It doesn't matter if the shooter hides in a cave under a hill for a turn or two.  Even if he pops out the other side of the hill, the ai snipers can still target him if line of fire available or if they can throw a grenade at his tile.  Camo armor or even invis armor doesn't help.  Worse, he can be targeted even behind a thin wall so long as the wall is in the same tile as he is.

If the alien squad carries a mind probe,  I think it would be ok for ai to know the xcom stats without having the complication of coding in explicit mind probe usage.  This simplification is a bit cheaty, but most of the time the ai won't benefit much from this information anyways.  Alien intelligence should be a factor here.

My understanding of TU is that is a game abstraction of speed or quickness and to a lesser extent efficiency or even proficiency.  Just seeing an xcom unit run a few squares should be enough for an intelligent alien to be able to guesstimate how quick that unit is and how much distance that unit can cover in a turn.  A turn is another game abstraction of a time interval.  The aliens may know quite a bit of information about human capabilities from all those abduction missions they run anyways.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Bobit on February 01, 2020, 12:55:08 am
100% sniper-spotter AI is exactly what the player gets. Yes it's absurd, and that's why megamods heavily nerf firing on enemies you can't see, which allows sniper AIs to actually help their ally without being OP. The most cheaty thing the AI does is "intelligence" where it automatically knows where you are a few turns after spotting you.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: ohartenstein23 on February 01, 2020, 01:16:09 am
As for cheating AI,  I find the whole spotter sniper mechanic in OXCE more "cheaty" than the ai knowing xcom units' stats or their equipment stats.  For instance, even one shot killing a spotter from behind will make the shooting unit visible to at least the AI sniper units for several turns (depends on ruleset)  It doesn't matter if the shooter hides in a cave under a hill for a turn or two.

This is a "vanilla" AI cheat that is exacerbated by he sniper code when it's overtuned in a mod. If you shoot an alien in the original game the soldier that did the shooting is now "known" to the AI, and any aliens are free to psi spam and blaster bomb them until more turns than the aliens' intelligence have passed without re-spotting.

The intended use is that it's supposed to emulate the same kind of smoke- and squadsight-sniping the player does. I'd argue the only "correct" value the spotter parameter is 1, and the mod should have some penalty to shooting with no LoS. This means the AI will try to snipe at units that they scout during their turn and may try to guess/take out the cover of units they spotted during your turn right before theirs. A more complicated system could be developed for what counts as spotted, but I don't think it will make much of a difference when using a spotter value of 1. I left the option to define other values for spotter in case there are modders who particularly hate their players.

Personally I think a non-cheating AI is harder to make good than giving a few choice smaller cheats that approximate tactics a human player can employ. In order to have a challenging AI that has perfectly symmetrical information to the player, you're going to have to model human decision-making at a level that would take a very long time to code that wouldn't be worth the little extra benefit you get from knowing the AI "isn't cheating".
Title: Re: Should the AI consider enemy range and partial cover?
Post by: kevL on February 01, 2020, 02:03:21 am
Personally I think a non-cheating AI is harder to make good than giving a few choice smaller cheats that approximate tactics a human player can employ. In order to have a challenging AI that has perfectly symmetrical information to the player, you're going to have to model human decision-making at a level that would take a very long time to code that wouldn't be worth the little extra benefit you get from knowing the AI "isn't cheating".

having done (unpaid) game development, including AI, for the last 10 yrs. I agree 110%

else hand over $100,000 ... for a non-cheating AI worth any salt.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Rubber Cannonball on February 01, 2020, 03:00:56 am
100% sniper-spotter AI is exactly what the player gets.

I'm pretty sure this is not what the player gets.  If an alien moves out of visual range on the alien turn, the player doesn't automatically see him on the players turn.  Squad sight is what the player gets.  I don't think squad sight is implemented for the alien ai.  I think it wouldn't be cheaty at all if the aliens had access to squad sight limited to their current turn.  It should be selectable in the ruleset by mission type, faction type and/or other suitable means to give modders flexibility.

Edit:  In fact the player doesn't even get to spot the alien that shot him if it isn't in any of his units' line of sight (LoS).
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Bobit on February 01, 2020, 06:21:59 am
Hm, I forgot that high spotter has an effect similar to intelligence. I would still hold that spotter = 1 is what the player gets though.

Letting AI shoot the enemy who shot them is bad, but because spotting is binary, the only alternative is to not let the AI know they were hit at all.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Rubber Cannonball on February 01, 2020, 06:38:50 am
..., the only alternative is to not let the AI know they were hit at all.

Interestingly enough that seems to be the effect if the enemy spotter unit is hit from outside its vision cone with a melee weapon.  So long as the melee xcom unit isn't seen by any alien, its position remains unknown to the ai regardless of how many blows it lands.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Bobit on February 01, 2020, 07:29:25 am
Really? That is interesting. Of course if the melee attacker doesn't flee, the spotter will likely turn around and see him anyways. But repeatedly backstabbing an enemy then fleeing seems, in a very rare situation, completely broken.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Rubber Cannonball on February 01, 2020, 11:46:09 pm
This is a "vanilla" AI cheat that is exacerbated by he sniper code when it's overtuned in a mod. If you shoot an alien in the original game the soldier that did the shooting is now "known" to the AI, and any aliens are free to psi spam and blaster bomb them until more turns than the aliens' intelligence have passed without re-spotting.

I think the vanilla spotter for psi was fine since psi wasn't a line of sight attack anyways and was mitigated by distance and psi defense.  In fact, I'm not sure it would be too bad if the aliens didn't even need to spot an xcom unit before being able to psi attack it.

Was the blaster launcher the only weapon that used the spotter mechanic in the original game?  I don't think the blaster launcher carrying aliens ever had any other weapons like grenades or plasma pistols.  At any rate between the bugs and alien accuracy, it seemed like the aliens did as much damage to themselves with the blaster bombs as they did to xcom.

But yeah in some mods ones' troops can't go outside if they can't tank whatever the enemy is packing.  Unless they always whack 'em from behind of course.   ::)
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Countdown on February 03, 2020, 02:00:28 pm
This my code, this was added prevent alines from doing stupid things. Player can know after couple of tries that attacking some unit from front is not effective, but aliens do not remember this (and even if remember they can't carry this knowledge between missions).
I agree we should keep behaviors like this to minimum, but in some corner cases we could help a bit AI do not have big disadvantage.
Another place where AI use behavior like this is psi attacks.

As always, question is how much "a bit" is.
One way this both cases could be fixed is count numbers of attack on unit, each time AI have better "knowledge" and can use more units stats to plan next move.
But current TU would not be accessible because you can't determine it without seeing unit movements on previous turn (and this could be only way to know it).

This makes a lot of sense and sounds reasonable. I hadn't even thought of how aliens already do this with psi attacks since they target the mentally weakest soldiers. Good point.


Because:
1/ one oxce dev reverting the work of another oxce dev would just be childish and stupid
2/ Yankes has given convincing arguments to justify it
3/ unless you read the code, you'll never be able to find out that it even exists
4/ my playtests didn't show any increase in AI ability to kill me, so I consider it a "harmless cheat"

Besides, if I removed all features I don't like, I would remove 30% of oxc code, 30% of oxce code not made by me and probably even 30% of oxce code made by me... but I do respect other people's work, opinions and tastes... and life is full of compromises (alternative is a pretty miserable life).

Fair enough, I was just curious. I agree that Yankes' points were a good justification. He convinced me.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: Rubber Cannonball on February 03, 2020, 11:01:54 pm
Really? That is interesting. Of course if the melee attacker doesn't flee, the spotter will likely turn around and see him anyways. But repeatedly backstabbing an enemy then fleeing seems, in a very rare situation, completely broken.

Yeah I agree.  I did some savescum testing in x-piratez with a ghost armor gal against a merc commando.  If she one shot killed the merc in the back with the ranged attack ghost beam, she was spotted by the ai and thus fired at and grenaded on the enemy turn.  If she killed the merc from the front with the melee ghost dagger, she was again spotted by the ai, but when she killed the merc from behind with the dagger she was't spotted.  If she crossed into the merc's vision cone before killing from behind with the dagger she was again spotted. No other merc unit was ever in range to spot the gal.

I suppose this means that in vanilla if one goes against ethereals with stun rods only and manages to never be seen one could avoid psi attacks until down to only 2 ethereals left or turn 20.  I haven't tried this.
Title: Re: Should the AI consider enemy range and partial cover?
Post by: pvalleyth on March 24, 2020, 10:40:49 am
thank information :)
Title: Re: Should the AI consider enemy range and partial cover?
Post by: pmotosporth on March 31, 2020, 07:40:41 pm
I believe some more variety in AI behaviour would be great. One could add them as additional options activated by mods.

Gesendet von meinem Pixel 3 mit Tapatalk