Jump to content

AI behaviour


NKF

Recommended Posts

Just thought I'd start a thread for discussions on how AI units behave in the game in case anyone cares to start a discussion on it.

 

What brought this on was while I was putting together the Reaper savegame for the damage tests (still not done yet - still a bit more stat tweaking to do).

 

While looking for a Reaper, I came across a savegame with two tanks and a floater that had run out of ammo. It was a large scout and the floater was outside the ship, next to the bridge segment of the UFO. My tanks were surrounding it. For some reason, the floater refused to move.

 

Every turn I was moving my tanks about while waiting for it to make a move. Instead, it just stayed rooted to the spot. But then I noticed that it always ended its turn by looking at the closest tank. Or if the tanks were at equal distances, it seemed to turn to the last tank that moved ... or perhaps it just randomly selects one of the two.

 

While the floater was observing the one tank, I had the other one sneak around the corner. Then I had the one that was being observed sneak away as well. Naturally enough, the floater started to move about. While its movements still seemed erratic, it gravitated towards the tank that it was observing. The other one seemed to be completely put of its mind. So, on a new turn, while both tanks were still hidden, I sent the other tank out and found that the alien was looking in the direction of the tank that it had been watching.

 

What I didn't take note of while testing this last bit was the distances between the two tanks and the floater. So I cannot really say for sure whether or not the alien was going after the unit that it had last observed, or whether it's entirely based on distance.

 

So what was the point of this particular post in the thread? Well, none, really. Just thought I'd share an experience that may or may not provide a bit of insight into the simple but erratic behaviour of our much loved enemies.

 

- NKF

Link to comment
Share on other sites

this is what i noticed, every time i play a ufo game the first unit to get shot at always seems to get hunted down, this goes along with nfk's observation. it seems to go hand in hand almost, but when i use cover i pop out and theres an alien standing there, i shoot at him once then move back into cover. the next turn the alien seems to advance towards the unit that was shooting at it as if hes going to try to kill it (yea right). other than that, they have pretty spuratic movement, not to much out of the ordinary though. they like to hang out in buildings sometimes too. you know that last alien you can't find on the farm layouts...i don't think he knows how to get down the stairs so he just stands there in the corner and waits till you blow the hell out of that corner of the building with a rocket or a modified autocannon mod.
Link to comment
Share on other sites

During some of my trials with Blaster Launchers a while back, I noticed alien behaviour quite similar to NKF's observations. If I took away an aliens weapons via mind control, and had some of my soldiers standing close by, the alien would move closer to the group. No weapons + moving closer to a group of heavily armed X-COM agents equates to suicide in my book! For some reason, unarmed aliens will want to stick close-by to keep an eye on your troops, even if it might mean death!

 

This seems strange. You would think the alien would try to seek cover and at least run away, but no. I think the reason an alien sticks close-by to some X-COM agents is because it does not want to die. If that alien stays in one place and doesn't move, his chances of dying in a flury of reaction fire is nil. And when you move your troops around, blowing most of their TU's in the process, that alien moves too, knowing full well that your soldiers can't reaction fire back. Thus, he is still able to remain inquisitive and also alive. Smart cookie! :P

Link to comment
Share on other sites

My guess is that alien is actually stuck in the "Shoot at enemy target" stage. All it knows is that if it sees an enemy, it should start shooting until the target is dead. As it hasn't got a gun in its hands, and as it hasn't got a melee attack, it can't really do much so it just stands there. If there's no targets, it just wanders aimlessly (well, to a randomly selected adjacent walk node).

 

But that doesn't explain those occasions where the alien walks away even though it has a clear shot at you, melee or ranged. I've seen Chryssalids not take a perfect opportunity that I'd accidentally given it. That last sentence doesn't seem right.

 

- NKF

Link to comment
Share on other sites

Reading through the unitref file, I noticed one offset that seemed to apply only to aliens, but... randomly-ish. It didn't matter what race, that is, item using, latent ability using, or turreted; and it wasn't the same for units of the same type.

 

I made a flying guess, and added 'AI behavior flag?' to my notes. I haven't looked into it further.

 

Perhaps there is a offset that affects the way an alien will work? Some aliens may hunt, some may camp, some may fight, some might take cover...

 

Keeping in mind that aliens tend to act differently at different times. You can draw them out of their UFOs by putting grenades on the roof, for example.

Link to comment
Share on other sites

IIRC, the alien units all have another stat in addition to the ones listed on the stat screen. It's listed in the OSG as "intelligence", and apparently governs how much "memory" an alien unit has.

 

Whoa. Backtrack a bit. Apparently, the aliens do cheat. A little. They have the ability to remember the position of X-Com (and I would guess civilian) units even when they would not ordnarily be able to see them (out of line of sight or whatever). Hence the "walk out, take a look, and walk back" move that seems so common in the alien turn.

 

Based on that, I would guess that the situation here is that the Floater knows where the tanks are, and so doesn't feel the need to move. Since it has no ammo and no HTH, it doesn't feel the need to attack, either. When the tanks start moving, it goes looking for the one whose location it had buffered courtesy of the intelligence stat.

 

Obviously, it's highly unlikely this is the whole story. If we knew that, maybe we could do something about hunt-the-last-alien syndrome....

Link to comment
Share on other sites

Hmm, actually, Bomb Bloke, you might want to take into consideration the index of the units in the unitpos.dat file (and unitref.dat, just in case), just for reference. Then, when the alien appears as though it's concentrated on a particular unit, compare the index of the unit being observed with some of those stats that you're feeling suspicious about.

 

Just a thought.

 

- NKF

Link to comment
Share on other sites

I was brain-storming the other day on why an alien might stay close to a group your soldiers. After reading NKF's post of the alien being stuck in a "Shoot at enemy target" mode, it made a little more sense. But, for the life of me, I couldn't determine what caused the alien to be stuck. Then it hit me like a ton of bricks: aggression may be the culprit. So I looked to the OSG for guidance.

 

Here is a quote: (it's on pg 260 of the OSG)

A rating of the alien's level of aggressiveness, ranked from 0 to 2, with 2 the most aggressive.

The more aggressive the alien, the more likely that it will stand and attack an X-COM soldier rather than attempt to take cover.

 

Low and behold, all alien Soldiers have an aggression rating of 2 (except the Ethereal Soldier, he has a rating of 1). Therefore, when an alien soldier is standing near your troops, he will stay and fight (even though he doesn't have a weapon). See, his aggression rating is so high that it overrides the flee instinct (if he has one). :P

 

usmarox Posted on Nov 17 2004, 04:24 PM

Obviously, it's highly unlikely this is the whole story. If we knew that, maybe we could do something about hunt-the-last-alien syndrome.... 

It's entirely possible that aggression plays a role in this scenario also. Usually, the only alien left is found inside the UFO. Since aliens that stay inside the UFO frequently are higher-ranking, their aggression rating is low. Hence, they tend to stay in one place (especially if all his friends were killed by your troops, and his morale is low).

 

Incidentally, my enduring problem of an alien that will not move away from the bridge of a Supply Ship, could be answered this way too. Alien near bridge = Higher Rank = Low Aggression = Will not move. Couple this with low morale, and I can see why that alien is stationary. You have to be assertive with the last alien and take a more aggressive stance, otherwise it could be a long wait! It might be time for me to revise my strategy somewhat! :(

Link to comment
Share on other sites

Aliens have an official aggression stat? Well, in that case, I reckon that's what I've gone and found. :P

 

And I reckon you can change that stat. For example, if you start throwing grenades near aliens, it... annoys them, drawing them out of their locations.

 

I would debate that all aliens have the same aggression stat at the start of the map, though. Just from my observations.

 

As for aliens 'tailing' a certain unit, NKF... I'm not sure.

 

In TFTD, I have observed an alien spotting one of my units. It then tried to use cover to walk around and attack him from behind, over the course of multiple turns. This would suggest the alien had a target, and wanted to stay out of sight of that target, allowing a safe attack.

 

As for hunt the last alien syndrome, I get the feeling that when you start your turn, the unit that is first selected is the unit closest to an alien. But that's just a theory, that happens to have been correct on a few occasions. If it is the case, setting up units across the map would create a sort of 'sensor grid', and furthar pinpointing can be done by moving units.

Link to comment
Share on other sites

I recall that the aliens have an intelligence stat that allows them to remember a unit for so many turns. I was just wondering if that was it.

 

I recall Bladefirelight mentioning to a while back that there's a problem with the AI in TFTD that, after so many turns, most aliens end up just standing around rather than wandering about at random like they appear to do in UFO.

 

- NKF

Link to comment
Share on other sites

*tries to revive TFTD memories*

 

I don't like the feel of that game as much as UFO, so I don't usually play it. :P

 

Hrm... I remember some cases when aliens would not move around much, even if they were placed out in the open where you would expect them to be 'aggressive'. But, I dunno.

Link to comment
Share on other sites

Aliens have an official aggression stat? Well, in that case, I reckon that's what I've gone and found.  :P

Initially, I thought that perhaps aggression could explain that offset value in the unitref file you were asking about. But you threw me a curve and plopped the word "randomly-ish" in there. If that wasn't enough, you also said: [the offset] wasn't the same for units of the same type." That confused me a bit. For "units of the same type" did you mean 'alien', or 'race'?

 

See, I was basing my conclusion off 'rank', not type of alien. The aggression number is not really random. Each alien race and rank has a unique aggression value which is slightly different from other alien race/ranks. From the surface, maybe the numbers looked randomly-ish, so I can see why you couldn't explain that offset. I figured I'd let you make your own conclusion, since you had more knowledge on the subject than me! :(

 

I did see that topic in the modders section yesterday, but his questions were far beyond my capabilities. Here again, it was probably better to let the experts provide an answer! I never really got into the modding aspect of the game. I'd much rather play the game to stumble across ideas, than decode the inner workings of it! :(

Link to comment
Share on other sites

What I mean is, say you have two Celatid terrorists, say. One might have a different 'aggression' stat then the other at the start of the map, dispite them being the same race, as well as 'rank'. The same goes for any alien.

 

But keep in mind that I don't have the OSG. If it says anything about aggression at all, I don't know it.

Link to comment
Share on other sites

  • 2 weeks later...

As a curious non-participant in this thread, I'm wondering if anyone has played around with the alleged aggression and/or intelligence stats for aliens yet. It seems this thread kind of faded away with no resolution, as everyone focuses on the ongoing damage tests...

 

It seems like it would be fairly easy to set up some basic trials. Arm an alien with an edited weapon that does no damage. Edit one of the "unknown" alien stats. Observe the alien's behavior as it spots an xcom soldier. Reload the saved game, see if it follows the same series of actions. Reload again, until you know all of the alien's possible choices of action. Increment the alien stat, and repeat. Repeat the process for every unknown alien stat. Preliminary tests should focus on one alien and one soldier. Later, multiple aliens, multiple soldiers, wounded aliens, wounded soldiers, smoke, fire, lighting, different maps, and different UFOs should be tested, as alien AI may choose different movements based on various battlefield conditions. These complex tests are outside the scope of the initial problem, though. Right now, we simply want to know what the "unknown" alien stats do, and what basic affect they have on alien AI.

 

Aliens may behave differently as their morale decreases. It seems that any explosion on the map decreases the morale of some units, even if no soldier or alien is damaged by the explosion. This reduction in morale may explain why certain aliens "wake up" when an explosion occurs. Perhaps the alien AI is triggered to act when some stat (including morale) changes.

 

For those soldiers who use smoke grenades, you will notice that smoke goes through walls. Smoke causes stun damage. Aliens will also "wake up" when smoke enters their general vicinity--again, when a stat changes, the alien wakes up.

 

I'll conduct some of these tests myself. It'll be a little while, though, as my RL work schedule is insane right now. Regardless, I hate to see this topic die while everyone focuses on the (admittedly interesting) damage tests.

 

--Zeno

Link to comment
Share on other sites

Well, I've bugged inteck, who may know something about it. He may come over here and enlighten us.

 

As for my knowledge about the aggression stat, all I have is a guess. You see, there are MANY stats we don't understand at the moment. So whether the stat I've chosen is aggression is anyone's guess.

Link to comment
Share on other sites

Like Bomb Bloke said, those numbers may or may not be aggression and/or intelligence stats. So there's no way to know quite yet.

 

I'd be interested in testing/learning about the intelligence and aggression stats, and how they change alien behavior. However, I know very little about changing/editing those values, hence why I haven't played around with them. My forte is testing, so the changing of values and setting up a game has to be done by someone with expertise in this subject. If this is done, and the game made available, I would be more than happy to lend a hand testing out the various scenarios you cite.

 

As for "everyone" focusing on the damage modifier tests in the works, I'd have to disagree. The only willing participants in that thread is NKF, Bomb Bloke and myself. Three people with an activity in these tests hardly constitute a serious interest (unless you consider "everyone" those aforementioned individuals)! :P Even then, I am the only one performing the actual tests, with NKF setting up the games and Bomb Bloke offering his expertise and logging program to make things go quicker. The results so far have provided nothing more than a fleeting interest to the other members of this website, so I doubt that thread is drawing attention away form this one. :(

Link to comment
Share on other sites

Zombie, I think the tests would have to involve changing the stat, then testing, then changing the stat, then testing, then chang...you get the idea. I don't know the quality of the various editors, but one of them may allow adjustments to the "unknown stats".

 

By "everyone" I meant "recent posting activity over the last few days in the UFO topic area". However, that is no longer valid, as it seems yesterday there was a flurry of activity in numerous threads under UFO. I didn't mean to say everyone was working on the damage testing. I recognize that work is only being done by you, Bomb Bloke, and NKF. However, it was (up until yesterday) the primary thread of activity (again, only in UFO, not the other topics). The AI testing thread (this thread) had lain dormant for over 10 days when I posted.

 

Thank you both for responding, and I'll help with the AI tests (or "unknown stat tests") when I can.

 

--Zeno

Link to comment
Share on other sites

I suppose you can think of it this way. While we're going on as usual, everyone else hasn't been keeping up. :P

 

The trouble with testing the aggression stat is how exactly are you going to test it?

 

But perhaps it may just be a simple state controller or somesuch. Like patrol, guard, hunt, etc. I recall someone, probably Bladefirelight, mentioning this to me many moons ago when there was a thread about the map nodes (waypoints, spawn locations, etc).

 

From playing my many ames in my Solo-Floater-Base-Assault-blah-blah-blah challenge, with a minor variation in that I go after the battleship that's landed nearby instead, I notice that I stay too long in the Lightning, almost the whole battleship of floaters will end up gravitating towards the ship (I once won the map without stepping almost half a map block away from the Lightning). My guess these fellows have their disposition setting set to hunt X-Com units. Or at least that's what it ends up as.

 

Also, will the aggression stat change during the battle? Say an alien who was previously on guard (like the one in the Large Scout) suddenly decides to head towards the nearest soldier that's gone up the left passage.

 

- NKF

Link to comment
Share on other sites

Yes, that is a problem. Testing the aggression stat, that is. However, we're also out to discover any unknown variables (and there are several in the long stream of code describing aliens).

 

The test must involve observation of the alien during the alien's turn. But the act of observing (i.e. having xcom soldiers with line of sight to the alien) may affect the alien's AI. On the other hand, simply recording the starting and ending position of an alien could reveal it's behaviour. I believe xcomutil has some function for revealing the map and all aliens, which could be a great help in uncovering the AI.

 

Anyway, the test would probably involve making some series of choices during the xcom turn, then observing the alien's turn (or checking the end position of all aliens). Record the results. Reload, and make the same series of choices. Record the results during the alien's turn. Repeat until you have uncovered all possible actions the aliens may take, given the same battlefield conditions.

 

Then, edit one of the unknown stats. Repeat the test. If nothing changes, then that stat probably has nothing to do with AI. Of course, it may have something to do with AI under different battlefield conditions...

 

I admit that comprehensive testing would be impossible due to the nearly infinite battlefield conditions which may be created. However, we must start somewhere. Personally, I believe (that is, my hypothesis is) that there are very few "choices" that the aliens may make on their turn. I think the aliens will perform almost exactly the same actions, given the same battlefield conditions. Further, I believe there will only be one or two unknown stats that affect AI. If my guesses are correct, then finding a strong correlation between unknown stats and alien AI is statistically possible after only a few tests.

 

Yes, stats may change during a battle. Yes, the aliens behave differently if you make different choices, or if the map changes, or if the results of some attack are favorable or unfavorable. If a player modifies an AI stat, they still won't know exactly what will occur during a battle due to the huge number of random factors.

 

Anyway, I think discovering this information is within reach, and would be useful for both the modding community and the UFO-edited-version players. There is also the potential to uncover some completely unexpected, previously-unknown variable in the alien code. What if Ethereals could be converted to always flee from xcom soldiers? What if Mutons could hold and fire three weapons simultaneously? What if Snakemen grew feet? What if Floaters tunneled underground? What if...what if...humans and Sectoids had compatible DNA???

 

And so, unsuspecting, the Mutant Alliance is born.

 

--Zeno

Link to comment
Share on other sites

Snakemen can't be given feet, without editing the graphic files. Mutons can hold as many weapons as you chose to give them (and yes, I mean in one hand). Floaters won't be able to tunnel, however.

 

I think there may be an aggression stat for alien craft. I get the feeling Mutons are much more aggresive in the air then the other races.

Link to comment
Share on other sites

Yeah, I also had a feeling that the simple act of observing an alien might change the behavior you are trying to study. (If you are familiar with the Heisenberg Uncertainty principal, it's kinda the same idea).

 

However, even if you were able to lift the "fog of war" through xcomutil, the results might not be too helpful. Say you take an aliens inital position reading at the end of X-COM turn, then take a position reading at the beginning of X-COM's next turn. Most of the time, aliens move around but then return back to their original starting point (and orientation, may I add).

 

If you just took a starting and ending poisition, the result would show that the alien never moved. In reality, it had moved, but you never took enough readings to determine that. Even comparing the alien's TU from turn to turn would usually show the same number. This is because they have a "partol" route, and stick to it until something changes (like X-COM agent(s) becomming visible to that alien or his close friends).

 

Changing a certain value might not change an aliens behavior, simply because your troops aren't visible. But make a soldier visible, and the alien might behave different. Heck, even the simple act of taking an alien's weapon away changes it's behavior. Morale also is a big factor.

 

I guess that these tests will have to be run under very stringent conditions to gain any kind of understanding of whats going on. All variables have to be eliminated (or at leat made a constant) because any one of them might change behavior. But like one of Murphy's Laws on Technology states:

Under the most rigorously controlled conditions of pressure, temperature, volume, humidity, and other variables the organism will do as it damn well pleases.
:P
Link to comment
Share on other sites

Bomb Bloke, I was joking in those last statements. Zombie, that's a good point on patrol routes. However, as I recall, if the patrol route is long then aliens will require 2 or more turns to complete the route.

 

I haven't started any testing, so this is as good a place as any to discuss potential setups.

 

I already considered the affect of weapons--i.e. the AI would change depending on whether a shot hit or missed, and whether it caused damage. I was planning to edit weapons to cause 0 damage, and edit accuracy on weapons and units to 250 to ensure a hit. I was also planning to eliminate reaction fire by editing that stat to 0.

 

It makes sense to "slow down" the battle. I can edit all units to only 10 time units (enough to perform very small movements, an inventory change, etc). This won't affect firing times much, as these are a percentage of remaining TUs. This should prevent aliens from reaching most waypoints during their patrol route.

 

We can't discount the initial movements of aliens. If they truly have a "hunting" stat, as NKF suggested, then at some point aliens may begin to move toward xcom as an AI choice (instead of following their patrol route). As you said, though, the interesting part of the test really comes when aliens spot xcom units, and thus choose some new action.

 

Any other suggestions? Again, it may be a few weeks before I begin testing.

 

--Zeno

Link to comment
Share on other sites

Or let's put it this way, X-Com soldiers can become a node in the aliens' patrol route. That could be how they hunt X-Com soldiers.

 

Like in my first post, I mentioned that the floater was attracted to the nearest unit to it.

 

- NKF

Link to comment
Share on other sites

I wonder about that--xcom soldiers becoming a node in the patrol route. The patrol route nodes seem to be static. Instead, I would guess that a soldier becomes a "target" and it is given a higher priority than the static patrol route nodes. Once the "target" is forgotten, lost, or dead, then the alien moves to the nearest node and continues it's patrol route.

 

Using prior observation and memory, I recall that each alien tends to focus on one xcom soldier. Aliens seem to pursue a single "target", and when another target appears, they switch to the new target (completely forgetting the old one). Again, this indicates to me that the soldiers are stored in memory in a single, separate data variable, and that each alien has one such variable. The static route nodes, on the other hand, seem to be an array of global positioning data elements which all aliens use to decide where to go.

 

I believe it is possible to add static route nodes (if we could translate a large portion of the tactical data files), but I don't believe the AI ever does this. It seems to me that the static route nodes are created one time: when the map is created. If I recall correctly, xcom starting positions (the dropship and base entry portals) are always a static route node for aliens. That would explain why, if your soldiers wait long enough in their starting spots, most or all aliens will eventually make their way to the xcom soldiers.

 

Bladefirelight or another mapmaking modder should be able to explain route maps and patrol nodes much better, and answer questions about adding patrol nodes. If multiple dynamic patrol nodes could be created, the UFO modders could greatly enhance the alien AI during combat.

 

--Zeno

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...