Author Topic: For AI-"improvements", should I add a new option or use the existing "sneakyAI"?  (Read 13324 times)

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 642
    • View Profile
"Improvements" in quotation-marks because it's pretty obvious that the AI was never intended to play optimally.

However, I'm interested in how it could alter the way the game feels when the AI actually tries to be as gruesome as possible.

The question is: Should I add a new option for that or can it be assumed that people who choose "Sneaky AI" want the AI to be mean?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9085
    • View Profile
It's a free world.
You can do anything you want on your copy of OpenXcom :)

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 642
    • View Profile
I meant in order to increase the chances for a pull-request being accepted as I want others to have an easier opportunity to suffer too! ;D

Offline Finnik

  • Commander
  • *****
  • Posts: 508
  • Finnik#0257
    • View Profile
I'd say it's better to keep those options separate, at least if it is not super hard code-wise, as it makes debugging it better.

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 642
    • View Profile
I'd say it's better to keep those options separate, at least if it is not super hard code-wise, as it makes debugging it better.
Yeah, I figured too that it makes more sense this way. Especially since Sneaky AI has a very distinct description. I just added my own description.

Offline Finnik

  • Commander
  • *****
  • Posts: 508
  • Finnik#0257
    • View Profile
What is your exact idea?

Making AI smarter is a tempting idea to me, but I don't know where to start, actually...

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11721
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Making AI smarter is a tempting idea to me, but I don't know where to start, actually...

Using medikits? :)

Offline Vakrug

  • Colonel
  • ****
  • Posts: 320
    • View Profile
Using medikits? :)
Yeah! Like in Phoenix Point, where enemy's soldier decides to take healing in an open space surrounded by phoenix troops.
Seriously, if an AI was smart enough to use medikits it still should not use them because it will never actually benefit to him.

And by "where to start?" probably means "how to program?".

Offline Finnik

  • Commander
  • *****
  • Posts: 508
  • Finnik#0257
    • View Profile
Well, I think I could program it if I would know what to code. So the right idea is a problem for me when I think AI improvements.

Using medikits? :)

A nice idea, btw. I'm very sure there are good places where AI could use it in XCF, as there are many cases when you can just wait for it to bleed out.

Offline Finnik

  • Commander
  • *****
  • Posts: 508
  • Finnik#0257
    • View Profile
Well, I think I could program it if I would know what to code. So the right idea is a problem for me when I think AI improvements.

A nice idea, btw. I'm very sure there are good places where AI could use it in XCF, as there are many cases when you can just wait for it to bleed out while roaming around trying to find you.

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 642
    • View Profile
What is your exact idea?

Making AI smarter is a tempting idea to me, but I don't know where to start, actually...
I actually already realized quite a few things. There's a few things that don't quite work yet but some very low hanging fruits did.

For example using the already existing sniper-code all the time. Basically as soon as the location of an enemy unit is known and there's a line of fire, use it. That's how the human also plays. This alone is a massive improvement and makes it a lot harder already. Especially on maps with little cover. One alien sees you, everyone shoots you.

Also: There's a method called "findFirePoint" ... This is the one I've modified the most and which is still not 100% working as I want it. But the idea is that as soon as the location of an enemy unit is known and I don't already have a line of fire, I will walk towards it while keeping TUs for reaction fire. Unless I can get to it and still shoot.

Problem is that this is quite costly due to a large amount of path-finding and vision-checks. I had used a work-around but the workaround only works well in open area but not when there's many buildings. So the units get stuck in UFOs.

findFirePoint already is a very clever method. It basically scores a position to go to and fire from. Closer to current location is better and being seen by enemy units makes it worse. So it already wants to choose a good location.

More coordination between the enemy-units would be great. For example: All of them move roughly towards the same location while staying spaced out against grenades. And once everyone is in position they strike all at once.

Offline Vakrug

  • Colonel
  • ****
  • Posts: 320
    • View Profile
For example using the already existing sniper-code all the time. Basically as soon as the location of an enemy unit is known and there's a line of fire, use it. That's how the human also plays. This alone is a massive improvement and makes it a lot harder already. Especially on maps with little cover. One alien sees you, everyone shoots you.
I know even better way for "improvement". It is called "don't ever move, just shoot, act like a turret". Yeah, if you just want to make game harder, paradoxically you should abolish AI completely, since AI actions right now are mostly suicidal.

But if you want to make game actually interesting and AI actions somewhat realistic, then you should teach AI a concept of being sieged.
In an essence, most of XCOM missions ideologically are castle siege and storming. Bad guys are living in an area for a while, then Skyranger flies in and starts massacring: first those without cover, then those who are still hiding inside buildings. If only AI knew that!
Right now an AI has a behavior of a lemmings. Player just adopts to that and a castle siege game becomes a tower defense game.
In order to change that AI should act approximately like that:
  • Realize that some building on a map should be protected from the inside.
  • Instead of running out of such building, AI should run in to them.
  • Once inside AI should detect firing positions. These are doors, windows, man made holes.
  • Then each AI unit should be assigned to "manage" such firing position.
  • By "managing" I mean performing each turn such actions: look outside, if you spot an enemy, then shoot, then hide inside and end your turn. If not, then just hide inside. Don't forget to face the door.
I don't know how possible it is to implement that (probably impossible), but if done it would feel, that a player is facing a sentient opponent instead of bunch of lemmings.

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 642
    • View Profile
I'm also running into another issue:

The AI has some inherit cheating. When I combine that with being smarter, it becomes unfair real quickly.

I think this way of cheating is likely an exact or very close replica of how it originally worked as I remember similar issues from back in the day.

What I mean: Once a unit is spotted its position remains known to the AI for several turns. In this case it depends on the Alien's intelligence. After turn 20 the Aliens get full knowledge of your units positions.

I'd say it is one thing to use that knowledge in tactical decisions as in "moving towards the unit". However, sniping at a unit that is currently not visible to any of its other units simply for having seen it somewhere else 3 turns before can lead to some frustration.

So I'm thinking that I need a distinction between "having an idea" where a unit is and "knowing exactly" where a unit is.


To the findFirePoint-issue: When I let it do a full-map-search it produces wonderful results in finding good positions. Way better than walking up to the unit and looking for a position within movement-range. For example: I did tests where I just stood in the sky-ranger and ended my turn. With the full map search they were going to locations quite a bit in front of it but in an angle that minimized their own visibility and still allowed them to shoot kinda diagonally. With the cheap function that only looked in a small radius around the unit, they would try to climb into the sky-ranger once the front-soldiers were dead, exposed themselves to vision and get shot by the soldiers from a very short distance while trying. It was 5 aliens vs. 14 soldiers with standard rifles just doing reaction-fire. In scenario 1 the aliens won and killed everyone while 2 of them survived. In scenario 2 all aliens were dead with only 4 casualties on X-Com side.

However, turn-processing in scenario 1 was unbearably slow.

The issue is that it attempts a pathfinding-call to every place on the map. Maybe a reversal between path-finding and line-of-sight-check could help. But on more open maps the difference probably isn't that big. I guess in the end a compromise is probably using a search-radius that is bigger than 5 but also not as big as the entire map. Also 2 medium-sized-search-radii (one around the unit and one around the target) are probably better than one big one just around the unit.

So my plans for today are: Make a distinction between "I kinda know where you are" and "I know so well where you are so I can shoot at you from all over the map" as well as attempting the double-medium-radius-compromise for findFirePoint.

Online psavola

  • Commander
  • *****
  • Posts: 827
    • View Profile
What I mean: Once a unit is spotted its position remains known to the AI for several turns. In this case it depends on the Alien's intelligence. After turn 20 the Aliens get full knowledge of your units positions.

I'd say it is one thing to use that knowledge in tactical decisions as in "moving towards the unit". However, sniping at a unit that is currently not visible to any of its other units simply for having seen it somewhere else 3 turns before can lead to some frustration.

So I'm thinking that I need a distinction between "having an idea" where a unit is and "knowing exactly" where a unit is.

Isn't this the way it's essentially supposed to work now? There is a difference of soldiers the aliens "know" and are "visible" to them. For example, based on turn 20+ cheating, the aliens cannot (AFAIK) shoot directly at the soldier, whose precise location is known (but not visible) to them, or even launch a blaster or throw a grenade (not sure of this), and maybe even not do PSI. For that, the aliens must have actually seen the soldier within a certain amount of turns (depending on the intelligence ie. "memory" or the alien). My understanding is, however, that this memory essentially only affects PSI (i.e. aliens can't still shoot a soldier they remember unless someone spots the soldier on their turn).

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 642
    • View Profile
I know even better way for "improvement". It is called "don't ever move, just shoot, act like a turret". Yeah, if you just want to make game harder, paradoxically you should abolish AI completely, since AI actions right now are mostly suicidal.
I disagree on "not moving" providing the most challenge. At least you'd have to go to better locations to camp from while also avoiding clumping. Getting into better positions to shoot from without exposing yourself in the process can be highly advantageous.

Also staying in your position while somewhere else on the map your friends are engaged in a fire-fight sounds quite sub-optimal.

In an essence, most of XCOM missions ideologically are castle siege and storming. Bad guys are living in an area for a while, then Skyranger flies in and starts massacring: first those without cover, then those who are still hiding inside buildings. Right now an AI has a behavior of a lemmings. Player just adopts to that and a castle siege game becomes a tower defense game.
I agree with your assessment of the state of the default-AI. It's exploitable. A big reason for the tower-defense-exploit is that they are kinda hard-coded to be hiding until turn 20 and starting from turn 21 they get the idea that maybe they should start exploring. (Exception are x-com-base-defense-missions, where they take a more active role right away). So they give you all the time you need to set up a trap and then walk into it one by one. Simply removing that switch-flip would help them big time in regards of playing more castle-defensy.

Could also make them all gather up in the "lobby" of their respective vessel, spread them around and aim at the door. I agree that this would make it hard.

However, I have a vastly different vision of how the solution should look like. I don't want the AI to play a passive and defensive-camping-game with potentially even more hide&seek.

I kinda want to reverse the roles here. Basically the player shall feel like their units are being hunted by the aliens and not the other way around. I want the aliens to be proactive but not in a lemming-like way.

What I'm thinking of is slowly moving towards where they think they can take good aim, reserving TUs for reaction-fire while avoiding exposure to enemy vision. There already are good methods for evaluating terrain and the path-finding, with active "Sneaky AI", does the "avoid exposure"-part. The important part is to not act like independent individuals who do that one by one but instead in a coordinated and decisive way.

I kinda already achieved that with some caveats. The main one being processing-time caused by "brute-forcing" the search for the ideal position to be at.

Realizing what you described would be possible. An algorithm would need to analyze the map for a ratio of "how many tiles do I have vision to" vs. "from how many tiles am I visible".
This could be helped and made cheaper with something that I'd call "semi"-cheating. Semi-cheating is when you use information you normally wouldn't have in a way to emulate experience and intuition.
In this case: You don't need to consider vision to and from all other tiles but only the tiles that there are enemies at. Using the information where enemies are to snipe them despite not seeing them obviously oversteps the boundary to actual cheating. Using it to save processing-time, emulate experience and prune useless behavior is more of a grey-area, which I think might be okay in this game.

I mean obviously the Sky-Ranger is where the X-Com-sodliers are coming from. And when we assume the Aliens are highly intelligent and communicate back to Cydonia, having them act ignorant to that circumstance seems more immersion-breaking then them knowing it's full of enemy-units.

Then there's also the circumstance that the player gets acoustic clues of the wereabouts of the aliens. So some sort of compensation for the aliens seems feasible.

In the end it is about the user-experience anyways. And it's very subjective what different people consider fun. I guess I first try to make it fun for myself.