aliens

Author Topic: Should the AI consider enemy range and partial cover?  (Read 10778 times)

Offline Bobit

  • Colonel
  • ****
  • Posts: 186
    • View Profile
Should the AI consider enemy range and partial cover?
« 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

  • 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.

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 enemy will need to spend TUs to get within maximum attack range or pull out a weapon. It should count as (max((dist+enemyTU)/enemyMaxRange, enemyQuickdrawTUs/enemyTUs, 0.25)) spotters.
  • The AI unit's body is partially obscured ("hulldown" "light cover")from the enemy. Trace rays from the enemy to a random part of the AI, if some of these rays hit a wall, it's partially obscured and so should count as maybe 0.6 spotters, or spotters proportionate to how many rays didn't hit a wall but that's higher performance costs.
  • The enemy is panicked. It should count as 0 spotters.

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.

Offline memmaker

  • Captain
  • ***
  • Posts: 95
    • View Profile
Re: Should the AI consider enemy range and partial cover?
« Reply #1 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


Offline Bobit

  • Colonel
  • ****
  • Posts: 186
    • View Profile
Re: Should the AI consider enemy range and partial cover?
« Reply #2 on: January 31, 2020, 02:28:16 am »
It does need an engine modification to work though.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8709
    • View Profile
Re: Should the AI consider enemy range and partial cover?
« Reply #3 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)

Offline memmaker

  • Captain
  • ***
  • Posts: 95
    • View Profile
Re: Should the AI consider enemy range and partial cover?
« Reply #4 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?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8709
    • View Profile
Re: Should the AI consider enemy range and partial cover?
« Reply #5 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.
« Last Edit: January 31, 2020, 05:19:03 pm by Meridian »

Offline memmaker

  • Captain
  • ***
  • Posts: 95
    • View Profile
Re: Should the AI consider enemy range and partial cover?
« Reply #6 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.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8709
    • View Profile
Re: Should the AI consider enemy range and partial cover?
« Reply #7 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.
« Last Edit: January 31, 2020, 05:47:32 pm by Meridian »

Offline memmaker

  • Captain
  • ***
  • Posts: 95
    • View Profile
Re: Should the AI consider enemy range and partial cover?
« Reply #8 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?


Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8709
    • View Profile
Re: Should the AI consider enemy range and partial cover?
« Reply #9 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.

Offline memmaker

  • Captain
  • ***
  • Posts: 95
    • View Profile
Re: Should the AI consider enemy range and partial cover?
« Reply #10 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?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8709
    • View Profile
Re: Should the AI consider enemy range and partial cover?
« Reply #11 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.

Offline memmaker

  • Captain
  • ***
  • Posts: 95
    • View Profile
Re: Should the AI consider enemy range and partial cover?
« Reply #12 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?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8709
    • View Profile
Re: Should the AI consider enemy range and partial cover?
« Reply #13 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.
« Last Edit: January 31, 2020, 06:14:51 pm by Meridian »

Offline memmaker

  • Captain
  • ***
  • Posts: 95
    • View Profile
Re: Should the AI consider enemy range and partial cover?
« Reply #14 on: January 31, 2020, 06:22:08 pm »
Alright, thanks again for your patience, Meridian ;D