Proposed Change to Flee AI

General discussion for players of Oolite.

Moderators: winston, another_commander

another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 5397
Joined: Wed Feb 28, 2007 7:54 am

Proposed Change to Flee AI

Post by another_commander » Sun Jul 15, 2018 7:17 pm

Following up on the discussion in this topic, I have made some tests with a slightly modified flee AI and I was quite happy with the result. I therefore submit this change for your further testing and consideration.

The change applies to ships with accuracy greater than 0. Dumb ships will continue to act dumb and flee in straight lines, but more often than not, you will be encountering pilots who will react more like a normal pilot would. "Clever" NPC pilots now check your position against theirs when fleeing and, if they feel that they are sitting in your sights, they will attempt to react. Most of the times they will try to jink more in order to get out of the way of your guns, but sometimes, in an act of desperation, they will turn and try to land a few hits on their attacker, hoping to surprise them. Current probability is 65% continue fleeing, 35% go evasive and consider an attack and they are open to suggestions.

The change required to test this:
Function performFlee in ShipEntityAI.m is changed to:

Code: Select all

- (void) performFlee
{
	if (behaviour != BEHAVIOUR_FLEE_EVASIVE_ACTION)
	{
		behaviour = BEHAVIOUR_FLEE_TARGET;
		[self setEvasiveJink:400.0];
		frustration = 0.0;
		if (accuracy > COMBAT_AI_ISNT_AWFUL)
		{
			double aspect = [self approachAspectToPrimaryTarget];
			// alert! they've got us in their sights! react!!
			if (aspect > 0.9995 || aspect < -0.999)
			{
				behaviour = randf() < 0.35 ? BEHAVIOUR_EVASIVE_ACTION : BEHAVIOUR_FLEE_EVASIVE_ACTION;
			}
		}
	}
}
Test binary for Windows x64 here.

User avatar
gsagostinho
---- E L I T E ----
---- E L I T E ----
Posts: 563
Joined: Sun Jul 19, 2015 1:09 pm

Re: Proposed Change to Flee AI

Post by gsagostinho » Sun Jul 15, 2018 8:11 pm

I will test this later tonight and report back. Thank you so much for taking a look at this!

another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 5397
Joined: Wed Feb 28, 2007 7:54 am

Re: Proposed Change to Flee AI

Post by another_commander » Sun Jul 15, 2018 8:17 pm

Thanks, looking forward to seeing the results. For completeness, there is one more small change that has been made in order to generate the test executable and I forgot to mention earlier. In the method setEvasiveJink in ShipEntity.m, the line that reads

Code: Select all

if (accuracy >= COMBAT_AI_IS_SMART)
has been commented out. Now all non-dumb ships do proper jinking manoeuvers.

User avatar
gsagostinho
---- E L I T E ----
---- E L I T E ----
Posts: 563
Joined: Sun Jul 19, 2015 1:09 pm

Re: Proposed Change to Flee AI

Post by gsagostinho » Sun Jul 15, 2018 8:21 pm

Out of curiosity, what is the distribution of dumb ships in the game? How is accuracy set for the default NPCs? Is that dependent on the type of system?

User avatar
gsagostinho
---- E L I T E ----
---- E L I T E ----
Posts: 563
Joined: Sun Jul 19, 2015 1:09 pm

Re: Proposed Change to Flee AI

Post by gsagostinho » Sun Jul 15, 2018 9:42 pm

Hmm, I just realized now that these modifications are for the source code and not for any game files post-compilation, right? I am quite unfamiliar with Oolite compilation and this might take me a while to figure out. Sorry about that!

User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 13652
Joined: Sat Jul 04, 2009 9:31 pm
Location: Corke's Drift
Contact:

Re: Proposed Change to Flee AI

Post by Cody » Sun Jul 15, 2018 9:47 pm

Simply drop the .exe into your (Windows x64) Oolite build, and run it (probably requires Oolite trunk).

User avatar
gsagostinho
---- E L I T E ----
---- E L I T E ----
Posts: 563
Joined: Sun Jul 19, 2015 1:09 pm

Re: Proposed Change to Flee AI

Post by gsagostinho » Sun Jul 15, 2018 11:06 pm

Hadn't realized there was a link to a compiled exe file. Thanks Cody!

User avatar
phkb
Commodore
Commodore
Posts: 2415
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: Proposed Change to Flee AI

Post by phkb » Mon Jul 16, 2018 5:55 am

I'm looking forward to trying this out this afternoon! Thanks, a_c!

another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 5397
Joined: Wed Feb 28, 2007 7:54 am

Re: Proposed Change to Flee AI

Post by another_commander » Mon Jul 16, 2018 12:27 pm

gsagostinho wrote:
Sun Jul 15, 2018 8:21 pm
Out of curiosity, what is the distribution of dumb ships in the game? How is accuracy set for the default NPCs? Is that dependent on the type of system?
Hard question. Each ship type has its accuracy set by different parameters. Some (like pirates) depend on system governments and some others have their accuracies set based on generic expectations (like trader opportunitsts and hunters belonging in a pack expected to generally be good pilots). There is plenty of randomness involved too.

Check oolite-populator.js in the core scripts folder for occurrences of the _setSkill(ship, bias) method. That's where the magic happens.

another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 5397
Joined: Wed Feb 28, 2007 7:54 am

Re: Proposed Change to Flee AI

Post by another_commander » Mon Jul 16, 2018 12:37 pm

Oh, and btw, core ships' AI does not go beyond 5.0. If you want higher level AIs, you need to OXP it.

User avatar
gsagostinho
---- E L I T E ----
---- E L I T E ----
Posts: 563
Joined: Sun Jul 19, 2015 1:09 pm

Re: Proposed Change to Flee AI

Post by gsagostinho » Mon Jul 16, 2018 12:43 pm

Thanks for all the info. I still did not have the chance to test that executable but I will do so tonight.

User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 1343
Joined: Thu Jun 20, 2013 10:22 pm

Re: Proposed Change to Flee AI

Post by Redspear » Mon Jul 16, 2018 5:35 pm

another_commander wrote:Most of the times they will try to jink more in order to get out of the way of your guns, but sometimes, in an act of desperation, they will turn and try to land a few hits on their attacker, hoping to surprise them. Current probability is 65% continue fleeing, 35% go evasive and consider an attack and they are open to suggestions.
Nice idea but IMHO 35% seems a tad high for a potentially suicidal 'act of desperation'.
Realistically 10% might even be too high but if one assumes that such behaviour might make combat more interesting then it should perhaps happen once in a while rather than once in a blue moon.
"With our thoughts, we make the world" :-) - - - Game too slow for you? Masslock Compensators - - - Trouble getting out of trouble? Indestructible Injectors

another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 5397
Joined: Wed Feb 28, 2007 7:54 am

Re: Proposed Change to Flee AI

Post by another_commander » Mon Jul 16, 2018 8:48 pm

Redspear wrote:
Mon Jul 16, 2018 5:35 pm
Nice idea but IMHO 35% seems a tad high for a potentially suicidal 'act of desperation'.
Realistically 10% might even be too high but if one assumes that such behaviour might make combat more interesting then it should perhaps happen once in a while rather than once in a blue moon.
Remember that the 65-35 percentages are not based on the total of ships you encounter, but on the ships that will be directed to use the bits of the new AI. Some ships still fly straight when fleeing and from those that don't, 35% may chose to break the run and attack. In reality you should be seeing desperation attacks less often than what it initially looks like.

But let's be sure first that the AI works, then I would be more than happy to drop the flee attacks a little.

User avatar
gsagostinho
---- E L I T E ----
---- E L I T E ----
Posts: 563
Joined: Sun Jul 19, 2015 1:09 pm

Re: Proposed Change to Flee AI

Post by gsagostinho » Tue Jul 17, 2018 1:20 am

@another_commander The behaviour of the AI seems better from what I can tell but I did have some crashes using this executable together with the latest nightly. @phkb did you have more success testing this?

User avatar
phkb
Commodore
Commodore
Posts: 2415
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: Proposed Change to Flee AI

Post by phkb » Tue Jul 17, 2018 2:53 am

I had a couple of long play sessions, where I noted all the different behaviours in action. I didn’t see a lot of the “fly in a straight line” escape option, but I was possibly in a slightly biased environment (mission testing with particular ship roles), so that might not be important. I found I regularly had to break off shooting at a fleeing ship because they were juking under injectors to throw off my aim, and I was getting hammered by other ships who were lining up behind me. In all I found the experience much more satisfying. So, first impressions are positive. I’ll have another go this afternoon and report back again.

I didn’t have any crashes I could link to this change, but then I built my own exe rather than use a_c’s download.

Post Reply