OpenXcom Forum

Modding => Released Mods => Brutal AI => Topic started by: Xilmi on November 09, 2022, 02:17:48 pm

Title: Looking for some advanced strategies and their counters
Post by: Xilmi on November 09, 2022, 02:17:48 pm
As you may or may not have heard, I'm trying myself on creating a more hard-core-experience by adapting the AI in a way that is meant to cause as much resistance to the player as it can.

And while I think that progress is coming along nicely, my judgement is limited by my own limited experience.

That's why I'd like to hear more about tricks and/or advanced strategies employed by players that I then could both take into consideration for the AI to employ and for the AI to counter.

Getting myself better as a player will help my understanding of what's a good idea and what isn't. I'd like for some good players to explain their moves and their thought-process behind them.

I guess that many of them are based on exploiting current weaknesses of the AI, so I'm particularly interested on the ones that don't and are more general in nature. But also the ones that do exploit weaknesses can be mentioned so I can tell whether I've already taken it into account or not.

You can, of course, also describe how the AI would have to act in order to give you the most trouble.

My dream-scenario would be to find an expert-player, who's also a content-creator who'd be willing to test my AI while giving feedback and showing how the remaining weaknesses can best be exploited so I can try and find ways to deal with that.
Title: Re: Looking for some advanced strategies and their counters
Post by: psavola on November 09, 2022, 09:49:33 pm
Over the years there have been quite a few superhuman ironman playthroughs on YouTube or Twitch, which will give very good hints if one has the interest and/or patience to watch them (in full or in parts). I have certainly learned a lot from them. If I would have to pick recent one to recommend, I might suggest The Voice (Echo archives), one playlist is at https://www.youtube.com/playlist?list=PLVLZLHjZpBt-9_OCLY680alIEQncPnOK9 . The player is very knowledgeable about the inner workings of the game and also explains the actions better than most. It might also be interesting that the playlist also includes a recently started new SH/IM challenge without smoke grenades (which requires somewhat different tactics for survival).

Some of the biggest ways to exploit the weaknesses of AI or game design are as follows:
 - hang back in the craft and wait for the aliens to wander in to view before or after turn 20. Do not even exit the craft, especially without smoke, except for a look around (usually with a tank, which can take a few hits). This does not work with UFO Skyranger, but with many other craft it is very effective (called "cheesy strat" by some). Especially Terror for the Deep. Caveat: some aliens with very high TUs might come charging in your craft and cause havok, so you'll need to make sure you shoot out everyone coming closer from inside the craft.
 - do not enter the alien craft at all (especially if it includes deadly chokepoints where the aliens can ambush you), rather wait for the aliens to come out one by one (after turn 20) while you are positioned in a good place and possibly covered by smoke.
 - in certain base defense missions (especially UFO), wait for the aliens to come at you at a rampage and get killed by your well positioned troops or proxy grenades you throw on the corridors for them. However, there is are differences wrt. RNG and base nodes the aliens move between, and in some cases you'll need to go after the aliens and most of them might not come after you.
 - smoke is an extremely effective cover in almost any scenario (OXCE does include the option for the mod authors to make it less so, which calls for different tactics) - by default smoke protects in 2D, but you can enable it to work in 3D (e.g. shooting from above, e.g. UFO floaters or buildings)
 - mind controlled, paniced or berzerked soldiers don't pick up weapons and use them or take new weapons from their backpacks, belt, etc.
Title: Re: Looking for some advanced strategies and their counters
Post by: Juku121 on November 09, 2022, 10:38:33 pm
IMO, the two biggest omissions from the above list are:

There is also the time-honoured turn-based tactic of peek-and-shoot (move out of and into cover during your turn) which the enemies don't do half as well as the player. A lot of 'camping' tactics are based on some variation of this.

Finally, there are the grenade relay/conga line and 'drop smoke' (to save TU) tactics for grenades.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 10, 2022, 01:35:14 am
Over the years there have been quite a few superhuman ironman playthroughs on YouTube or Twitch, which will give very good hints if one has the interest and/or patience to watch them (in full or in parts). I have certainly learned a lot from them. If I would have to pick recent one to recommend, I might suggest The Voice (Echo archives), one playlist is at https://www.youtube.com/playlist?list=PLVLZLHjZpBt-9_OCLY680alIEQncPnOK9 . The player is very knowledgeable about the inner workings of the game and also explains the actions better than most. It might also be interesting that the playlist also includes a recently started new SH/IM challenge without smoke grenades (which requires somewhat different tactics for survival).
Thanks, I will watch that series to see how much of it is still applicable.

Some of the biggest ways to exploit the weaknesses of AI or game design are as follows:
 - hang back in the craft and wait for the aliens to wander in to view before or after turn 20. Do not even exit the craft, especially without smoke, except for a look around (usually with a tank, which can take a few hits). This does not work with UFO Avenger, but with many other craft it is very effective (called "cheesy strat" by some). Especially Terror for the Deep. Caveat: some aliens with very high TUs might come charging in your craft and cause havok, so you'll need to make sure you shoot out everyone coming closer from inside the craft.
I attached a screenshot of what my AI does in that scenario. They assume positions from where they have a good overview over the map while making sure to keep some distance from one another (in order to avoid AoE). Flying units like these floaters are particularly nasty in that case because they almost always go airborne for that. Turn 20 doesn't mean anything to them. They'd just wait like that forever.
And they "communicate" with one another. So basically when one of them gets a line of sight, the others will also move to a position where they have a line of sight too. And when one of them then actually sees a unit it means that everyone can open fire from whereever they are. Up until today I used a sight-check for that but that meant that after a unit died or hid after shooting it wouldn't work anymore. So now I replaced it with a check for target->getTurnsSinceSpotted() == 0. This added a significant bump in difficulty. Especially for the likes of floaters, who have such an easy time getting a line of fire towards everyone walking out in the open and smoke-grenades don't help because they only protect in 2D, as you say.
I also have added an anti-smoke-grenade behavior for the aliens. Basically when it thinks it should see someone but doesn't it will move closer until it does. And once one of them actually sees you, it allows all the others who just have a line of fire to shoot too. And you don't even see it coming because the smoke also prevents your own vision.

- do not enter the alien craft at all (especially if it includes deadly chokepoints where the aliens can ambush you), rather wait for the aliens to come out one by one (after turn 20) while you are positioned in a good place and possibly covered by smoke.
Due to the getting a good overview-algorithm, it's mostly unnecessary to enter the UFOs against my AI. That is because for the most part they will try to get out rather quickly anyways. One of the few times it went reaonably well for me was when I started right next to the doors of their ship. I've done a few things to make chokepoints harder to camp though. Firstly they don't usually try to get out one by one. Since they all want to leave the UFO, they are lining up and when one poor alien sould opens the door to be greated by your soldiers, then there's others behind him who will shoot out too. Something especially nasty was that when there's few friends around but a lot of X-Com outside was that if it has a grenade, it'll pre-prime it before stepping out. So he basically becomes a suicide-bomber. At first I let them always preprime, if they have nothing better to do. But that was very bad for them, so I had to figure out a better solution to only do it situationally.

- in certain base defense missions (especially UFO), wait for the aliens to come at you at a rampage and get killed by your well positioned troops or proxy grenades you throw on the corridors for them. However, there is are differences wrt. RNG and base nodes the aliens move between, and in some cases you'll need to go after the aliens and most of them might not come after you.
Oh right, proximity-grenades. I have never used them so far. I should definitely try them out. I need to know what proximity will trigger them and then add code for the aliens to avoid them. So currently that would probably be one of my best bets for things that still work against the AI as there is no code to deal with it.

- smoke is an extremely effective cover in almost any scenario (OXCE does include the option for the mod authors to make it less so, which calls for different tactics) - by default smoke protects in 2D, but you can enable it to work in 3D (e.g. shooting from above, e.g. UFO floaters or buildings)
Yeah, I found it still helpful to get into nearby buildings with real cover. But as I mentioned earlier. I have already taken measures against it in my AI. So the protection is temporary and might backfire.

- mind controlled, paniced or berzerked soldiers don't pick up weapons and use them or take new weapons from their backpacks, belt, etc.
You mean AI-alien-soldiers? There already was code to use weapon-pickup. With my AI that also will be enabled or it at least should be enabled in tandem with it. But when you get into a position to Psi them, you have a lot of great opportunities besides of that.

So far I've usually done AI for 4x-games where you and your opponents start at an even footing and that are about at least somewhat fair competition. In these scenarios having an AI that plays as good as possible was kinda desiarable.
But for X-Com I'm already questioning the sensibleness of what I've done in the past two weeks. So far my own progress as a player couldn't keep pace with my progress on the AI. I think I'll have to step up my game quite a bit in order to get a little further into the game.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 10, 2022, 01:54:13 am
Scout-sniper tactics (or squadsight in modern parlance), the practice of shooting from beyond LoS to avoid reaction fire. The number one advantage for either side, IMO. I do hope you plan to make the sniper-spotter feature a part of your AI and not just make everyone a sniper all day, every day.
What I did with that was that everyone will be a sniper if there is something to snipe. If there's nothing to snipe they'll advance until someone eventually becomes a spotter coincidentally. Unless when there's no line of fire for any of them. In that case they either become a seeker or a camper depending on the situation. It's a bit difficult to even put it into words. If there is a line of sight to the line of sight, they will camp it. If there isn't, which means the unit is in a room with locked doors, which happens in base-defense, they will basically go there and open the door. (I had to make it possible for the AI to open doors with "rightclick" when the other side is blocked.)

Melee 'milling', the tendency of melee-only enemies to run around like headless chickens and be easy prey. One half of all the reasons OG Reapers were considered a joke. Fortunately, leeroying fixes most of it, and units with high TU are less suspectible (a part of why Chryssalids were still terrifying).
I spent at least two days on melee-code. I couldn't get the reapers walk into the skyranger and also bite. It's still a problem when the first two slots near the door are left free but the 2nd row on the grid isn't. Because the main tile of the unit is the uppermost corner. And it doesn't work if it is on a tile that is on another layer of the level than other parts of the creature.
Crysalids work extremely well though.

There is also the time-honoured turn-based tactic of peek-and-shoot (move out of and into cover during your turn) which the enemies don't do half as well as the player. A lot of 'camping' tactics are based on some variation of this.
That is probably what has quite a bit of potential. Currently my AI only ever hides when it doesn't have enough TU for another shot. It's helpful to vacate a spot at a chokepoint to not block vision for their friends.

Finally, there are the grenade relay/conga line and 'drop smoke' (to save TU) tactics for grenades.
I think that could be elaborated a bit more in detail. Drop smoke refers to not throwing but letting it fall down, I suppose. But what is grenade relay/conga-line supposed to mean? I assume some sort of chain-reaction maybe. But I can't really imagine how that can be used. So could you please elaborate on that?
Title: Re: Looking for some advanced strategies and their counters
Post by: psavola on November 10, 2022, 06:48:20 am
(grenade relaying)
I think that could be elaborated a bit more in detail. Drop smoke refers to not throwing but letting it fall down, I suppose. But what is grenade relay/conga-line supposed to mean? I assume some sort of chain-reaction maybe. But I can't really imagine how that can be used. So could you please elaborate on that?

By default, primed grenades do not explode immediately if dropped or thrown, rather at the end of the turn. This allows person 1 to prime a grenade, drop it, person 2 pick it up and throw it to person 3, person 3 to throw it to person 4 who is sufficiently near the aliens to have the strength to throw the grenade at them. Obviously this chain can be shorter as well (usually this depends on the weight of the explosive and the strength, i.e. how far you can throw the explosive). If your soldiers have good strength, you usually don't need to do long relays. There is also an option "instant grenades", where grenades (including smoke) explode immediately when thrown. This prevents relaying (but still allows priming, dropping and another person picking it up and throwing it). Instant grenades makes the game more realistic (no relay) but easier. Especially if you play with instant grenades, you might at least in the early game use grenades a lot. Even more realistic "instant grenades" would be that you cannot drop a primed grenade without it exploding.

These are game mechanic issues and I don't see how it could be addressed in AI code.

Wrt. sniper/spotter tactics I think you should be aware that there is an option Extended accuracy, where the accuracy decreases the longer you go from the target (especially snap and auto shot). There are also options which limit the range of weapons. OXCE also includes an option that most mods use, with which you get a penalty (usually 50% loss) in accuracy unless you have personally line of sight. However, this does not apply to certain (sniper) weapons and grenades. So in those options and mods the spottr/sniper tactics can still be employed with sniper weapons and grenades. While none of this affects the original vanilla game, it is worth noting because the AI code would eventually need to also take these variations into account.

I'd guess that some active SH/IM streamer might be interested in testing and eventually streaming a "brutal AI" challenge when the code gets to a point where it is mature enough.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 10, 2022, 11:37:38 am
Interesting. I didn't consider that possibility at all. So I guess I can definitely add this to tricks I've learned. Also interesting that using instant-grenades isn't a good solution because it makes it easier due to not allowing for reaction-fire of the naded alien.

Yes, I have seen that option and have a vague idea what it does. In general I must say that having a lot of options to customize game-rules does not exactly make it easier to develop AI.
Especially in this case this can have massive implications on how you should play. Range being completely limited is the easier part to deal with. The evaluation method for the respective fire-mode will just return 0 accuracy and thus you know you need to walk closer. This is similar to how my AI handles smoke. I'll have to look whether it should already work or needs a small tweak. Just looked. Should already work. If the code that shoots doesn't shoot and the code that should move the Alien thinks the aliens doesn't need to move because it's already in position, it assumes it's vision is blocked by smoke and walks closer. Doesn't matter if it's smoke or other reasons. But having gradual drop-off or sudden drop-off of 50% means you have a lot of cases where you'd have to compare getting closer vs. shooting from where you are. Currently I just assumed: If you actually can shoot, then shooting is always the best option. But I guess when range has massive impact on accuracy this isn't the case anymore. And coming up with a good solution for that is not exactly trivial. You'd kinda need to simulate the outcome of different options maybe even several turns in advance when the distance is too big. As in: I have a line of fire but my chance to hit is only 1%. If I spent 2 turns on moving closer, I could bring it to 45%. But at the same time I might be killed by an enemy sniper who operates without these restrictions.

Eventually my entire: "Go out in the open where you have a good overview" idea might simply be undesirable if weapon-accuracy-behavior is modded in a direction that's vastly different from default-behavior.

So far all of this is only taken into account in the accuracy formula. But that is only used to compare different options of shooting, not shooting vs. moving.

When it comes to "mature enough", I'd like to know what the expectation for that would be. So far I haven't requested a new build from Meridian since quite some time. I also don't really like having to depend on someone else in that regard and am still quite interested in help when it comes to making my own install-ready-builds.

My approach was more like: I wait until someone shows interest (e.g. tells me they'd like to start streaming it) and then release the newest I have up until that point.

I currently have a situation that I don't quite like. It is about what constitutes as "spotted".
Up until yesterday I checked for actual visual contact of at least one friend to consider a foe attackable. However, that meant that if the spotter died or moved into cover after shooting, the visual contact was broken and others wouldn't snipe anymore.

So I used turnsSinceLastSpotted() == 0 instead, thinking it would be the same that I get as a player with the little green boxes. However, it's not only visual contact that makes a unit spotted. Taking damage and/or dying from fire of a unit also makes it considered spotted.
This basically means that my snipers get revealed to the enemy for the turn after doing their sniping. In some way this is comprehensible. But I must say that it felt unfair to me as it seems to cross the line between "cheating for simulating experience" and "cheating for an unfair advantage". I mean I could try to guess where a shot from outside vision-range came from and shoot there too. But it's a different thing to know exactly where it came from and just having a general idea.

I guess I need something that works similar to turnsSinceLastSpotted but without the part where shooting at someone makes a unit spotted by default.
Title: Re: Looking for some advanced strategies and their counters
Post by: Vakrug on November 10, 2022, 11:50:41 am
I guess that many of them are based on exploiting current weaknesses of the AI, so I'm particularly interested on the ones that don't and are more general in nature. But also the ones that do exploit weaknesses can be mentioned so I can tell whether I've already taken it into account or not.
I will repeat what I said in "For AI-improvements" thread: AI should not act like lemmings, it should act like soldiers defending a castle. Aliens should run inside UFO, not outside. Abolish entirely your idea of "Go out in the open where you have a good overview" (except if it is X-COM base attack). In most cases it is not aliens who attack, so they should not hunt for player's units at all.

If you will not address this issue, any other improvements to AI will be cosmetic and useless.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 10, 2022, 01:20:18 pm
I will repeat what I said in "For AI-improvements" thread: AI should not act like lemmings, it should act like soldiers defending a castle. Aliens should run inside UFO, not outside. Abolish entirely your idea of "Go out in the open where you have a good overview" (except if it is X-COM base attack). In most cases it is not aliens who attack, so they should not hunt for player's units at all.

If you will not address this issue, any other improvements to AI will be cosmetic and useless.
I agree with the "not act like lemmings" sentiment. That's why I'm not letting them give up a good position just to get a line of sight if there's not already combat happening or it is considered safe to do so.

But I really disagree about your assessment that any pro-active behavior should be avoided and is "cosmetic and useless".

While camping choke-points does have some merit, there's usually ways for the acting side around this. If you all gather in the same room, you are subject to stuff like grenades. If you spread out within the UFO, bigger numbers and careful advancement can overwhelm your position. Also you never have the advantage of being able to flank.

And most importantly, it would be predictable and boring, if the aliens act completely defensively and "don't hunt for player's units at all". You'll not have to worry about ever losing a Skyranger because if you run out of steam to make further progress, you just retreat and they'll let you. A soldier panics and runs off? Can just wait for him to calm down and bring him to the Ranger too. Can even collect the items and artifacts of dead soldiers and aliens and carry them in.

I don't see how the kind of behavior you suggest can be brought in line of what I envision as "brutal". The way my AI currently works, where aliens seek having a great line-of-sight- and movement-potential-coverage while also making sure to spread out, actually does make it feel pretty brutal. They can react quickly and punish you for leaving cover while at the same time limiting how many you can kill at once and having you guess where they actually might be until you are eating their plasma-blasts. I'd even make a comparison to chess. In chess you also usually seek to increase piece-activity by bringing your pieces to positions where have many options to move to. Putting yourself in a narrow corridor inside an UFO that has a dead-end in one direction and a choke-point where the enemy is coming from in the other leaves you with very little options. I mean it is important that when the aliens get into this situation that they make the right calls too. But I really don't think that they should bring themselves into that situation and never deviate from it.

I think from a tactical consideration the ideal scenario is the one where you maximize the ratio of your gun-barrels pointed at the enemy vs. gun-barrels of the enemy pointed at you while making sure you are the one who opens fire first and the one who has more different attacking-angles to avoid AoE.

Encircling a choke-point X-Com must come through and then striking once they do. That's what I consider a sound tactical approach from the perspective of the aliens.
Title: Re: Looking for some advanced strategies and their counters
Post by: Juku121 on November 10, 2022, 05:01:11 pm
So far I've usually done AI for 4x-games where you and your opponents start at an even footing and that are about at least somewhat fair competition. In these scenarios having an AI that plays as good as possible was kinda desiarable.

But for X-Com I'm already questioning the sensibleness of what I've done in the past two weeks.
I'm a big fan of your work on Pandora: First Contact. :)

But it's indeed a thorny path, since current AI means a lot of mods are overtuned against the player and would be pretty near genuinely impossible if the playing field was relatively level. You might easily get a repeat of TDTD 'fixing' the difficulty. :P

Extended accuracy
penalty (usually 50% loss) in accuracy unless you have personally line of sight.
Yeah, these seem to be pretty much standard in most mods now.

getTurnsSinceSpotted()
You might also want to check 'turnsLeftSpottedForSnipers'. I mean, you're basically writing an AI for an all-sniper, all-spotter team, which is fine and desirable for the base game or mods that don't deviate much from it. But sometimes a modder wants some weaker enemies, or enemies the player can combat by killing their spotters or avoiding their snipers. Llike brainwashed policemen, or farmers with dogs, or gangbangers and their leader, or Meridian a Predator with spotting drones, etc.

What I did with that was that everyone will be a sniper if there is something to snipe.
What I meant is that I (and I imagine a whole bunch of modders) would prefer if only units with the 'sniper' tag did that. And only 'spotter'-tagged enemies comminicate their vision back to others. I imagine every alien in OG UFO can be considered both a sniper and a spotter, but not every modded enemy is the same.

Taking damage and/or dying from fire of a unit also makes it considered spotted.
Yeah, that's the biggest 'problem' with the current sniper/spotter mechanic. You can't have a marksman who shoots at what their spotter points out, it's either alien death snipers who know exactly where you are if you ever hit someone on their team, possibly for quite a while afterwards, or no snipers at all. Reasonable enough for OG-style aliens who might have psychic sensors in their UFO they can sic on spotted enemies, or something like a giant turret with a crazy auspex. Not so much for when a mod pits the player against a bunch of football hooligans with baseball bats and handguns.

I guess I need something that works similar to turnsSinceLastSpotted but without the part where shooting at someone makes a unit spotted by default.
Well, couldn't you just disable the 'spot offender when hit/killed' part? At worst, make some sort of phantom 'soldier' in the rough direction of where the shot came from?

...smoke-grenades don't help because they only protect in 2D, as you say.
Smoke grenades can also be made 3D with an option, like any other grenade. They do thin out towards the top, but you can always throw some more.

I also have added an anti-smoke-grenade behavior for the aliens. Basically when it thinks it should see someone but doesn't it will move closer until it does.
There are also built-in modding tools to help: heatvision and psi-vision.

Oh right, proximity-grenades. ... I need to know what proximity will trigger them and then add code for the aliens to avoid them.
Being right next to them, i.e. in one of the eight adjacent tiles or the tile it's located in. Right above/below seem fine.

Make sure not to completely invalidate them, or smokes for that matter. Players will not be happy if you make their toys totally useless.

However, this does not apply to certain (sniper) weapons and grenades.
But it does? I recall Starving Poet being extra salty when this was implemented in the middle of his XCF stream, and he ended up modding this back to a much lighter penalty than the default 50%.

Of course a modder can make their grenades no-LoS, but that's a deliberate choice.

Also interesting that using instant-grenades isn't a good solution because it makes it easier due to not allowing for reaction-fire of the naded alien.
An insta-naded alien can definitely return fire. A smoked alien might not, and there are also mods that use TU-sapping weapons like flashbangs that might also rob them of the ability without removing LoS.

I always play with instant grenades, but ones with limited range (12 for ones with weight 3, something like 4 for demo packs that aren't really all that throwable IRL). 12 might even be too generous. I also tend to make them less accurate and explode in inventory when the time is up. Grenade range is one of my biggest pet peeves with the game. One that virtually no-one else seems to share, though. :-\

These are game mechanic issues and I don't see how it could be addressed in AI code.
The 'brutal' AI can (try) to learn to use them?



Finally, while Vakrug's point about UFOs being fortified castles is rather hyperbolic (and you might not have a UFO at all, nor a player craft for that matter), one of the things I very much liked about Xenonauts was how their AI camped the hell out of UFOs. They were a bit cheaty, as in knew exactly when your troopers had run out of TU for reactions and opened doors (and fire) just at that moment, then gladly waited until you tried opening the door yourself and blasted you at point-blank range when you did. Not to mention UFO bridges full of valuable equipment (which tended to suffer in the firefight) and the deadliest aliens on the map, lurking behind consoles and along the walls, catching you in an almost unavoidable crossfire. I killed many a UFO door to kill/suppress the ETs lurking just behind.

Well, that and their Reapers' habit of sneaking up behind soldiers and giving you heart attacks. ;D

My approach was more like: I wait until someone shows interest (e.g. tells me they'd like to start streaming it) and then release the newest I have up until that point.
That might be a long wait. :-\
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 11, 2022, 01:04:01 pm
@Juku121 Let me try and answer somehow without having to do a post-disection-again. :D

Someone who replied to me via PN told me they wanted my AI to work like a flag for mods that can be set on an alien to alien basis.
So my idea is to eventually provide two methods to use it. One as a general option in the advanced-options-menu that flips it on for everything but also as a flag that can be set by modders for some specific aliens.
So both players and modders can have control over whether they want to use the new AI or not.

Maybe even Yankes would be fine with this kind of compromise.

Also for the quick-battle game-mode it's completely fine. Because unlike to a lengthy campaign you aren't really attached to the soldiers and the outcome doesn't matter much. Beating a quick-battle with one soldier suriving is a relief, whereas in the campaign that would be considered horrible (unless it's the final mission). So the exact same battle can either feel exciting or frustrating depending on the context in which it took place.

I found a different solution for my sniper-issue. I introduced a new property to BattleUnit that is similar to lastSpotted but only gets reset by visual contact. But that alone wasn't enough. I also needed to increment the counter at every half-turn, not just every turn. That is because otherwise the aliens would still know where people are that they briefly saw on my turn but that I retreat. But now it works like I intended it to work.
Note that I'm still cheatily looking at positions of player-units for general tactical decision-making as a means to emulate experience and memory. But I really felt that needed to be strictly separated from what they can choose as targets for their actions.

I think you may have misunderstood my intentions about how the AI should deal with smoke-grenades. I don't want to let the AI cheat to make them useless. I want them to employ some counterplay. And I think that simply walking further into the smoke until you actually see someone is the right answer. So smoke still has the intended effect and can be very useful in certain situations but doesn't just mean you can use it as if it was real cover.

I think I won't do anything against proximity-grenades for now. What I'd have in mind as a solution would turn them pretty-much useless. The general behavior of the aliens should make it more difficult to predict where they will go and use these grenades in an exploitative manner.

I think that my first concern is to make it all work with the vanilla-mechanics and rulesets. As you already said the probably massive difficulty-spike will most likely make it not balanced for the already existing mods that seek to increase difficulty in other ways. By making it also available via a modding-flag modders can then take control on how to use it. And fully supporting all possible rulesets that modders might have come up with, seems very hard. I mean someone could walk me through some possible scenarios and how their existence alters play from how it would be good in vanilla. So then maybe I can integrate at least some support.

About the insta-nades. I actually found a bug yesterday that prevented the AI from realizing the explosion-radius of their own grenades, which meant they were wasting TUs on units or further grenades on units that would die anyways. It was obviously intended that they realize it but it simply didn't work because of an incorrect parameter in the line-tracing-call of the explosion. So insta-nades would actually help them too now as it allows to immediately reaccess the situation and know when someone survives a grenade. Especially since I coded something really nasty for their grenade-usage: They now consider indirect fire of them too. So if they've spotted (as per the new method) you behind a corner and another alien has no line of sight, it can now throw the grenade next to the corner to still hit anyone hiding behind it. Not limited to nodes that is. Every tile in the explosion-radius from the targetted unit is considered a possibility.

I always play with instant grenades, but ones with limited range (12 for ones with weight 3, something like 4 for demo packs that aren't really all that throwable IRL). 12 might even be too generous. I also tend to make them less accurate and explode in inventory when the time is up. Grenade range is one of my biggest pet peeves with the game. One that virtually no-one else seems to share, though. :-\
The 'brutal' AI can (try) to learn to use them?

I'll actually see if I can get a new version out today. Since yesterday I've reworked basically every single part of the AI. Then I also found and fixed some bugs. So I'd say the current version on my Repo would make for a decent milestone in the development and something I'd like people to be able to try out for themselves.
Title: Re: Looking for some advanced strategies and their counters
Post by: Juku121 on November 11, 2022, 01:54:06 pm
The 'brutal' flag and option, as well as a new flag for direct actions as opposed to general decision-making all sound good.

I did not really want dispute any specific plans regarding smoke grenades, just put out a general warning against going in too hard to mitigate them. Although walking into smoke isn't all that universal a solution. A lot of the time, enemies are pretty damn far from any smoke of mine that's just chilling somewhere between me and them.

I do tend to play mods with excessive vision range (40 instead of 20 by default, though I personally tend to pull it back to 30 again). I imagine 'maxViewDistance' is another modding option that has massive implications for AI and balance, especially since increasing this makes all sight calculations a lot more expensive. And you can't really walk into a smoke cloud 25 tiles away unless you're a Chryssalid.


And, yeah, making a proof of concept with the vanilla ruleset first is very much recommended.

AI using indirect grenades sounds cool, too. Though bear in mind that there are also grenade launchers that do similar things (is the Small Launcher the only one in vanilla, I forget?).

Although another lesson from Xenonauts is that players can be quick to get their pitchforks if their opponents are supernaturally good at using grenades. Make of that what you will. :)
Title: Re: Looking for some advanced strategies and their counters
Post by: Yankes on November 11, 2022, 08:18:16 pm
Maybe even Yankes would be fine with this kind of compromise.
Yes, if new AI is fully configurable (aka I could be more in some cases more dumb or deadly if modder want) then I would not be against inclusion.
If I recall correctly, Meridian was weakly against your current approach, this means that if you AI will have enough community support then there is chance that Meridian could be convinced to include your changes to OXCE.
Title: Re: Looking for some advanced strategies and their counters
Post by: The Reaver of Darkness on November 13, 2022, 11:57:01 am
TACTIC:
When coming around a corner, always face toward where aliens are likely to hide so as to activate mutual surprise and suppress reaction fire.

COUNTER TO TACTIC:
Always have multiple units facing where X-Com can approach, facing in from multiple angles so that they cannot activate mutual surprise on all of them at once.

COUNTER TO COUNTER:
Move in with a durable/armored unit, tank, or expendable unit; throw grenades/proximity mines into where aliens are likely to be camping; barge through the walls; use motion scanner to determine positions; destroy all walls with explosives.

- - -

TACTIC:
Hide your soldiers in smoke.

COUNTER TO TACTIC:
Throw grenades into smoke clouds; fire blindly to where soldiers are likely to be positioned.

COUNTER TO COUNTER:
Put smoke everywhere and use motion scanners; put decoy smoke clouds to waste enemy grenades.

- - -

TACTIC:
Move durable and/or expendable units forward to scout, and keep snipers in the rear with good field of view to attack from outside of vision range.

COUNTER TO TACTIC:
Do the same; or if good sniper positions are limited, fire blindly into them, or stay away from positions which have a line of fire from good sniper nests (such as rooftops).

COUNTER TO COUNTER:
Find more specialized and less predictable sniper positions; use smoke, explosives, and/or terrain destruction to "construct" new sniper nests; use psi wizards instead of snipers who don't need line of fire.

- - -

TACTIC:
Blaster bomb the command/navigation room on the first turn in order to destabilize alien morale.

COUNTER TO TACTIC:
Bury command center in center of ship; use redundant armored walls to make it harder to blast through; have separate command and navigation rooms; distribute command ranks throughout ship; bring units with high bravery.
LOGISTICAL IMPACTS, RESPECTIVELY:
Less efficient ship interior design for normal functions; ship is heavier and more expensive; command delays reduce force responsiveness; lack of dedicated command center reduces control; high bravery units are less intelligent and thus less suitable for many operational tasks.

COUNTER TO COUNTER:
Carefully raid their less efficient ship design; bring more blasters; use a composition which does not rely on blasters; hide and camp the aliens.

ALTERNATIVE COUNTER TO TACTIC:
Take advantage of all of the soldiers who spent their whole turn inside the ship, and bomb the X-Com craft to kill them all.

COUNTER TO ALTERNATIVE COUNTER:
Spread your units out and don't ever leave a ball of them in a predictable location. Best to leave nobody at all inside the craft because it might get bombed first alien turn.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 14, 2022, 12:13:02 pm
I did not really want dispute any specific plans regarding smoke grenades, just put out a general warning against going in too hard to mitigate them. Although walking into smoke isn't all that universal a solution. A lot of the time, enemies are pretty damn far from any smoke of mine that's just chilling somewhere between me and them.
Using smoke-grenades is a game-changer especially against the more current yet unreleased changes in my AI about the turn-order-manipulation, which allows the AI to really play like a human player when it comes to sniper/spotter-coordination. As in: The spotter moves in until he sees something but then the snipers take their shots first and the spotter then either moves in further, shoots himself or moves out a little again.
They almost feel like a hard necessity now on the more open maps. They force the spotter to come much closer and make it more likely to discover him first. But on the other hand they also make it so you don't really know where to look until it's too late.
As I said, the anti-smoke-logic doesn't even know about smoke. So they don't just "walk into smoke". The logic is more like: The shooting logic didn't shoot and the walking logic think it shouldn't have needed to walk as it should already have been able to attack from where the alien is. If both these conditions are true it'll just walk further towards where it thinks enemy units should be. The same should also help them with range-limited weapons and mods that impair their vision at night.

I do tend to play mods with excessive vision range (40 instead of 20 by default, though I personally tend to pull it back to 30 again). I imagine 'maxViewDistance' is another modding option that has massive implications for AI and balance, especially since increasing this makes all sight calculations a lot more expensive. And you can't really walk into a smoke cloud 25 tiles away unless you're a Chryssalid.
I've already taken that into account in every range-based-decision in my AI, of which there actually aren't that many left, now that I think of it. Sight-calculations are only done after moving. The by far most taxing in my AI is the line-of-fire-calculations which are independent from sight. I got reports of massive slow-downs from the one user who actually tested what I put out. SO I had to intervene and massively change how excessively I use them. My tests showed that the loss in playing-strength is minimal but the gain in performance is massive. (compared to the version that is put out for testing) It even forced me to come up with a new and much better algorithm to detect encircle-points. I might even use that new algorithm to detect choke-points and treat them in a different way.

AI using indirect grenades sounds cool, too. Though bear in mind that there are also grenade launchers that do similar things (is the Small Launcher the only one in vanilla, I forget?).
Yes, right now the small-blaster is still used like a direct-fire-weapon, which is not ideal but also not overly problematic. But I can totally see that in Mods where the enemies get stuff like rocket-launchers, you'd want to treat all that differently too. Shouldn't be that hard to adapt. I've seen the property of explosion-radius can be derived from the ammunition as that is already done with the blaster-launcher.

Although another lesson from Xenonauts is that players can be quick to get their pitchforks if their opponents are supernaturally good at using grenades. Make of that what you will. :)
Well, I think it's not just grenades, it's the entire AI, that I have some doubts about the actual usability for regular play-throughs.
It's definitely way more fun in the quick-battles where the outcome of a mission doesn't matter.
I've done three playthroughs alongside of development and especially the last one was quite frustrating while playing self-enforced (due to Meridian's warnings and also not robbing myself of potential material for debugging) ironman. But it also meant I had to grow as a player and this thread has helped quite a bit with that. So far smokes had to become a staple.

But since it's all optional and can be switched off at any time, that should prevent the pitchfork-thing. It's the player's decision of whether they want the aliens to be unleashed or not.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 14, 2022, 01:48:39 pm
Yes, if new AI is fully configurable (aka I could be more in some cases more dumb or deadly if modder want) then I would not be against inclusion.
If I recall correctly, Meridian was weakly against your current approach, this means that if you AI will have enough community support then there is chance that Meridian could be convinced to include your changes to OXCE.
The requirements Meridian told me where actually much less conflicting with how I envisioned it than what you told me in the comments about the initial pull-request.

They were:

1. Fully backwards-compatible, which just means that when not using the option, the game behaves exactly like before. That seemed most easy to realize by using my own methods for everything and leaving the methods of the base-AI alone. But that approach is something that you seemed to have taken an issue with due to duplicating code. I have not copied any method that I didn't change at least something in. In the later iterations the changes have become bigger and bigger. So even the initially almost unaltered methods are now quite different than what their origin looked like. They still often fulfill the same task but in a way meant to optimize efficiency rather than emulating OG-behaviour.

2. No work in progress. This was only a problem to me as long as I had no alternative to allow people to test my work beforehand. But we found a compromise where he builds versions for me from a separate branch. I now even prefer it this way as it allows me to experiment with things I probably wouldn't have experimented with before and can tidy everything up later. But that also means it will definitely not happen anytime soon. Developing AI has a bigger scope than adding a new button that does something very specific. So it definitely will take some time until I run out of things to improve.

What you were asking in those comments, however, seemed much more difficult to realize than what Meridian asked for. Especially since it seemed to be partially conflicting with Meridian's requirement #1.

I really do not want to mess around with the original AI code and inject all of my stuff there. This would make ensuring backwards-compatibility very, very difficult and lead to almost incomprehensible code within those methods.

I think at this point it would be even better to add my AI as a completely new class to keep it even more strictly separated.

Your other point was to make different behaviors of the AI configurable separately. I think that something like that only really starts to make sense when the AI is mostly finished and thoroughly tested so one can actually have an overview of what would make sense to be configurable.

I definitely do not think that every single thing about it should get it's separate switch.

Right now I see 2 main options that I think make sense for it:

1. Respect limitiations. => There's some optional (and controversial, if I read the threads about these correctly) limitations for the regular AI that are active by default. I want my AI to ignore these limitations by default but think there should be a way to reenable all of the them as an option.

2. Giving modders control of when to use it or not. I'm not really sure though what possibilities a modder has when it comes to defining conditions for something like that. There's many potential possibilities and I don't know just yet. For example: Assign it to certain units/unit-ranks. Could, for example have the Leaders and Commanders use it but not the basic soldiers. Or you could want to make the Sectoids use it but not the Mutons.
Other possible scenarios could be to enable it with a turn-timer in a mission... or a month-timer in the game... or for specific mission-types. There's a lot of thinkable scenarios and I don't know yet if I have to specify them separately or if the modder can control all of them with only one hook in the code.

As I said, when it comes to sub-routines also being moddable, we'd first need to define for which sub-routines that makes sense in the first place. This would have to be based on feedback in the sense of: "I wished they could still do that but would not do that."
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 14, 2022, 02:49:38 pm
@The Reaver of Darkness

On your first point about facing where X-Com can approach: I actually managed to conjure an algorithm yesterday that does that. I had a similar one previously but it was a bit whacky at times and sometimes had weird results. The new one, however, seems to make really good predictions and when I combine it with some other ideas could lead to really good decision-making about guarding at good positions vs. trying to attack. I think this really allows for advanced tactical considerations. Move in when the enemy is surrounded but don't move in when the enemy has set up a trap and is waiting for you to make a move.

I've also considered part of the counter to the counter in the sense that the algorithm that determines where to "camp" a specific position prefers greater distance and units avoiding to stand too close to one another. So instead of just standing there in one place and inviting a grenade, they spread all over the place.

The algorithm also will consider self-made holes. But of course if you do it all in one turn, it can't react so the counter to that is still valid. And sending in well-armored units first of course also will remain helpful in any case.


I'm not a fan of the proposed counter to smoke. Exactly because of the counter to the counter you mentioned. It would be rather exploitable if you knew the AI would react in that way to smoke. I think what I taught the AI to do when it cannot see is pretty decent in combination with it's ability to alter move-order at will. It can send in a spotter and have units from far away shoot at whatever the spotter can see. It's not perfect and risky for them too. But it kinda does the trick.


Yeah for Spotter/Sniper coordination, doing exactly that and doing it properly is one of the main reasons that make my AI hard to fight against. I actually shunned away from "firing blindly at sniper-positions". That's mostly because it's hard to emulate "guessing" in a believable way. If the AI "guesses" correctly, it feels like it's cheating. Not that it isn't cheating at all, but I think there's a line that must not be crossed with the cheating and blindly firing at the right positions imho crosses that line.

Staying away from anything that could be used as a sniper-positions is a must against my AI anyways. Fighting anywhere outdoor, especially on maps with little obstacles like arctics or deserts is already extremely tough and makes smoke kind of a must... And then you realize that at least with default-settings Floaters in the air see you anyways.


When it comes to blaster-bombing the command/navigation room on the first turn, I guess there's not really anything the AI can do about. Your counters are not things the AI has control over. That's a map-generation-issue. The player always moving first means there cannot be any counter the AI could possibly employ.

Doing the same thing back to X-Com is not really a counter. It's more a question of opportunity. If they get that opportunity, then they should of course go ahead and do it. Mind-control would also be awesome to counter X-Com using weapons too powerful compared to their armor.

I've also implemented my own version of explosiveEfficacy, which reduced the aliens hesitency to use explosive stuff by making any net-positive in kill:casualty-ratio "worth a shot". Also in particular does a mind-controlled soldier see itself as an enemy worth killing with explosives too! I think that blaster-wielding aliens should probably ignore themselves instead counting themselves as a casualty. Because they usually only have the blaster and when they are the last remaining alien their option is to take the enemy with them or die anyways.
Title: Re: Looking for some advanced strategies and their counters
Post by: Yankes on November 14, 2022, 08:54:29 pm
The requirements Meridian told me where actually much less conflicting with how I envisioned it than what you told me in the comments about the initial pull-request.

They were:

1. Fully backwards-compatible, which just means that when not using the option, the game behaves exactly like before. That seemed most easy to realize by using my own methods for everything and leaving the methods of the base-AI alone. But that approach is something that you seemed to have taken an issue with due to duplicating code. I have not copied any method that I didn't change at least something in. In the later iterations the changes have become bigger and bigger. So even the initially almost unaltered methods are now quite different than what their origin looked like. They still often fulfill the same task but in a way meant to optimize efficiency rather than emulating OG-behaviour.



OXCE is not fully "compatible" with OG, there is multiple changes in behavior (and even AI) but most of them are subtile and do not affect game play aside of some corner cases.

If feature was critical and important then Meridian would allow small changes in OG behavior, but as he think that new BrutalAI is neither, and because of this, he demand no changes at all in default behavior.
I personalty could permit more changed in OG behavior at least if they are faithful to OG. But for now if Meridian explicit require it from you then I will not try override his request and I consider it still holding.

For you code, as I previously said if your new function is fully configurable then I could accept duplication of code as it make easier to realize Meridian requirements. Only thing I require more is that new AI could be configure in that way that for normal user will not see difference to old AI. This mean not work exactly same but overall similar and you could ignore corner cases. This should be relative easy to do.



2. No work in progress. This was only a problem to me as long as I had no alternative to allow people to test my work beforehand. But we found a compromise where he builds versions for me from a separate branch. I now even prefer it this way as it allows me to experiment with things I probably wouldn't have experimented with before and can tidy everything up later. But that also means it will definitely not happen anytime soon. Developing AI has a bigger scope than adding a new button that does something very specific. So it definitely will take some time until I run out of things to improve.

What you were asking in those comments, however, seemed much more difficult to realize than what Meridian asked for. Especially since it seemed to be partially conflicting with Meridian's requirement #1.

I really do not want to mess around with the original AI code and inject all of my stuff there. This would make ensuring backwards-compatibility very, very difficult and lead to almost incomprehensible code within those methods.

Magic word: Refactor
Some times function it impossible to change but you can rewrite it in that way its behavior do not change but adding new functionality is trivial.
This could even make code easier to read. At least this would be approach I would take to improve code like AI.
This would require lot of skill and time but in long run would reduce work you need to do in improving AI.

Another benefits of refactor like this would be closing all holes in engine logic, some thing like this could even permit changes in visible behavior of aliens.


Again this is not that you should do it now, but how I would try approach this problem. I already apply this approach to some changes I did before in OXCE, last one was custom move cost that required lot of refactor of handle both TU and Energy as limits. This could be inspiration how it could be done for AI.




I think at this point it would be even better to add my AI as a completely new class to keep it even more strictly separated.

Your other point was to make different behaviors of the AI configurable separately. I think that something like that only really starts to make sense when the AI is mostly finished and thoroughly tested so one can actually have an overview of what would make sense to be configurable.

I definitely do not think that every single thing about it should get it's separate switch.

Right now I see 2 main options that I think make sense for it:

1. Respect limitiations. => There's some optional (and controversial, if I read the threads about these correctly) limitations for the regular AI that are active by default. I want my AI to ignore these limitations by default but think there should be a way to reenable all of the them as an option.

2. Giving modders control of when to use it or not. I'm not really sure though what possibilities a modder has when it comes to defining conditions for something like that. There's many potential possibilities and I don't know just yet. For example: Assign it to certain units/unit-ranks. Could, for example have the Leaders and Commanders use it but not the basic soldiers. Or you could want to make the Sectoids use it but not the Mutons.
Other possible scenarios could be to enable it with a turn-timer in a mission... or a month-timer in the game... or for specific mission-types. There's a lot of thinkable scenarios and I don't know yet if I have to specify them separately or if the modder can control all of them with only one hook in the code.

As I said, when it comes to sub-routines also being moddable, we'd first need to define for which sub-routines that makes sense in the first place. This would have to be based on feedback in the sense of: "I wished they could still do that but would not do that."

Now goes my requirements (for now this is only things I will require in future before inclusion of your code to OXCE):

For 1. even if you make separate AI it should obey configs set by modder, as whole point of them was to control AI, if you do not want this restriction make mod that set them all to zero, and this mod could be part of default OXCE install (same how we handle features from UFOextender).
And this should be way how your change be enabled, special mod that can be enabled with any other mod.

For 2. Make simple `struct AiConfig { bool UseBrutalAi, UseBehaviorA, CheckForX, IgnoreZ; void load(const YAML::Node&); };`, AI object get copy of this struct and read only from  it, and do not check any global state. How AI get this struct should not bother you now any way, this will be for future to decide, for now it could be one object for whole `class Mod`.
Every function as part of AI class have access to this `AiConfig` and check for `if (_config.SomeFeatureC)` if you need alter behavior in some subroutine.
For start, function that you will need to allow configure is one that make biggest departure from original AI, this mean modder can restore partially old behavior.
This mean you do not need exactly implement old behavior, but it need be close enough that is easy to miss when you do not know for what to look.
e.g. Door blocking by Xcom soldier, normally AI will fail to open them, but your can do it, you add `if (_config.OpenBlockedDoors)`and this could be `true` by default for your AI.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 14, 2022, 10:19:34 pm
This is a screenshot from Remnants of the Precursors, which I worked on before.
Which AI to play against is simply an option you choose before you start the game.

One Option for each AI.

This is basically what I intended it to be like for OpenXcom as well.

I must say that what you are asking for exceeds what I'm willing to do.

Emulating the entire current behavior and making every single aspect of it, even little things like opening doors, configurable adds a lot of work that would be no fun for me to do. I do not see AI as something to be microconfigured with mods. To me the relationship between mod and AI is primarily that the AI knows what to do with the toys that modders can give to it.

That's what I'd expect/hope for as a modder. The decision which AI to play against is a decision I want to leave at the player.

As I said, if in feedback some modder asks about disabling or configuring certain aspects of my AI, I'd see some point. But developing all of that in advance for the theorethical possibility that someone might potentially want to mess with it, simply seems to be a bad cost:effort-ratio to me.

I'd also ask to consider the aspect of https://en.wikipedia.org/wiki/Overchoice
Title: Re: Looking for some advanced strategies and their counters
Post by: Yankes on November 14, 2022, 11:08:33 pm
I nowhere ask for "emulation" only for similar behavior and this is big difference and should not dramatically affect implementation.

Of corse I can't force you to do anything, this is your code and you can do anything you want but we have our own cost/benefits ratio
and for now I do not see if your branch will pass this threshold.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 15, 2022, 01:58:43 am
I playtested for several hours straight and put most of it on video. All in one play-list now.

Smoke grenades really are extremely potent. I basically emulated the same thing the aliens are supposed to do when there's smoke. Except I have the big advantage of placing the smoke where I want it and having several HE-grenades on everyone. It is also extremely helpful to act quickly to disrupt the aliens from better preparing.

Sometimes some aliens still were in the UFO by the end of the mission. I guess they may have been blocked from exiting it. I think I need a version of the path-finding that ignores their own units so they can at least start to walk out when someone is in the way and go close to the alien blocking the exit.

Edit: Okay, so I did a little experiment: I repeated the same mission twice and also acted the same way, except for one small but crucial difference: In the second attempt I skipped 5 turns at the beginning to allow the aliens to position themselves in the way they want to be positions. And it made a massive difference. The difference that when their spotter closes in on me there's 7 other aliens shooting and not only one or two. So the key to the success is to act quickly and disrupt their preparation.

So what I'm thinking now is that they should continue their preparation and only start to employ their anti-smoke-behavior when the preparation has progressed further.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 15, 2022, 01:22:03 pm
Here's my thought process on the situation and approach for the aliens in a clearer wording than what I was capable to deliver at 2 AM:

The problem is not how the aliens deal with smoke-grenades but when. They immediately start shortening the distance in the hope of getting into visual contact. An approach that only really makes sense when you can count on the support of your friends.

However, we have an asymmetry due to map-generation. Since the aliens start scattered across the map and some are in positions that take several turns to participate in any combat, it can be considered suicidal to start charging before everyone is in position. However, staying passive when x-com is advancing towards your position also is no long-term-option.

So my idea is the following: The aliens that spawn outside should try to avoid combat for as long as possible to buy time for their teammates to get into a better position.

They could do that for as long as no X-Com has been spotted. Spotted in this case includes being attacked. If it happens immediately they would fight back. But when X-Com acts slowly. For example by first throwing smoke and then advances from smoke-cloud to smoke-cloud, this delay should be welcomed and used for improving their position. If contact can be delayed for several turns the prospects of an engagement are vastly imroved as a spotter will not enable just one or two other aliens to open fire but ideally all of them.

I can't wait to try this approach and see how it impacts what the missions feel like. Should hopefully increase the tension before combat starts happening and the intensity when it does. Also put more pressure on the player to act more quickly as approaches like skipping the first turn to avoid reaction-fire will come with the disadvantage of giving the aliens more time to organize their own battle-plans.
Title: Re: Looking for some advanced strategies and their counters
Post by: psavola on November 15, 2022, 07:09:17 pm
Most advanced players usually also use motion scanner a lot, especially in non-open maps, next to ufos or if you have substantial amount of smoke. It provides information on whether someone moved within 9 squares in each direction. This is essentially a must have when breaching UFOs, but also essential with buildings, city terror missions etc. to verify whether there are aliens [or civilians] nearby (e.g. in nearby buildings). In OXCE, pressing down ALT after a scan shows the locations on your screen, providing an easy and usable interface to the results.

Looking at the vids, you've nicely adopted the basics of smoke grenades. Bear in mind, however, that thickness of smoke decreases further away you get from the center (and with time, but not sure if the decrease is gradual). While visually "iwthin" smoke, usually about 2-3 squares closest to the edge do not provide guaranteed protection from visibility to the outside.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 16, 2022, 11:22:52 am
I actually tested how the smoke slowly degrades by disabling the alien's anti-smoke mechanism and just clicking end of turn. Over time more and more of my soldiers became visible and thus shootable again. The process, however, is relatively slow and doesn't play much of a role as by the time it's mostly gone the mission would already have been over.

I have also tested my idea from my last post and frankly it did not change the result by a lot. It did change how the mission plays out though. But not in a way that makes it more interesting. So I scrapped it.

I have a hard time with coming up with other counters for the aliens. One idea is to mimic my own approach more in the sense that the aliens would also use a dedicated spotter instead of closing in with everyone. That way they should at least avoid presenting themselves as easily nadable targets and have more TUs for shooting. However, I'm not seeing how that resolved their main-problem of at best finding my spotter but having access to the rest of my squad denied. It might actually even be disadvantageous as it decreases the chance they will get a first-strike-advantage at all. I'll have to test that though.

In theory they would seek to circumvent my spotter(s) and flank my backline. But that's a very abstract idea that requires quite some thought as to how something like that could actually be put in place.

About the motion-scanners:
Interesting. So the combination of motion-scanners and smoke-grenades seems like a way of gaining a pretty big tactical advantage over the aliens. And with that GUI-trick, You can essentially "see" them without actually having to make visual contact. From the AI's perspective that seems like a tough disadvantage to overcome. So far I really wanted to stick to the unwritten rule that the AI must never attack someone who it hasn't made visual contact with. The player being able to make visual contact much harder to achieve for the aliens and even having ways of not having to make it themselves to shoot them, really is something I'm not sure how to deal with.
Title: Re: Looking for some advanced strategies and their counters
Post by: Yankes on November 16, 2022, 11:28:48 am
btw, you should not hardcode smoke as opaque for AI as some alines can clearly see though it, and another thing is that fire could blind some alines too.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 16, 2022, 11:54:30 am
btw, you should not hardcode smoke as opaque for AI as some alines can clearly see though it, and another thing is that fire could blind some alines too.
So far nothing hard-coded about it. The logic is: "I should be in range (according to _save->getMod()->getMaxViewDistance()) but couldn't actually attack something. (as otherwise I wouldn't even have gotten to the movement-part) Conclusion: Either something is impairing my vision or my weapons have limited range."
From that point it doesn't matter what the reason is. The solution was: get closer.

And as I said, this worked pretty well unless I refined my tactical approach to instead of moving my whole team through the smoke a little bit at a time to: A few persons move as much as they can while everyone else stays where they are. This lead to a big shift from "the aliens and I have kinda equal chances to find someone on their respective turn" to "It is now much more likely that I find something from them but they will at most find my people who are running around but not bigger parts of my group".

I thought about whether actually "knowing" about smoke would help the AI in any way. But I couldn't really come up with a scenario where that would be the case. At least not one that could also be exploited. e.g.: "Blindly firing at random locations in the smoke" as a "counter" would immediately stop being useful and become easily exploitable by "throw smoke to deplete their TU's and ammunition".

And as I said: For knowing that you can't see, it doesn't matter why you can't see.
Title: Re: Looking for some advanced strategies and their counters
Post by: Yankes on November 16, 2022, 01:24:38 pm

I thought about whether actually "knowing" about smoke would help the AI in any way. But I couldn't really come up with a scenario where that would be the case. At least not one that could also be exploited. e.g.: "Blindly firing at random locations in the smoke" as a "counter" would immediately stop being useful and become easily exploitable by "throw smoke to deplete their TU's and ammunition".
Some aliens should do this as its would be fun mechanic, but you need provoke it first by shooting at alien from that smoke or something like that and given alien have low intelligence stat.
Title: Re: Looking for some advanced strategies and their counters
Post by: Leflair on November 16, 2022, 02:38:41 pm
Speaking of AI units that can see through smoke, like with heatVision (%), I assume all the sniper-positioned aliens could use that unit as their spotter? Guess its similar to having a flying unit that see through most smoke relaying positions.

- One common player strat is to put primed smoke grenades on their units, so if one is killed the smoke grenade drops and pops´ but the AI should reasonably well know the location of the spotted soldiers (guess this falls under spotter-AI).

Dealing with "Hard Cover:" Similar to AI options for their own motion-detector, some AI units have things like psi-vision, but there´s also scenarios where a player can reasonably guess an alien is behind a "soft" wall (wooden planks for example) or inside a building and take (auto) shots to get through the wall and hit the enemy - but this falls under your "no blindfire" rule for the AI? It´s also a scenario where the player is using a lot of these LOS obstacles to step-out-and-shoot and be pretty impervious to the AI (thinking base defenses and "exploiting" the mutual-surprise rule in favor of the player).

- some weapons that can just vaporize walls and keep on going. Either to hit or create an alternative opening in a wall to get at the enemy. But again, blindfire/niche use cases for the AI. But for example, if all approaches are blocked by proxy-grenades.

Speaking of proxy-strats - if the AI has a unit with very good armor vs the proxy-grenade (be it damage type like HE, or just armor thickness) using your out-of-order unit movement to send that unit in first to trigger and soak all the proxy grenades for its buddies?
This could also be an AI strategy if they have a tought armored unit and a bunch of squishies, to send in the tough one to trigger reaction fire and then send in the squishies (especially if they are melee units).

- Been brought up in the thread, but defensive-vs-aggressive AI posturing, depending on mission (aggressive for attacking player bases, maybe more defensive/reaction focused for defending big crashed UFOs/bases)?
One issue with any fixed AI is that it will always behave the same, so once the player figures out its weak-points and behavior they can deal with it every time. I´m guessing you´re familiar with games that use various AI-profiles to sorta getta round this (could be tied to race or mission type).
Guess this could also cover things like certain aliens being flagged to use a specific counter-profile vs smoke (spray and pray vs sacrifice lemming to spot etc).

Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 16, 2022, 07:55:10 pm
Some aliens should do this as its would be fun mechanic, but you need provoke it first by shooting at alien from that smoke or something like that and given alien have low intelligence stat.
Well, theoretically, the following could be done:
When you see shots coming from inside the smoke, you can track them and count how many it were, make an assumption about the TUs they cost and how far the shooting unit could have moved at most after firing.
You could then fire at either the location the shot came from or a random location within the movement-radius according to the leftover TUs. And if you always auto-fire, chances aren't too bad you'd hit something.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 16, 2022, 09:33:39 pm
- Been brought up in the thread, but defensive-vs-aggressive AI posturing, depending on mission (aggressive for attacking player bases, maybe more defensive/reaction focused for defending big crashed UFOs/bases)?
Instead of making it depend on the mission I was looking for more generalizeable ways to figure out when to do what.
I think I've come up with something quite decent. Staying defensive throughout an entire mission would be pretty bad, especially against someone who uses a lot of smoke. I must say that feature is a bit cursed. In the sense of: Now that I know how good it is, I can't keep myself from using it all the time. But I actually had more fun when I didn't know how to properly utilize it.

One issue with any fixed AI is that it will always behave the same, so once the player figures out its weak-points and behavior they can deal with it every time. I´m guessing you´re familiar with games that use various AI-profiles to sorta getta round this (could be tied to race or mission type).
Guess this could also cover things like certain aliens being flagged to use a specific counter-profile vs smoke (spray and pray vs sacrifice lemming to spot etc).
This depends very much on the mindset. In chess, for example, the best move is also kinda predictable. The catch is, that every move that isn't the best one is just worse and it's unpredictability doesn't make it any better. So I'm pretty much a fan of deterministic behavior. The randomness of the map-generation is where the variety should come from.
I'm all fine with different behaviors. But I then also need an algorithm to tell when which behavior is favorable.

A way to make a convincing spray&pray behavior that neither looks stupid nor like it's cheating while also being overall beneficial for the aliens is something that has become an increasingly attractive idea.
Title: Re: Looking for some advanced strategies and their counters
Post by: psavola on November 16, 2022, 09:53:44 pm
I think I've come up with something quite decent. Staying defensive throughout an entire mission would be pretty bad, especially against someone who uses a lot of smoke. I must say that feature is a bit cursed. In the sense of: Now that I know how good it is, I can't keep myself from using it all the time. But I actually had more fun when I didn't know how to properly utilize it.

With vanilla behavior, smoke is indeed extremely useful if you want to avoid casualties. To the point that some avoid using it as an additional challenge or by not bothering with it. But mod authors may also force players to manage without it or use less of it, with features (such as heatvision) which decrease the effectiveness of smoke (even eliminate it completely). This can be nicely tuned based on aliens, armor types, etc.

Thus, as was already stated, I don't think the AI should have any hard and fast optimizations wrt. smoke (and if I understood correctly, your AI does not have them). I think it should be perfectly acceptable that in the vanilla game (even with better AI), humans can get an edge by using smoke, motion scanners, and several other techniques that the aliens do not have in the vanilla game. I doubt you can really design a generalized AI to deal with all of them to the max (while not breaking its applicability in mods). If you want more challenge, you can always play a modded version where the game mechanics have been balanced differently.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 16, 2022, 10:35:44 pm
I think it should be perfectly acceptable that in the vanilla game (even with better AI), humans can get an edge by using smoke, motion scanners, and several other techniques that the aliens do not have in the vanilla game.
I guess that maybe this is the answer afterall. I didn't have 0 losses with smoke against my AI either. Just a lot less than without them. That's what they are there for. If the smoke was everywhere, the aliens wouldn't even be at a disadvantage. It's the fact that I can conceal my units and thus can create a zone that is more dangerous for them than it is for me.
Maybe I've been trying to find a solution to a puzzle that there simply is no solution for.
I've been trying to find an answer for:
"How do 8 Sectoids with plasma-pistols beat 14 Humans with plasma-pistols, smoke-grenades and actual grenades?"
They don't. Because they are outnumbered and outgunned.

I mean we're talking about the most basic alien in crash-landings of small UFOs. Against aliens that can fly, the smoke would be mostly useless. If they were more numerous or more resilient one of them might break past my own spotter and reveal my "core".

I made a small change that should increase their chance of flanking. But depending on the map there's no way to guarantee that'll be successful. I mean if I put myself into their position and think I would have to deal with an enemy that simply has better ods in the first place, I can't find a reliable solution either.

So I guess I'll just leave it like it is in that regard.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 17, 2022, 02:21:12 am
I actually did end up implementing blindFire.

I think I found a way in which it is neither useless nor feels like the AI is cheating.

The BattleUnit-class got a new member: _tileLastSpotted

So far only when a unit was last seen was stored. Now it is stored where.

This is set in the same instances where it's also set when it happened. So when a unit gets seen, when a unit hits someone with an attack and when a unit kills someone with an attack.

Now after the AI tries to do it's regular attacks of visible units, it will do the blindFire()-method. The key here is that after one attack against such location has been chosen, it is reset. Basically the _tileLastSpotted is set to 0 again. This way they will not waste too much against these tiles.

So the counter-play is to make sure to move your units that have attacked something and ideally also anyone near them and of course in a direction of 90° from where the aliens will be shooting from. Scatter-shots might still hit something.
Title: Re: Looking for some advanced strategies and their counters
Post by: psavola on November 17, 2022, 06:28:00 am
"How do 8 Sectoids with plasma-pistols beat 14 Humans with plasma-pistols, smoke-grenades and actual grenades?"
They don't. Because they are outnumbered and outgunned.

I mean we're talking about the most basic alien in crash-landings of small UFOs. Against aliens that can fly, the smoke would be mostly useless. If they were more numerous or more resilient one of them might break past my own spotter and reveal my "core".
...

This sounds very good. Let's consider two scenarios when going after an early-game small UFO. If it's sectoids, you can use smoke (but if you don't, you'll have to be very careful). If it's floaters, your ability to depend on smoke might be much reduced (unless you use 3D smoke option) and you might face heavy losses unless you're careful. This uncertainty forces the player to be on edge. Now, when going for medium+ ufos, sectoids are using PSI. And with your AI, being mind-controlled is so deadly (also for the nearby comrades) and without workarounds, that the only way to deal with it is to abort the mission until you've screened out your weak-minded soldiers. This shifts the game a lot and likely also affects mod design choices. So in general, sectoids are much more dangerous than in vanilla in any case (and you could think of small ufo sectoids only as a special case of an "easy enemy").
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 17, 2022, 10:59:06 am
My testing yesterday has shown that the difficulty against my AI increases kinda exponentially with the number of aliens on the map.

And in order to progress you eventually have to go for bigger UFOs and/or alien bases. So I guess that even the (otherwise)vanilla-run will eventually become a lot more challenging.

I mean 2 out of 3 of these ended more or less in an alien-retaliation against my main-base. Those have a lot more aliens.

There's something about the blind-fire which I don't like: When they shoot a vacant tile, the shot will always target the ground. This vastly reduces the chance of hitting anyone behind. I think it's handled in the same way for the player. It's a bit weird, that the soldier aims differently depending on whether there is someone on the tile or not despite not knowing it. Aiming for the ground is great with stun-launchers. But not with a plasma-rifle.

I also looked into stuff like: When they do the blind-firing, they might as well ignore obstacles and try to destroy potential cover. But that didn't work. If they don't get a line of sight, they don't get to take a shot. The place where that is handled is directly in the method that spawns the projectile. The only way to override it is: "Be the player, have the option enabled hand have the ctrl-key-pressed." I would have expected that kind of API on a higher-level. I'll have to modify that function to allow the AI to do that too.

Another interesting observation was that playing my test-missions on max-alien-tech-level (to increase the chance of grenades) usually made it easier, not harder. Against unarmored targets plasma-pistols with their super-cheap auto-shot are not really a disadvantage to heavy-plasma. The higher tech-level usually has several of them spawn with stun-bomb-launchers. Their high TU-cost means there's usually no more than 1 shot of these per turn. And if they take someone out with it, it doesn't cause morale-loss to the others as the person isn't dead.
Title: Re: Looking for some advanced strategies and their counters
Post by: Juku121 on November 17, 2022, 11:58:46 am
Efficiency-wise, have you tried your AI on something like an 80x80 map with 60+ enemies? Not so much from an AI POV, but whether the turn times remain reasonable.

Yes, right now the small-blaster is still used like a direct-fire-weapon, which is not ideal but also not overly problematic. But I can totally see that in Mods where the enemies get stuff like rocket-launchers, you'd want to treat all that differently too. Shouldn't be that hard to adapt. I've seen the property of explosion-radius can be derived from the ammunition as that is already done with the blaster-launcher.
I didn't really mean direct-fire explosives, althought that's a consideration as well. What I was trying to get at is that a number of mods have whole families of arcing grenade launchers/mortars, which work pretty close to grenades, and are much more appropriate for 'blind-fire' or just random suppressive fire.

About the motion-scanners:
...
The player being able to make visual contact much harder to achieve for the aliens and even having ways of not having to make it themselves to shoot them, really is something I'm not sure how to deal with.
As has already been brought up, aliens can have psi-vision that kinda emulates motion scanner functionality. It's actually better, since scanners leave the Z-coordinate open, which is a major disadvantage on multi-level maps (manors, looking at you >:( ).

...an alien-retaliation against my main-base.
Aren't bases considerably different for smoke usage, since an enemy (or three) can be right around a corner so no smoke will help you there? Potentially making smokes a sub-par tactic.

And if they take someone out with it, it doesn't cause morale-loss to the others as the person isn't dead.
'stunningImprovesMorale: true'?
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 17, 2022, 12:47:08 pm
Efficiency-wise, have you tried your AI on something like an 80x80 map with 60+ enemies? Not so much from an AI POV, but whether the turn times remain reasonable.
Not yet. I will eventually do this. Since the first (and so far only) feedback I've gotten on one of the already released versions was that it's way too slow.
So I've already done a rather drastic step and reduced the calls for line-of-fire-checks from roughly Tiles*n/2*(n/2)² to Tiles*n/2*n, with n being the amount of units on the map. Before that I could tell whether the aliens had fliers or not based on the turn times. After that it became unnoticeable at least with vanilla map-dimensions. I hope this problem is now solved and that a little larger maps and a little more enemies should scale in a more linear fashion, which hopefully makes this a non-issue. But I know I'll have to stay wary of that.

Whether the shot is arcing or not is irrelevant for the explosiveEfficacy-function. I have to make sure that indirect fire and blind-fire take everything into account that explodes. There's code that is similar enough to what I'll need, so it's just a point that eventually needs to get done.

Psi-vision will be very nice for the Aliens using my AI, no question about that. :)

Yes, the more hard-cover there is the less difference smoke-grenades shall make. The way I exploited it worked actually better when there was less real cover, so I could always keep a lot of dudes with line-of-fire to everywhere to then kill what my spotter saw. As soon as the spotter has to break los with his friends, the advantage is gone. And keeping people stacked in a mission where the aliens bring blasters is pretty insane anyways. So I probably won't see many opportunities for smoke to make sense at all. Maybe in a floor leading to a hangar.

'stunningImprovesMorale: true'?
I suppose that's some non-vanilla option that also works both ways in the sense of "gettingStunnedReducesMorale: true". It just was an observation. Not necessarily meaning that something should be done about it. In order to have hopes of ever getting a few soldiers to significantly improved stats high-end-armor is kinda mandatory. And at that point the difference between plasma-pistols and heavy-plasma will be very significant. I don't know whether armor protects against stun. If not, stun-launchers also are much more useful relatively spoken.
I think it's kinda realistic that getting stunned doesn't affect the other's morale.
Title: Re: Looking for some advanced strategies and their counters
Post by: Rangerh on November 17, 2022, 11:52:56 pm
Wouldn't be much use in default UFO and TFTD as the aliens have 20 tiles of vision at night, but for other mods with a wider variety of enemies , some being human-like and so affected by human-like night vision (9 tiles) , how about some more aggressive use of flares at night battles like the human players do.

This could help at night the not-view enhanced AI troops to spot your own hiding in the dark.
Something i always liked in Jagged Alliance 2, starting to see enemies throwing break lights around to spot your troops better (though sadly often a cheat as those break light were landing right on your soldiers).
Now the difficulty i imagine would be to make the AI flare usage more believable and landing sometime none is hiding (assuming the AI have yet no idea where your squaddies are), not automatically landing where your troops are hiding.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 18, 2022, 11:17:12 am
Wouldn't be much use in default UFO and TFTD as the aliens have 20 tiles of vision at night, but for other mods with a wider variety of enemies , some being human-like and so affected by human-like night vision (9 tiles) , how about some more aggressive use of flares at night battles like the human players do.

This could help at night the not-view enhanced AI troops to spot your own hiding in the dark.
Something i always liked in Jagged Alliance 2, starting to see enemies throwing break lights around to spot your troops better (though sadly often a cheat as those break light were landing right on your soldiers).
Now the difficulty i imagine would be to make the AI flare usage more believable and landing sometime none is hiding (assuming the AI have yet no idea where your squaddies are), not automatically landing where your troops are hiding.
Using flares for AI-units that have impaired night-vision and happen to carry flares sounds like something very specific. Making it believable doesn't sound hard at all. I'd just make them use the same "algorithm" that I use: Throw it at places that they have good line of fire to but that are roughly twice the vision-range away from their each of their soldiers and already thrown flares. This would be completely decoupled of the consideration of enemy-locations. Priority-wise I'd put it between attacking and moving. The API for that is a bit lackluster but I'd just use the same tricks that are being used for the grenades. That means subtracting the 4 TUs it costs to take them from the belt within the AI-code itself.

I only just started exploring the world of Mods yesterday. I fixed an endless-loop caused by turrets not being able to move. But so far nothing else that is based on particular Mod-content.

The exact thing happened that I've been warned about:
The mods scale their difficulty with higher amount of enemies and all sorts of restrictions to what you can do.
Activating Brutal-AI in XCF, for example, meant I got killed/had to abort every single mission after 2-3 turns so far.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 23, 2022, 11:22:39 am
I'm getting a little frustrated here. The past two days I've basically made no progress.

Ever since I figured out the "trick" to use all those doors in a base-defense-mission to hide on the alien's turn and come out on mine, I couldn't come up with an effective counter for the aliens. At least not without breaking their approach for normal maps.

The issue is that they think a position is save because their enemy has no line of fire. But that's on their turn. One of my guys near them opens a door and sees them. Other guys further up the long corridor come out to shoot with no retaliation-fire possible.

I tried hiding 2 corners away. But that made them too passive, susceptible for AoE and opened them up for flanking. I tried making them brute-force it. Once again this increased AoE susceptibility but actually made them stronger on base-defense-maps as they start relatively spread out. But it's not suitable for normal maps.

The most complicated to program behavior was to make them peek out and hide again on their turn. It does not really counter me doing the same and is essentially dealt with in the exact same way then the 2-corners-away-hiding except they have a little fewer TUs on my turn. I can imagine this to be quite good on normal maps though... if there was no smoke that is. Smoke ruins basically all the advanced tactical approaches and the only semi-decent counter seems to be rushing it.

However, one problem with my tests was that I played the same savegame over and over, so I had a lot of knowledge about what to expect. So it's actually hard to compare to my first encounter there which I lost before discovering the hiding-trick.

One thing I haven't tried yet was blind-fire with blasters. I learned (from reading the code) that putting the last way-point twice makes the missile go down to the floor of the targeted tile. So that would prevent uncrontrollable behavior if there is no target at the blind-fire-position.

I would, however, prefer something safer and related to movement.
Title: Re: Looking for some advanced strategies and their counters
Post by: Juku121 on November 23, 2022, 08:52:16 pm
What do you mean by "two corners away"? Something like this?

    |    |        |
    |    |        |* - lurking
----    --------     Alien
                 corner 2
     corner 1
----    --------
    |    |        |
    |    / * X-Commie
    |    |    behind
    |    |    door
----    ----

 more X-Com
 down here

Well, if the aliens did that to me, I'd do the following:
I suppose vanilla's lack of alien explosives might be a bit troublesome, but Blaster Launchers are exactly the thing for such a situation.

That's also kind of how RL CQC looks like: lots of grenades, calling heavy fire onto enemy positions whevener possible, assaulting with as much surprise and overwhelming force one can muster. And lots of casualties.
Title: Re: Looking for some advanced strategies and their counters
Post by: Xilmi on November 24, 2022, 12:27:03 am
Yeah, of all the experiments I did to improve the situation the only one that made it in is using blasters.

But I think my mindset was more broken than the AI.

It was like: "I must make the aliens win this mission!"

But now when I actually played a normal game again and not just premade-missions or saves I had played several times before, I realized that when there's actually more at stake than a standalone mission, having the AI have too good chances to win all the time isn't that helpful afterall. :D