Jump to content

AI Bugs, Improvements & Suggestions


Recommended Posts

So, in this thread I would like to have a discussion with you on how we can change certain aspects of the AI behavior you found strange, faulty, or would like to suggest alternative behavior for.

The primary reason for this thread is to present the bug reports / suggestions in such a way that I can easily replicate the situation from my end. In my experience, when dealing with bugs for the AI most time (if not all) was spent in trying to replicate the scenario locally. So the speed of bug fixing / tweaking of behavior will increase tremendously if you can help me in this!

I will give preference to those that post saves, and are using the latest version!

I therefore would like to suggest the following style:

Save & (optional) Screenshot

Link to a save and a screenshot which shows me what situation I'm dealing with (if applicable).

You can post the save to the forum, and the screenshot to imgur.com

(See example)

Tech. Info

Which version of Xenonauts are you using and which mods. (essentially everything I need to replicate it on my end)

Observed Behavior

Explain what behavior the AI shows, what it is doing wrong according to you. (or shouldn't be doing)

Desired Behavior (Optional)

Explain what behavior you think the AI should show.

An example, based on Ol' Stinkys post:

hTZCVUl.png

Save & Screenshot

Save Link

Tech Info

Xenonauts v20 Balance Patch 2, Stinky's Map Pack 2

Observed

Units try to enter the center, going through enemy fire. I think they are trying to get to the civilians inside on which they should have no knowledge.

Desired

The aliens should confront the Xenonaut units in front of the building and/or retreat to safety.

Link to comment
Share on other sites

Save and Screenshot: http://ge.tt/1vcMWcD1/v/0 , http://picpaste.com/bug60-AJZs8v8p.jpg

Tech Info: V20 Hotfix 08/01/2014 (the mission was started with V20 Stable 24/12/2014 though, in case that matters)

Observed:

The Sebillian is hiding behind a wall, but does not actually really do anything besides moving a bit. Clara Cristensen can fire at him quite safely. Just keep ending your turns to see it. Interestingly enough, the alien does not fire on its own, but will reaction fire sometimes. And while apparently it's next to impossible for a single soldier with an assault rifle to actually kills this alien because of regeneration, more firepower should do the job (e.g. having another soldier peek through the door and fire at the alien when suppressed).

Desired:

I don't think there's one proper way for the alien to behave, but surely it should do at least something instead of getting shot at patiently. I would say that it should at least shoot back. It can occassionally hit with reaction fire, so its chance to hit shouldn't be that tiny, and even if it doesn't hit, it could at least suppress or destroy the soldier's cover. Either MinimumAccuracy is way too high, or the way it works is not a good concept and the AI should decide to fire if it sees a soldier and doesn't come up with anything better to do.

NOTE: I actually have a similar save ( http://ge.tt/303UzcD1/v/0 ) where the alien is a Caesan, so it's easier to kill, and this one simply repeats the sit-and-crouch dance until it gets worn down by shots from the two soldiers.

Edited by llunak
Link to comment
Share on other sites

Okay, this is not a suggestion for a specific situation, but rather to change the general decision-making approach of the AI. Here's what currently happens, I believe:

Aliens perform their turn sequentially. The game iterates through aliens on the map in some order. Each alien chooses an action, such as moving somewhere or shooting, performs it, and then chooses action again if TU is available. Some things interrupt the process, like noticing an enemy while moving, and then the AI may choose to for instance fire from the current spot.

The core weakness there is that aliens still act individually. Alien N will only start doing stuff when alien N-1 is done.

It would be stronger by following a different approach. Generate a preferred action for each alien. Then begin with the alien that has the highest-scoring action, probably shooting at the enemy. At each interruption, regenerate preferred actions and allow another alien to potentially take over. It's sometimes much more effective, say, for alien 1 to take an action, then alien 2 to take some actions, then for alien 1 to take more actions.

Example:

Alien 1 is not in cover but near it, and close to a bunch of enemies. Alien 2 is farther away and in cover. Now it makes sense for Alien 1 to throw a grenade. It explodes, killing one enemy but leaving another alive. At this point Alien 1 can either fire on the remaining enemy or run for cover. Neither is optimal. Running leaves the enemy alive, firing leaves the alien in too much danger if it misses. It's optimal instead for Alien 2 to safely fire on this enemy, and then for Alien 1 to make its decision.

More generally, I would propose the following steps for the AI turn.

1. Generate a dependency graph between aliens. Two aliens are dependent on one another if both have the same enemy within range OR are within a certain distance of one another.

2. Generate a preferred action for each alien, assuming here that higher heuristic score = better action. Also assuming that the heuristic takes into account the chances of doing damage to the enemy, and of remaining alive, that is probably already the case.

3. Of all aliens, pick the one with the highest-scoring action and perform it.

4. Recalculate actions for that alien and all its dependent aliens.

5. Repeat from 3.

With the correct heuristics, this should result in behaviour like what I described in the example.

But what about situations where it makes more sense to fall back? To have a good evaluation of those, I would also choose the initial strategy based on a probability tree (of sorts) of killing the enemy.

When an enemy is range of an alien, proceed as follows to determine the best strategy:

1. Evaluate which other aliens, if any, could fire on the target, either directly or by moving first. Calculate how many shots each of these aliens could fire and so obtain the maximum amount of shots that are possible to aim at that enemy.

2. Make a tree. Each node is a state with a score that is the damage done to the enemy, or the maximum score if it's a kill. Edge weights are the probability of transitioning between those two nodes as usual. Calculate the probability of reaching a leaf node with at least score K, where K could depend on AI type - "cowardly" aliens only going for high K such as kills, aggressive aliens going for lower K. If there is a patch to a K-node above a certain threshold, then attack, otherwise fall back / act defensively. Of course this tree, once calculated, could be used to select the next best action for each alien as previously in step 4.

Example of the tree, here: www.xenonauts.com/aishot.pdf

There's an enemy with 60 HP. Alien A has a weapon that is expected to do 30 damage and can hit 75% of the time, Alien B has a weapon that does 80 damage and so kills in 1 shot, but only hits 20% of the time. Edges indicate which alien shoots and specify the probability, nodes indicate total damage done to the enemy. Kill nodes are coloured blue and are supposed to have a very high value. Hit edges have green text, miss nodes have red text.

Yellow boxes by some kill nodes indicate the probability to that node, where obviously higher is better. Too lazy to make all ;) It should be obvious how the tree can be used for decision making, but here the point is just that the aliens would see there's a high probability of a kill, and therefore act offensively, not defensively on this turn.

The tree shows that there's a 56.5% chance to kill the enemy with just two shots from Alien A. But also that if the first shot misses, there's still quite a good chance of finishing the job. One cool thing is that simply applying different search approaches could give very different AI behaviour. Some AI could try for the shortest path, hoping to get a bit lucky and kill with as few shots as possible. Another AI could go for a longer path that uses more actions but almost certainly kills.

This is a quick mashup while I'm in a bit of a hurry, so please forgive inaccuracies or unclarity :)

Link to comment
Share on other sites

Save and Screenshot: http://ge.tt/7M04mcD1/v/0 , http://picpaste.com/bug31-ir37Z2IM.jpg

Tech Info: V20 Hotfix 08/01/2014 (but the save itself is from V20 Stable 24/12/2014, in case that matters)

Observed:

(This assumes the alien doesn't get shot by reaction fire, if it does, try again.) The alien will stand up, run back and behind the two boxes, but immediately in the same turn it will start running back. Next turn, it will run almost to the sniper and try to cover behind the iron pipes. Next turn, if it lives long enough, it will shoot the sniper.

Desired:

While the alien is eventually doomed one way or another, and so it cannot really do that much better, there are several things that it does noticeably poorly:

- Why does it run back behind those boxes but immediately changes mind and run almost to where it was before?

- Why does it charge the sniper only on the second turn instead of charging immediately?

- It tries to cover on the side of the iron pipes, but it actually doesn't work as a cover (since for both of them it counts as shooting over a cover), so it's quite easy for the sniper to kill it at that point at the latest.

- I originally got this with the first V20 stable release that still had the AI passivity bug, and I explicitly set MinimumAccuracy to 0.01 there, which resulted in the alien just shooting repeatedly at the sniper, which actually kept the sniper suppressed and unable to fire. So in this case maybe it'd work better for the alien to first fire and then approach the suppressed sniper (although if the sniper had a sidearm that would be somewhat risky too).

Edited by llunak
Link to comment
Share on other sites

Save and Screenshot: http://ge.tt/1vcMWcD1/v/0 , http://picpaste.com/bug60-AJZs8v8p.jpg

Tech Info: V20 Hotfix 08/01/2014 (the mission was started with V20 Stable 24/12/2014 though, in case that matters)

Observed:

The Sebillian is hiding behind a wall

Thanks; this is probably solved in the next iteration, where Trepidation is introduced. (Concept of moving away from dangerous situations)

Link to comment
Share on other sites

Save and Screenshot: http://ge.tt/7M04mcD1/v/0 , http://picpaste.com/bug31-ir37Z2IM.jpg

Tech Info: V20 Hotfix 08/01/2014 (but the save itself is from V20 Stable 24/12/2014, in case that matters)

Observed:

(This assumes the alien doesn't get shot by reaction fire, if it does, try again.)

I'll answer the questions in sequence:

- (1 & 2) I think this is a revert of an old bug; I'll look into it.

- Shooting over cover: This is an actual bug I'll look at.

- This behavior should probably be in by now (disregarding the previous two bugs)

Link to comment
Share on other sites

Okay, this is not a suggestion for a specific situation, but rather to change the general decision-making approach of the AI.

Thanks for the tips :)

Small preface:

I'm an academic AI programmer by heart and prefer search techniques over domain knowledge any day of the week!

So when I use a reactive layer, with an heavy emphasis on knowledge, it most likely isn't by choice, but due to necessity.

Also; I built a fully fledged HTN planner system the first couple of months I arrived.

To be blunt: It runs too slowly, and there's not really anything I can do about it yet.

This is due to several things, one among them the fact that there are some design decisions in both the engine and the datastructure which are too costly to fix, and ensure that I can never get near decent enough running times for the lookups I need to do to enable planning. Those decisions were made with a reactive layer approach in mind, not a planning one, and before I got on board.

I've started integrating aspects of the planners decision making into the AI as I altered / optimized different areas of the gamelogic. (or better said, abstracted and integrated them in the AI knowledge system).

At the moment, I'm creating correct emergent behavior; before I start back again on the organized team behavior.

Hope this explains things :)

Link to comment
Share on other sites

Thanks; this is probably solved in the next iteration, where Trepidation is introduced. (Concept of moving away from dangerous situations)

I'm not sure if this actually counts as being in a dangerous situation. Given that the Sebillian has regeneration and more powerful equipment, wouldn't it most likely win the shootout if it actually fired at the soldier? The situation is only dangerous to it because it poses as a shooting dummy.

Link to comment
Share on other sites

I'm not sure if this actually counts as being in a dangerous situation.

I haven't run the save yet; my assumption was that you were only popping out of cover during your own turn. The trepidation would add "danger" to locations which give no viable attack option, but do get shot at.

(Also, the next iteration includes a ShotPotential function, which will encourage aliens to move to locations which give better aim at covered/hidden previously known targets)

The not-shooting-back is definitely a bug, and probably due to the EngagementRange still set to a low value for Sebillians. This is also fixed in the next iteration.

Link to comment
Share on other sites

I hope you don't mind a question. Do you plan to implement AIs that always explore the map?

Right now, it seems that there's nothing there that'll make an AI go out and look for Xenonauts; they seem to bump into me by accident, such as chasing a civilian or looking for a suitable place to hide. Sound would be reactive, while ProbabilisticSearch's function sounds like a revamped version of the AI "guessing" where units were. If there was a variable - let's call it "Explorer" - which put a weight on fog of war tiles, it'd be possible to create a scout version of each rank who could head out into the unknown and get some idea of where the Xenonauts were. I'm thinking Explorer would be 0 for most aliens, but a scout would have it be a value that gets him out into the fog.

Link to comment
Share on other sites

Okay, this is not a suggestion for a specific situation, but rather to change the general decision-making approach of the AI. Here's what currently happens, I believe:

Aliens perform their turn sequentially. The game iterates through aliens on the map in some order. Each alien chooses an action, such as moving somewhere or shooting, performs it, and then chooses action again if TU is available. Some things interrupt the process, like noticing an enemy while moving, and then the AI may choose to for instance fire from the current spot.

The core weakness there is that aliens still act individually. Alien N will only start doing stuff when alien N-1 is done.

I think will take forever to calculate though. Your talking about chain looping though some very complex code.

I think the best method is to "devise" a plan/goal (probably the most desireable location on the map to engage from) first based on the AI overall knowledge of map and enemy unit positions then have the AI units execute it unless local conditions make that impossible or suicidal. So, calculate a "goal position" once per turn and set a weight for location that encourages AI units to move there provided they won't get killed or pass up an opportunity to easily kill an enemy. Since the AI is nearly always on the defensive it isn't really necessary for it to consider anything other than how to kill the most enemy units while saving the most possible friendlies. That mean moving to the best cover with the best fields of fire to the most enemies it knows about. Even a base assault is a sort of defensive mission as the base props can be treated as "civilians" when the AI isn't shooting at your troops.

Honestly though, let's say that it could be done in a reasonable amount of computer time, the aliens are already putting up a good fight. At the start of the game they are far superior in weapons and toughness. I'm losing 2 to 3 squad members on every mission now where before I was losing 0 - 1. Granted, I'm still in ballistics and have no armor, but if your idea was put into place and worked, I have doubts anyone would survive the first month or two of the game. Is that want we really want? I was advocating for better AI "planning" previous to the last balance changes, but now I'm not so sure that it is necessary since combat is so much more deadly now. At a minimum, I wouldn't want a better AI until after month one or two now, at least with the current balance.

Edited by StellarRat
Link to comment
Share on other sites

Thanks for the reply GJ! It's always sad to hear about code issues that prevent the application of best AI techniques, though I quite like the level of sophistication you're putting into it. As a matter of curiosity, have you considered using Monte-Carlo search for firefights? I imagine that it could be applied quite effectively to evaluate fights between 2-3 aliens and soldiers.

Stellar, I've seen game AIs do even more complex calculations. The good thing with Xeno is that the search space is not that big. The game's also turn-based, which means AI calculations that take several seconds are no problem. Personally I'd be willing to wait longer to have a smarter AI. Something I liked in GalCiv2 was that the game had an option to enable certain more CPU-intensive AI searches.

And there's never any need to worry about the AI becoming too smart to be fun. I'm fully confident of that from experience. Even with the best efforts of very capable developers, it's not going to be smarter than a human. And when the AI gets smarter, it can always be counterbalanced by changing other mechanics, say like alien accuracy. Improving the AI should always be a goal though because it leads to better fun. A game can have the same amount of difficulty, achieved by different means. Difficulty that comes from smart AI is much more fun than difficulty that comes, say, from aliens having ridiculous health.

Link to comment
Share on other sites

Stellar, I've seen game AIs do even more complex calculations. The good thing with Xeno is that the search space is not that big. The game's also turn-based, which means AI calculations that take several seconds are no problem. Personally I'd be willing to wait longer to have a smarter AI. Something I liked in GalCiv2 was that the game had an option to enable certain more CPU-intensive AI searches.

And there's never any need to worry about the AI becoming too smart to be fun. I'm fully confident of that from experience. Even with the best efforts of very capable developers, it's not going to be smarter than a human. And when the AI gets smarter, it can always be counterbalanced by changing other mechanics...

I agree with most of what you've said, that why I ended with argument with the "current balance" comment. However, I'm having turns on terror maps now that take nearly one minute for the AI to calculate. I noticed that with the last patch the turn calculation time increased substantially. I'm not sure I'd want to wait two or three minutes between turns. Of course, there could be a full loop or something else that can be optimized in there now, but generally, smarter AI means more calculation time.
Link to comment
Share on other sites

OK, now for a "real" AI suggestion/fix: NPCs, Farmers with shotguns seem to be much more aggressive and brave then soldiers on the maps I've played lately. Farmers fire everytime they have a chance just about. I would imagine the soldiers should be at least as aggressive. Many times I've seen soldiers retreating and/or not using cover effectively, also not shooting much, in spite of the fact that they have assault rifles.

Link to comment
Share on other sites

I can't speak about performance because I have not seen the code. I don't know the situation therefore, maybe it's as fast as it can be, maybe there is some bad data structure choice that means the whole thing could be sped up by a lot. All I know is that in principle the numbers in Xenonauts (map sizes, alien and soldier count, etc) are such that search-based approaches are feasible. This is of course assuming a good enough technical foundation, which GJ seems to indicate isn't entirely the case. But the scope of the problem is definitely possible to handle with proper application of search techniques. Besides, for things like MCTS you're able to stop the search and get the current-best result at any arbitrary moment.

Link to comment
Share on other sites

Tech Info

Xenonauts v20 Balance Patch 2

Observed

Civs won't allow Xenonauts to help them, and prefer to find a cubby hole to hide in. Which is all very well, but what if you have an open desert level, or if the only buildings around are the focal point of the map?

Also, I think we've all seen civs make bad decisions. But they have a visual range of 16, so how can they make good calls when they're murdered by alien reaction fire? It's not their fault, a Xenonaut could easily meet the same fate.

Desired

A way to communicate with civs so that the player can protect them has been suggested in the past. What if we didn't need to implement a "follow me!" or "get to safety!" type command in the game, and instead the civs tag along behind the Xenonauts naturally? That way it's up to the player to protect them, which they can do with a smoke grenade. Unless the player is flanked, the civs will be low priority targets if they're even seen at all. If the player is flanked, then they've been outplayed by the AI anyway.

There'll always be a player in the level, so civilian behaviour doesn't need to be designed with different types of map in mind. The existing high Sight value means that they should LOVE smoke, which is handy since it's the perfect tool for saving civs. All that needs to be done is to tweak AlliedInfluence and AlliedLOS so that they try to stay behind Xenonauts instead of running away from them.

Finally, give civs a sight range of 20/21 so that they don't die to reaction fire. The aliens need to hunt them down.

Link to comment
Share on other sites

Speaking of civis, this is undoubtedly due to the smaller maps of the balance patch, but in there I've seen (twice now) a civvie run into a UFO! I am fine with them not being especially bright, they are supposed to be panicking after all, but their basis behaviour should be running away from aliens and UFOs.

Link to comment
Share on other sites

Speaking of civis, this is undoubtedly due to the smaller maps of the balance patch, but in there I've seen (twice now) a civvie run into a UFO! I am fine with them not being especially bright, they are supposed to be panicking after all, but their basis behaviour should be running away from aliens and UFOs.

It should do, but I'm not sure that AI's pathing gets updated when it sees an enemy. These are the values for civs:

                     			Sight="1" 			Sound="1"			Cover="-1"			EnemyInfluence="0.5"			AlliedInfluence="0.2"			EnemyLOS="1"			AlliedLOS="0.0"			ProbabilisticSearch="0.0"			NearestEnemy="1"			Goal="0" />		

What should hapen theoretically is this: the civ opens the UFO door, hoping to find a nice hiding hole - a positive value for Sight has this effect. The door opens and there's a million bloomin' aliens inside. The civ sees them and now recalculates based on the new data. Although he has a strong urge to head inside due to a Sight of 1, the positive EnemyLoS and NearestEnemy values overrule Sight and the civ runs for his life.

What seems to happen is this: the civ opens the UFO door, hoping to find a nice hiding hole. He opens the door and sees the aliens, but his path has been set and he's locked in for the ride. He runs towards his doom. Either that, or the civ can see the cover inside and the combined worth of Sight and Cover beat EnemyInfluence and EnemyLOS, and the civ believes that hiding behind a UFO console is the best course of action.

Edited by Ol' Stinky
Link to comment
Share on other sites

Save & Screenshot

smokealien_zpsbaf711c8.png

Link to savegame

Tech. Info

v21 Experimental Build 1, no mods

Observed Behavior

When a smoke grenade is thrown, aliens loose all knowledge of where a solider is and behave in an inappropriate manner. For example: With the save provided, open the door and throw a smoke grenade. The Caesan noncoms will move around randomly without taking into account anything about the smoke.

Desired Behavior

Smoke should be marked in a manner that indicates to the AI that there is either a) something in it, or b) something behind it. It should not automatically loose memory of the fact humans were there, because there is a high probability they still are. Whenever possible, grenades should be thrown into smoke, or smoke should intruded on, or reaction fire should be readied.

Link to comment
Share on other sites

Speaking of civis, this is undoubtedly due to the smaller maps of the balance patch, but in there I've seen (twice now) a civvie run into a UFO! I am fine with them not being especially bright, they are supposed to be panicking after all, but their basis behaviour should be running away from aliens and UFOs.

This several time yesterday i had 2-3 civilian run straight into the UFO. I used it to my advantage as they emptied the aliens TUs once but in the other case i found myself with several Chrysalid to take care of.

What is weird is that it seems they (civilians) tend to cluster around my troops. And so they enter the UFO when i come near it. They also tend to stop right in front of doors which is quite bothering in some situation and even dangerous for my soldiers. Had to kill 2 civilians up till now to save soldiers because civilians prevented me from entering/leaving a room.

I m playing on V20 sable with hotfix 1. I ll try to make a screen and a savegame for both issues if i have time to play tonight.

Edited by Saskali
Link to comment
Share on other sites

Tech Info

Xenonauts v20 Balance Patch 2

Observed

Civs won't allow Xenonauts to help them' date=' and prefer to find a cubby hole to hide in. Which is all very well, but what if you have an open desert level, or if the only buildings around are the focal point of the map?.[/quote']

Obviously there is some balance between civilians that are fully capable of evading aliens, and the ones from X:EU.

My preference is to have the civilians be attracted to Xenonaut units once known, and keeping out of LOS, which should now be implemented. (tweaking of AInfluence, ALOS)

Furthermore, we shouldn't have civvies running into UFOs anymore; I opted for special casing it under the Goal parameter.

Edited by Gijs-Jan
Link to comment
Share on other sites

Observed Behavior

When a smoke grenade is thrown, aliens loose all knowledge of where a solider is and behave in an inappropriate manner. For example: With the save provided, open the door and throw a smoke grenade. The Caesan noncoms will move around randomly without taking into account anything about the smoke.

Should be fixed in the upcoming patch!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...