aliens

Author Topic: alien AI work, now with test builds  (Read 13854 times)

Offline hmaon

  • Sergeant
  • **
  • Posts: 40
  • C jockey
    • View Profile
alien AI work, now with test builds
« on: March 02, 2013, 11:23:19 am »
Latest un-merged build you can try if you're bold: n/a everything's merged

So, I've been working on some AI changes. It'll probably be a while before the giant pull request is merged (https://github.com/SupSuper/OpenXcom/pull/358), especially since it keeps getting amended, but if anyone wants help test them, I'm making builds available.

Latest: https://bumba.net/~hmaon/oxc/oxc_ai_changes_2013_Mar_02.7z


Never mind, it's merged! Just use the git builds.

You might notice aliens trying to hide after shooting you. They should also reliably face toward where they expect xcom to appear, when they're hidden. Then there's a bunch of stuff that might not be noticeable and then also melee units should be properly vicious. Maybe. Unless they're broken again.

Attached is a screenshot of some sectoids trying to set up an ambush.
« Last Edit: March 17, 2013, 08:05:27 pm by hmaon »

Offline xracer

  • Commander
  • *****
  • Posts: 565
  • X-COM lover, we've gone at it everywhere
    • View Profile
Re: alien AI work, now with test builds
« Reply #1 on: March 08, 2013, 01:06:23 am »
I like it!!!

Just had a mission where i was confused where i was being shot from :) it was a night mission in the end figured it out and kill the little green man.

But most definitely improves game play. 

Offline Ran

  • Colonel
  • ****
  • Posts: 196
    • View Profile
Re: alien AI work, now with test builds
« Reply #2 on: March 10, 2013, 01:36:10 am »
Yes, clearly an improvement!

What exactly does sneakyAI do?
Aliens try to avoid tiles you can see?
I noticed aliens are more timid and rather try to walk away when they see an agent than trying to shoot him.

Generally I think aliens are pretty good outside now, but terrible inside UFOs.
Instead of taking advantage of the terrain (lurking behind corners and doors and shooting anybody who walks into them) they just wander around and even past your agents without any plan. I don't know if this is possible to implement but aliens should not simply walk through doors (and get shot by an agent waiting outside) but stop at a door, open it and only walk further if it is safe and if they have enough TUs for a shot. Even better if they could give each other cover (always check if another unit with enough TUs for reaction shot is nearby before advancing).

Offline hmaon

  • Sergeant
  • **
  • Posts: 40
  • C jockey
    • View Profile
Re: alien AI work, now with test builds
« Reply #3 on: March 10, 2013, 08:21:01 am »
Good feedback, thanks!

Aliens have hardly any concept of planning ahead right now, sadly.

What type of UFO were you in?

Offline Ran

  • Colonel
  • ****
  • Posts: 196
    • View Profile
Re: alien AI work, now with test builds
« Reply #4 on: March 10, 2013, 11:28:11 pm »
Glad I can help.  :)
This applies to all UFO types from Medium Scout to Battleship as well as certain game situations in general (see below).
Take the Large Scout for instance. It's great for ambushes with it's narrow aisles leading to the 2 doors, yet aliens take no advantage of that but wander around mindlessly.
Also aliens should make more use of grenades. They regularly carry them but except for terrorists almost never throw them. Especially inside UFOs they'd have a terrible effect.

After some testing I now understand  how sneakyAI works - and where it doesn't work.
When aliens see a target, instead of blindly attacking they try to get in a covered position and shoot the target from there.
While this sounds good and works decently with distant targets in complex terrain like jungle, forest or farm, it's complete nonsense when there is no cover within reach or the target is very close.

Try the attached savegame:

There's a sectoid near the lower left corner of the UFO.
If you put a soldier very close to the alien there is a very high probability that it will not shoot the easy target but run away and try to hide in the bushes to the left which may end with the poor alien standing in open terrain with the back towards your soldier. If you give him another turn, the sectoid will take cover in the bushes and shoot the soldier from there.
So the basic idea is good but a very bad choice in the given situation.

Enter the UFO with a single soldier and place him in the middle of the aliens.
Watch in amazement as they try to run out of the UFO or wander around until they run out of TUs.
Of course they will shoot now and then but in the majority of cases they try to take cover or flee which is insane in this situation. Rather than sneaky they simply seem terribly afraid of your soldiers. ;)

Maybe it's possible to have different AI modes:
sneakyAI if target is far away and cover within reach - try to hide, shoot from cover, or pop out, shoot, go back to cover

aggressiveAI if the target is close or cover out of reach - spend all TUs on attacking nearest target no matter what

lurkingAI inside UFO (except for some aliens patroling) - save TUs for reaction shot, move cautiously and make sure you end turn in favorable position near doors or corners facing the right direction.



« Last Edit: March 10, 2013, 11:31:58 pm by Ran »

Offline hmaon

  • Sergeant
  • **
  • Posts: 40
  • C jockey
    • View Profile
Re: alien AI work, now with test builds
« Reply #5 on: March 11, 2013, 12:29:49 am »
The sneakyAI setting actually only affects pathfinding--it makes visible tiles effectively more costly so that the algorithm will try to route around them if possible.

Wandering around mindlessly is often patrol behavior. It just walks to random nodes that are adjacent to the current node. I'm not sure what to do about it though. Maybe once an alien spots a soldier, all nearby aliens should also begin acting deliberately?  Except they don't necessarily do that on their own either. They forget about their target after a number of turns equal to their intelligence number. When they see a soldier in the first place, they only aggress some of the time, based on their aggression score. Ufopaedia.org says: "Aggression is a number between 0 and 2. The larger the value, the more aggressive the alien will be. High ranking aliens usually prefer to stay concealed, rather than get involved in a raging fire-fight.." (https://www.ufopaedia.org/index.php?title=Alien_Stats#Calculating_statistics).

Oh and the chance of the aliens using a grenade is higher on higher game difficulties, iirc.

Offline Ran

  • Colonel
  • ****
  • Posts: 196
    • View Profile
Re: alien AI work, now with test builds
« Reply #6 on: March 11, 2013, 06:57:40 pm »
Well' I'm mostly playing on Veteran and all I do is collecting grenades from dead aliens (there are notably more than at Beginner level). However only terrorists actually throw them at my soldiers.

What I don't get about sneakyAI is why aliens try to walk away when they see a target instead of shooting it. The guy outside the UFO is a soldier so I guess he should be pretty aggressive. Maybe it's just my impression but I think with sneakyAI enabled aliens spend more TUs for walking away and less on shooting - unless they are already in cover.
Will have to run more tests on this


Offline hmaon

  • Sergeant
  • **
  • Posts: 40
  • C jockey
    • View Profile
Re: alien AI work, now with test builds
« Reply #7 on: March 12, 2013, 06:31:26 pm »
A sectoid soldier for instance does have an aggression of 2. That's 90% chance to attack minus 5% for every soldier spotting it, apparently.  Also if he just used two moves to patrol and then spotted you, he's going to try to back off instead of attacking. Maybe it's dumb.

Anyway, I'm trying out some new patrol code based on Volutar's suggestions and descriptions of xcom1's patrol behavior. You can try it here: https://bumba.net/~hmaon/oxc/oxc_ai_changes_2013_Mar_12.7z
or from here: https://github.com/hmaon/OpenXcom/tree/ai_continues

Aliens should wander far afield and won't pace back and forth in one small space. This is probably not the code's final form though.

Wow, I really messed up something in that build. I won't even say what. Here's a new one: https://bumba.net/~hmaon/oxc/oxc_ai_changes_2013_Mar_12.7z This one features improved cover AI, hopefully.
« Last Edit: March 14, 2013, 11:08:13 pm by hmaon »

Offline hmaon

  • Sergeant
  • **
  • Posts: 40
  • C jockey
    • View Profile
Re: alien AI work, now with test builds
« Reply #8 on: March 15, 2013, 07:59:36 am »
https://bumba.net/~hmaon/oxc/oxc_ai_changes_2013_Mar_15.7z

fixed more bugs, sped some things up considerably, added a visualizer for AI exposure calculations (turn on traceAI and hit ctrl-F10 when an alien is selected; see screenshot attached)

oh yeah, I guess ...048.png shows a reaper not hiding properly. hooray!

Offline kkmic

  • Commander
  • *****
  • Posts: 582
  • Undefined
    • View Profile
Re: alien AI work, now with test builds
« Reply #9 on: March 15, 2013, 11:47:47 am »
Can the AI be "dumbed down" for lower difficulty levels?

Offline hmaon

  • Sergeant
  • **
  • Posts: 40
  • C jockey
    • View Profile
Re: alien AI work, now with test builds
« Reply #10 on: March 15, 2013, 09:17:19 pm »
Not currently but, honestly, it's already pretty dumb. It might be something that could be added later, along with modding.

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: alien AI work, now with test builds
« Reply #11 on: March 17, 2013, 09:49:13 pm »
aspects of the ai are affected by difficulty, like the number of waypoints aliens are allowed to use for blaster launchers, the odds of psionic attacks, the odds of explosive attacks in general, and the odds of grenade attacks.

Offline kkmic

  • Commander
  • *****
  • Posts: 582
  • Undefined
    • View Profile
Re: alien AI work, now with test builds
« Reply #12 on: March 19, 2013, 10:16:20 am »