Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

Trader AI

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
Fritz
---- E L I T E ----
---- E L I T E ----
Posts: 591
Joined: Sun Jul 12, 2015 2:30 pm
Location: Bavaria, Germany
Contact:

Trader AI

Post by Fritz »

After having watched and followed freighters and freighter convoys quite often (Pythons, Boas and Anacondas with role "trader"), I came about a serious problem with the AI. To put it short, if these freighters are disturbed by the presence of ships considered to be potentially dangerous, they usually don't resume their original course (to the station) after the threat is gone. They manage to do it sometimes, but the buggy behaviour seems to be more the rule than the exception.

I mentioned it in the thread Traders and offenders, but since the AI behaviour doesn't have anything to do with my original question, I think I belongs here, and I'll repeat some of my observations:

Yesterday I was following a clean Python with one of my paint jobs (so it had to be a trader!) and four escorts to the planet to take some pictures. The convoy was on the standard course, not directly to the station, but roughly in the direction of the planet. Everything was normal and they kept flying in a straight line until they suddenly changed course, probably because there were pirates in the vicinity. After I had destroyed these, I found the Python again, but it didn't resume the old course. Instead it flew around randomly, essentially not changing its position (similar to ships waiting for prey around the witchpoints). With the escorts following neatly, the turns looked like some artistic formation flying, but it was certainly not what a trader should do!

Another case, this time a clean trader Python without escorts. I met it while it was travelling through pirate-infested space but not being attacked directly. I followed it, and it went on and on, the destination being somewhere in outer space (neither planet, nor sun, nor witchpoint, nor rock hermit). After some time I noticed that it hadn't a destination at all: It didn't fly in a straight line, instead it made a very slight change of course exactly every 40 seconds by pulling up perhaps 1 or 2 degrees. - After a while I forced it to change it's course by coming very near, but the described behaviour continued after it had settled on a new course. After this change I noticed that it was making little roll movements as well. After some hours, the described behaviour would put the ship in a very big spiral.

I can be sure that they are traders because of a ship-naming OXP, and I don't have any OXPs installed that should affect trader behaviour even remotely.

I've followed many other ships in the past days, but I'm still not sure what is happening. Some observations:
  • The probability that a freighter resumes it's course to the station seems to be bigger when the disturbing ships are destroyed (by me) while the freighter is still in scanner range.
  • Traders seem to consider clean assassins and possibly even headhunters as a threat. Since these often lurk around the witchpoint, freighters arriving at this location are stuck there quite often, especially because their evading course (as described in the blue text) eventually brings them back near the witchpoint.
  • There seems to be a difference between ships considered as a vague threat (assassins, "harmless" offenders?) and ships considered to be attacking pirates. In the latter case, the freighters fly a "wobbly" course, probably to make aiming more difficult from a distance.
  • What the freighter will do (as described in the blue and green texts) seems to be random, but I have the impression that the lurking (blue) case is more probable in the vicinity of a witchpoint.
  • Having an escort or not doesn't seem to affect behaviour.
I noticed three scenarios of how traders are added to the game:
  • The trader is spawned somewhere between witchpoint and station during system population.
  • The trader is spawned around a station (or is launching from it), jumps to another system, and the player follows him through the wormhole.
  • The trader is spawned around the witchpoint shortly before or after the player arrives on his own.
I've observed the anomalies in all three cases, so it probably doesn't matter.

For normal gameplay this bug doesn't matter much, and that's probably why nobody noticed. Most players will either avoid the freighters because of the mass locking, or attack them if they are playing the role of a pirate. But the bug should reduce the number of freighters arriving at a station, waiting for clearance, and docking. Apart from safe or thinly populated systems, only freighters spawned near to the planet will ever make it to the station, the rest flies off into outer space or forever around some invisible point.
"You wouldn't kill me just for a few credits, would you?" – "No, I'll do it just for the fun!"
Fritz
---- E L I T E ----
---- E L I T E ----
Posts: 591
Joined: Sun Jul 12, 2015 2:30 pm
Location: Bavaria, Germany
Contact:

Re: Trader AI

Post by Fritz »

After some more testing and observations, and after looking into oolite-traderAI.js and role-categories.plist, I can explain some (but not all) of the strange behaviour.

One fact is: Traders are afraid of assassins, so they go into "avoidance mode" at every witchpoint where an assassin is waiting, and that's quite often.

The second problem is the player himself (that's me while observing the "strange" trader behaviour!): If I'm assumed to have the role "player-unknown", I'm treated and avoided like a pirate. Does my unknown status change into some kind of "player-friendly" when I kill an assassin or pirate in the vicinity of a trader? That would explain why destroying the disturbing ships often gets the freighters on course again.

The wiki says about "roleWeights": "An array of the player's current role as perceived by the game. Generally NPCs will pick a random entry from this list and treat the player as if they were an NPC of that role. The 'player-unknown' role is the default role. The size of the list depends on the player's current Elite ranking.". So there is a randomness affecting this role, and that would explain, why many of the traders aren't bothered by my presence, but some are.

But if the player is the disturbing ship, getting out of scanner range doesn't "reset" the trader, at least not in all cases. I've watched traders stopping just outside of my scanner range, but not going away for a destination. This behaviour can't be explained by the contents of the two mentioned files.

If I'm following a trader that is regarding me as somebody to avoid, he will show the "green" behaviour (see the green text in the previous post): He doesn't go for a destination, he just flies in a random direction, changing his course slightly from time to time. This behaviour seems completely senseless: If you are unsure if a bad guy is following you, and you can't outrun him, the best strategy would not be to go into outer space. where nobody will help you, but to try to reach a safe station as fast as possible!

The same can be said about avoiding assassins at the witchpoint. Why do the traders fly in some random direction and - even worse - change course in a manner that will eventually bring them back to the witchpoint, i.e. back to the dangerous ships? Why don't they simply fly in the direction of the planet, as any player-trader in a lightly armed ship would do? Or fly in a random direction until the assassins are out of range, and then turn for the planet?

Apart from the flawed avoidance strategies (this seems to be hard-coded, controlled by ai.behaviourLeaveVicinityOfTarget), it seems unnecessary to avoid assassins in the first place. Traders are no target for them, and they will not attack an innocent ship (at least I have never been attacked by an assassin before I started to accept contracts, so it is at least very unlikely).

The "player-unknown" is more difficult to handle because he could be a pirate. But why avoid him when he is clean? Most clean ships are kind of unknown, and assuming that everybody is a pirate isn't a very useful strategy, especially when you have a well armed escort. And if the player reputation is trader-friedly, there is even less reason to avoid him. I have definitely never acted as a pirate or an assassin, and I've helped many traders against pirates, so why does any trader fear me?

So, apart from the strange avoidance strategies, much of the seemingly "buggy" behaviour is caused by traders fearing almost everybody including "good" players. And all of this is completely independent of the number of escorts. I've seen an Anaconda with six escorts turning away from an Adder!

My conclusions are:
- ai.behaviourLeaveVicinityOfTarget should be changed to get the traders actually away from the feared ships or, in case of somebody following but not attacking, as fast as possible to the nearest station.
- A simple solution for the unnecessary avoiding of player-unknown and assassins would be to simply remove these roles from the avoidance list in role-categories.plist.
- A more complex solution would be to make "fear level" and behaviour dependent from the weapons of the trader and its escort. A poorly armed Moray could be more careful than a Python with military lasers and four escorts.
"You wouldn't kill me just for a few credits, would you?" – "No, I'll do it just for the fun!"
Fritz
---- E L I T E ----
---- E L I T E ----
Posts: 591
Joined: Sun Jul 12, 2015 2:30 pm
Location: Bavaria, Germany
Contact:

Re: Trader AI

Post by Fritz »

Another strange observation: An Anaconda was kept in a kind of "evading mode" by a derelict Python. I don't know if the Python had been shot into this state by the Anaconda but it seems possible because there was no other ship around. After I had destroyed the Python,the Anaconda immediately continued with her journey.
"You wouldn't kill me just for a few credits, would you?" – "No, I'll do it just for the fun!"
Post Reply