Jump to content

R&D Tactical bug hunts (suppression and alien skipping turn)


johnnylump

Recommended Posts

@ Amineri -- Your assessment of the problem and proposed solution looks good. I'm just happy if they try something -- a low-percentage shot, running for it -- when heavily overwatched and possibly flanked. All praise Amineri!

 

@ AnUser -- There is some teamwork, I think. The aliens call for their friends, for one. And I poked around in the suppression code and it looks like they'll collectively target someone with suppression and then other attacks. Although admittedly this stuff is challenging to parse.

Link to comment
Share on other sites

  • Replies 89
  • Created
  • Last Reply

Top Posters In This Topic

Amazing discoveries, Amineri!!

 

As I suspected it seems the AI makes little use of team strategy, all this actions seem based on individual conditions. Anyway just fixing the skipt turn would be great, although it seems here we have the possibility to improve combat AI a bit. I won't comment that because I still haven't got a clear idea of how it works, I'll just say that I'd love if aliens could try to seek for cover when flanked, and that better overwatch than shooting as default action (provided the shot % had been considered low enough).

 

I'm sorry if I mislead you about this. I was trying to present a somewhat simplified scenario (because I know it was getting away from me). The AI does take into account teamwork, and probably roughly to the same level as a player.

 

It considers what each unit's possible moves are, and evalutes them in the context of the surrounding units.

1) Individual units get bonuses to move to positions that are near allies (but not too near), and even stronger bonuses to move toward members of their own pods

2) Individual units can be assigned targets, so that all the members of a pod can be directed to focus on a single target. This target gets a higher priority than other targets (but it won't cause the unit to prefer an assigned target in cover over a flanked target, for example).

 

 

If the DangerZone level == 1, then a BONUS to movement of +400 is applied. However, if the DangerZone level > 1, then a PENALTY is applied to movement. The penalty is -250 for level 2, and -500 for level 3. This -500 overwhelms nearly any other factor in determining whether a spot is "good" to move to.

(...)

Altering this penalty could allow units to make moves even when overwatched, if the unit is flanked, but the flanking unit(s) are not overwatching.

Could it be possible swapping this values to make that if many xcom units are in overwatch the first alien taking action (and in range of xcom units) would move to trigger all reaction fire? I do that, but I'm smart and I use an assault soldier with lightning reflexes and using run and gun, but only the alien were to perform a dashing move (if very overwatched) that could turn into a major team tactic, and since each alien seems to compute their own actions, only the first alien overwatched by 2 units or more and with no good shot chance would take the initiative to unleash xcom reaction fire on him, so following aliens in that turn would no longer be 'overwatched', would they?

Well, I feel as the main thing is to keep the alien units from being TOO predictable. From a game theoretic perspective, if you can predict your opponent's moves, that is often a significant advantage.

 

There are many possible situations under overwatch. Perhaps the overwatching soldier can be flanked and killed by another alien. Perhaps one alien can grenade and destroy cover, allowing a 2nd alien to kill the soldier. Moving is not always the best option. I'm not sure if there is a "wait for now and let other aliens move first" option. If there isn't, it might be possible to mod in such an option.

 

P.S. A SHIV can make a better overwatch target than an Assault soldier. With its built-in 20 defense, a dashing SHIV applies an impressive -60 aim penalty to overwatch-firing aliens. Particularly if there are many aliens, this can be a better solution since Lightning reflexes only applies to the first shot, regardless of whether it would have hit or not.

 

btw, aliens only take 2 moves per turn one by one right?, I mean, they don't take dash moves at all or do they?

There is no Dash state. Aliens considering moving, or taking an action. Interestingly, with the developer console on, if you give your soldier UnlimitedMoves (allows an unlimited number of actions on your turn), then your soldiers can no longer dash either.

 

another random thought.. do aliens consider enemy having the "Covering Fire" perk when pondering shooting them? I guess they don't but just to know

 

Trying to take into account all of the possible permutations of soldier perks would make the AI's search space about 1000x bigger. I saw no indication that any reasoning was soldier-perk-specific.

 

They do take into account perks/abilities that THEY have. Sectoid behavior is quite different if they are the generator or reciever of a mindmeld. If the generator, they get the "should hide" modifier applied. If the receiver, they are much bolder and likely to attack (they get a x2 modifier to offense portion of shot priority in that case).

 

 

One other reason that this bug would crop up less in classic/impossible.

 

The offense priority for standard shots also gets a boost of +7 for each point of hp the target has below 5 (a hard-coded value of 5).

 

In vanilla impossible, starting soldiers have 3 HP, I believe, which would provide sectoids a +14 bonus to offense priority. With a 35% aim chance, 35*2 + 14 = 84, against an uninjured XCOM soldier. In Long War, soldiers have 3 base HP and +2 from Kevlar, making the HP 5, and providing zero bonus OFFENSE priority.

 

I think the AI could be made a little smarter if it used a value based upon the current weapon damage. This would allow the AI in later stages of the game to take into account chances to "one shot" a soldier with a powerful weapon such as a Heavy Plasma.

 

Currently, the AI would place no higher priority on a 7 HP soldier than a 20 HP soldier when armed with a weapon that dealt 9 damage.

All shall hunt the weak! Brutal... Well, again, I do take more risk if there's the chance to kill an alien, so it's good if they do it as well :smile:

 

It's not just about the shot odds, but also the payoff. An easy of example of this is lotteries. Even if the odds are VERY low, if the payoff is high enough it can be worthwhile to play. In this case, killing a unit can pay off as a defensive action (one less unit to shoot at you).

 

The aliens do this effectively at lower levels, because of the hard-coded 5 value. However, at higher levels, not taking into account the increased weapon damage makes the AI choose less-optimal decisions. This is another (small) way that the game becomes easier in the later game.

Link to comment
Share on other sites

Please tell me that i'm not the only one to feel really stupid, like a caveman, after an Amineri post.

 

Edit: In my opinion being flanked should give the alien like +200 incentive to move to get the f out of there if it isn't already flanking enemy.

 

I apologize for that. In many ways a text forum isn't the ideal way to convey information about AI programming :) Lots of diagrams are very helpful here!

 

-------------------------------

 

It's hard to categorize what the alien behavior should be in all situations. For example, forcing the alien to move the unit if it is flanked could lead to exploitable behavior, if it doesn't take into account other factors. Perhaps there is another alien unit that can move to flank the xcom soldier. Perhaps the XCOM soldier is in low cover and only has 1 HP left.

 

The AI behavior is already pretty good -- don't want to break other things while trying to fix one glitch.

 

My proposal here is to always allow both firing and overwatching, at MINIMUM allowed priority. That way if there is no better option, it will be 50/50 whether the alien will shoot or overwatch as last resort.

 

We also don't really want the AI to act TOO much like a human player. A human player would simply give up and quit if he had a single sectoid left, facing 4 XCOM soldiers, was flanked, and had two units overwatching. I mean -- the human players have the "run for the dropship and evac" option in most situations, but the AI doesn't get that choice.

 

As a side note, that one was one thing I really like about X-COM:Apocalypse -- the aliens could flee the map. Doing so would move them to an adjacent building, where they could join an existing infestation or try and start a new one. Enough aliens escaping and you'd have to perform a raid on the adjoining building -- another bughunt :)

 

That said, I'll try going forward to document the various constants that shape the alien behaviors, so people can play with them to see what effect they have.

 

----------------------------------------------------------------------------------------

 

One final note regarding "running for the dropship". There appears to be code in the XGBehavior_Civilians that allows for civilians to flee for the XCOM dropship instead of just standing around. However, it is triggered only in a condition that doesn't happen -- effectively it is turned off. Also, civilians will only enter the "flee" state if an alien moves to within 4 tiles. FOUR TILES!

 

I'm thinking about unlocking the running for dropship, and letting people expand the 4 tile parameter so that civilians are more likely to flee and less likely to just stand around waiting to be killed. This would probably require some rebalancing as to Terror Mission performance critieria, as it makes civilians more survivable.

Link to comment
Share on other sites

In thinking about your original proposal to give shot and overwatch an always-on, 50-50 priority ... would that be in effect if the alien was flanked? Because at that point, overwatch is a pretty bad choice. If that's the case, perhaps making "shoot" as the sole, always-on option of last resort, would be the best case ... so the only thing to do would be:

 

 

1) Clamp the ShotStandard priority to be no less than 1. This leaves the basic shot as always being an option (assuming the unit can shoot)
(Of course, I may be misunderstanding and clamping the overwatch priority at 1 still wouldn't result in a flanked unit that hits this bug going overwatch)
Link to comment
Share on other sites

You are correct that clamping both ShotStandard and Overwatch actions to be no less than priority 1 would result in a 50/50 chance to perform either in the worst-case scenario.

 

The way the game is coded now, if it weren't for the rounding-off error in the overwatch code (I'm still assuming that is the root cause), a lone, overwatched, flanked sectoid with no good shots would ALWAYS enter overwatch, since that would be the only option remaining.

 

If the unit is flanked and overwatched, then moving is typically a pretty bad move. How bad really depends on how many units are overwatching -- because classic/impossible difficulty extends the short-range boundary, the AI always thinks that it has 3 enemies overwatching the unit (if at least 1 is with 90% of sight-range), so it "believes" that moving is a VERY bad option. In a sense the game "lies" to the AI about how bad the overwatch situation is on the higher difficulties in order to make it play more defensively.

 

Overwatching also isn't that great, since the unit is already flanked, the enemy doesn't have to move in order to get the flanking shots. (this assumes that the AI is still trying to "win" the tactical mission, which isn't very likely at this point anyhow)

 

Probably the best tactical option is to shoot at one of the flanking units, hoping to get a lucky shot and remove some of the source of "being flanked." There is some code buried deep down allowing for some prioritization of enemy units flanking the AI's, but with the -100 defense penalty to ShotStandard's priority, without a really good shot any such more subtle prioritization is lost.

 

However, there are two approaches here: the AI choosing the "optimal" solution, or the AI choosing a "believable" solution. With a lone flanked, overwatched sectoid, it's not hard to imagine some sort of panic and arbitrary decision making.

 

I figured that clamping both overwatch and firing to priority 1 would be a reasonably robust change (hopefully shouldn't impact other AI decisions very much).

 

Altering the -100 ShotStandard defense penalty would make ANY unit more likely to shoot when flanked, which isn't a great choice -- you really want the AI to try and pick some other option if it can.

 

Finally, I think that the alien always shooting as a last resort could still be exploited. The sectoid is in a sense wasting its action on a low probability shot. By overwatching it is trying to prevent enemies from approaching and capturing it, which encourages the XCOM player to kill it instead of capturing it (which is likely what the alien overmind would really want).

 

Which action is optimal really depends upon what the goal is.

1) From a purely tactical perspective shooting is preferable (offers better odds of "winning", even if they are extremely low)

2) From a strategic perspective, overwatching (to try to force the player to kill instead of capture) is better, as it denies the player a captive and any captured weapons.

Link to comment
Share on other sites

Excellent point about captures. I think my preference would still be for the alien to still take the shot, as live and equipment captures can have a decreasing utility over time, but a wounded or dead X-Com soldier always helps the aliens. But in truth I'll take anything that closes off this exploit!

Link to comment
Share on other sites

I went ahead and implemented Amineri's suggestion. Turns out there was only space for a single conditional check, so I followed my heart and left it shooting. The game loads up with these changes, and battles run, but I have not tested them enough yet to see if the alien freeze is eliminated.

 

Here's the code:

function int AI_GetScore(XGAbility kAbility, out string strAbilities)
{
    local float fOS, fDS, fIS;
    local int iOS, Ids, iIS;

    // End:0x11
    if(kAbility == none)
    {
        return 0;
    }
    fOS = AI_OffenseScore(kAbility);
    fDS = AI_DefenseScore(kAbility);
    fIS = AI_IntangiblesScore(kAbility, fOS, fDS);
    iOS = int(float(100) * fOS);
    Ids = int(float(100) * fDS);
    iIS = int(float(100) * fIS);
    // End:0x12F
    if(kAbility.iType == 8)
    {
        return Max(int(float((iOS + Ids) + iIS) * (AI_GetScoreModifier(kAbility))), 1);
    }
    // End:0x168
    else
    {
        return int(float((iOS + Ids) + iIS) * (AI_GetScoreModifier(kAbility)));
    }
    //return ReturnValue;    
}

 

 

And here are the hex changes:

 

XcomGame
3a 01 00 00 cc 28 00 00 6b 01 00 00 07 01 00 00
to
3a 01 00 00 cc 28 00 00 73 01 00 00 07 01 00 00

AND

0f 48 dd 88 00 00 70 a8 70 a8 70 a8 1b b5 02 00 00 00 00 
00 00 00 de 88 00 00 16 1f 4f 66 66 3d 00 16 38 53 00 d8 
88 00 00 16 1f 44 65 66 3d 00 16 38 53 00 d7 88 00 00 16 
1f 49 6e 74 3d 00 16 38 53 00 d6 88 00 00 16

to

07 2f 01 9a 19 00 38 89 00 00 09 00 e2 7b 00 00 00 01 e2 
7b 00 00 2c 08 16 04 fa 38 44 ab 38 3f 92 92 00 d8 88 00 
00 00 d7 88 00 00 16 00 d6 88 00 00 16 1b b7 02 00 00 00 
00 00 00 00 de 88 00 00 16 16 26 16 06 68 01

 

(It was an exact fit -- not a single 0b needed) Please give it a try and report if the issue is fixed!

Link to comment
Share on other sites

urg ... still getting alien freezing..

Had three rookies, all in high cover, all viewing sectoid in high cover. One sprinted to flank sectoid. Repeated overwatches met with inaction (not overwatch) by sectoid. There was better cover in range for the sectoid, but it would risk several overwatch shots to run for it. It stayed frozen. I moved the flanking soldier out of cover (but still flanking sectoid), and the sectoid shot him. This suggests a low to-hit roll is still preventing aliens from taking the shot.

 

... Looking through the code, it appears that the iType for a basic shot may be 7, not 8, so I changed it, but I'm still seeing flanked aliens skip their turn.

Edited by johnnylump
Link to comment
Share on other sites

Don't think I can, unless you see a way to optimize the code: It's a 26, not 2c 01, and not a byte to spare. I'm going to try overwatch (33) and see if it's something specific to firing. After that, move (01) -- in which case I can play with the score.

 

... no dice on overwatch, either.

 

Tried move as ability of interest, with a minimum value of 10. Seemed like some flanked sectoids were getting creative -- shooting more often than moving, actually -- but in a fully controlled situation ... 4 soldiers in low or high cover, one flanking, the lone alien froze, even when all four soldiers hunkered down, or I skipped my turn entirely for all of them. So no verdict that this is working at all. Perhaps something with all the "filter" functions is at issue?

Edited by johnnylump
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...