[WIP] Captain AI overhaul. Updated 09.12.2014

The place to discuss scripting and game modifications for X Rebirth.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

cicero111
Posts: 108
Joined: Sat, 13. Aug 11, 14:30
x4

[WIP] Captain AI overhaul. Updated 09.12.2014

Post by cicero111 » Fri, 14. Nov 14, 01:04

Captain AI overhaul
============

Installation:
Extract in extensions dir as pr. usual. If alpha is installed, delete that dir (mod was renamed).
Download link:
2.5x version: https://dl.dropboxusercontent.com/u/652 ... _beta2.zip
3.0 version: https://dl.dropboxusercontent.com/u/652 ... eta3.1.zip


What it has:
General movement:
- Move closer at a rough intercept vector
- Ships will behave differently if they have capital wingmen (not rotate so much and stir up formation).
- In zone boosting. Boost if target or position is further than 20KM away. If target is enemy, stop about 12KM away and engage.
- In zone boosting for wingmen. Will boost to catch up if leader is 15KM away. Need to either reassign ships, or move fleet to a different zone to refresh the escort script loop.
-> IZ boost is only enabled for player combat ships for now and is a work in progress.

Shiptypes:
- Balor and Sucellus will hold position and orient weapon toward target (also when target is moving) and break off/gain distance if target get too close.
- All warships (destroyers and "battleships") have custom code to move to and broadside enemy, and standoff/move ranges by type.
- Carriers will try to keep their distance, and rotate to be ready to break off if enemy cap gets too close.
- Tradeships run vanilla code in close combat for now.

General AI:
- Explosion avoidance, will start to move away when target hull gets below 50% and lock the movement for 60s when below 10% to avoid them stopping when target dead to wait for the explosion.
- Panic checks when shield and hull gets damaged. Based on morale + random bonus and amount of damage taken. Will run away if failed.
- "Suicide run" if ship is close to destroyed and target have a lot of hull left. Requires high morale.
-> Xenons will never panic and always do suicide run.
- Path calculations end checks are done in a much faster interval than vanilla (5-10 sec) when enemy is near.
- Cap formation code added to lessen the chaos and allow ships as sucellus to orient ot target. Still some work to do in the escort scripts.

Other:
- Added fix for stuck boosters bug (if this is still an issue in vanilla).

The current version have some output to debug log active to show what the captains are doing, mostly limited to player ships and boosting.

How it works:
Probably have to do a writeup on this sometime..
Mostly using the engine positioning/vectorcode + holding position/rotating ship etc. based on situation, target type and ranges.
The code is sectionized in ship definitions/parameters, AI decisions and shiptype behavior.
Current ship definitions/modes:
- Ranged: Balor, Sucellus
- "Battleship": Arawn, Fulmekron, I
- Destroyer: Taranis, Olmekron, K, Gangrene Chaser
- Carrier: Heavy and Light Sul

Savegame safe?
Treat it as beta code for now.

Compability with other mods:
The mod replaces or changes nodes in the move.attack.object.capital,move.escort.capital, command.move.wait and command.fight.attack scripts.
Mods that don't change anything with the Captain, i.e. don't touch those scripts will work fine.
Don't use the AJD mod whis this one - it's an excellent mod, but causes a lot of weirdness in my scripts.

Todo:
- Code optimizing and cleanup, and I suspect some bugfixing.
- Put it on Steam WS when verified in release state.
- Add some mod compatibility stuff if it's wanted.
- Do some distance tuning for the decision code.
- Do more with skills (threat response, and formation tightness/ chaos based on leadership skill).
- Do a lot more testing/ polishing, especially when it comes to formations...
- Add relevant methods from ego's new AI code when it's released to beta.


Any feedback, tips and ideas would be most appreciated.
This mod will be released with WTFPL when it's done, so if some stuff should be added to complement other mods, just give me a hint and I'll se what can be
Last edited by cicero111 on Fri, 12. Dec 14, 21:48, edited 21 times in total.

User avatar
Sandalpocalypse
Posts: 4447
Joined: Tue, 2. Dec 03, 22:28
x4

Post by Sandalpocalypse » Fri, 14. Nov 14, 05:46

nice.

does it pick out balors and sucellus specifically, or does it scan for weapon slots?
Irrational factors are clearly at work.

Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 8074
Joined: Tue, 30. Mar 04, 12:28
x4

Post by Sparky Sparkycorp » Fri, 14. Nov 14, 08:37

You star :)

I currently use a Sucellus for their beauty and the promise of the ICH working despite it being less effective in vanila than a Taranis so I look forward to trying this after i finish beta testing 3.00. Hoping it makes my choice of ship more rational :)

My only though at the moment is to wonder whether the Taranis could do with a little shaved off its speed but that'snot directly related to this mod (apart from the chase aspect).

linolafett
EGOSOFT
EGOSOFT
Posts: 3321
Joined: Mon, 26. Mar 12, 14:57
x4

Post by linolafett » Fri, 14. Nov 14, 10:40

If feel bad to say, that we actually changed the balor behaviour some days ago in the office. It will now keep its distance and fires its torpedos outside of the laser ewaponrange of stations and ships ;)

cicero111
Posts: 108
Joined: Sat, 13. Aug 11, 14:30
x4

Post by cicero111 » Fri, 14. Nov 14, 11:14

@Sandalpocalypse
It selects Balor and Sucellus specifically and sets some parameters for each. The movement code is generic. This so each one can be tuned a bit for ranges and behavior without too much code duplication.

@Sparky
Have been thinking about different strategy for each ship type. B/S as artillery ofc, taranis as hit&run destroyers maybe, carriers should keep their distance etc. Maybe do some suicide run thing when hull is below x% for captains with high morale too maybe. Been tossing around some ideas - what could be fun are some unpredictability/surprises to what the captain does.
Typical tradeships should look at the opposition and mostly flee I guess.

@linolafett
Really glad to hear this, and I'm also looking forward to take a peek at what's been done - might learn some new tricks with the engine :)
I'm just doing this for fun - to directly see the result of those code snippets in 3D space is fascinating.

Saquavin
Posts: 486
Joined: Thu, 22. Aug 13, 17:12
xr

Post by Saquavin » Fri, 14. Nov 14, 11:47

linolafett wrote:If feel bad to say, that we actually changed the balor behaviour some days ago in the office. It will now keep its distance and fires its torpedos outside of the laser ewaponrange of stations and ships ;)
What about sucellus ? I've never seen my sucellus firing his main weapon :(

linolafett
EGOSOFT
EGOSOFT
Posts: 3321
Joined: Mon, 26. Mar 12, 14:57
x4

Post by linolafett » Fri, 14. Nov 14, 13:19

Asked our AI guy again, the change is currently not live ingame, but on his machine. So not jet to test in the beta.
This change will take weaponrange into account, so all ships with huge weaponranges will not fly close to stations and enemyships, at least they try to avoid them. For a arawn the change might not be visible, but the balor for sure. I dont know about flight pattern changes though, so your mod may be still a nice addition :)

Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 8074
Joined: Tue, 30. Mar 04, 12:28
x4

Post by Sparky Sparkycorp » Fri, 14. Nov 14, 15:24

Thanks for posts Linosoft :)

linolafett
EGOSOFT
EGOSOFT
Posts: 3321
Joined: Mon, 26. Mar 12, 14:57
x4

Post by linolafett » Fri, 14. Nov 14, 15:30

actually it would be linolafat, if the name would be translated :P

Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 8074
Joined: Tue, 30. Mar 04, 12:28
x4

Post by Sparky Sparkycorp » Fri, 14. Nov 14, 17:58

Yeah, I was just joking :)

Kind of thanking both you and your colleague(s) for the reply about AI :)

cicero111
Posts: 108
Joined: Sat, 13. Aug 11, 14:30
x4

Post by cicero111 » Fri, 14. Nov 14, 18:47

@linolafett
Sounds like a lot of changes are coming to the capship AI's - really looking forward to this :D Thanks for the additional info.

User avatar
werewolves?
Posts: 1166
Joined: Tue, 31. Jan 12, 00:58
x4

Post by werewolves? » Sat, 15. Nov 14, 06:40

I would be great if you could figure out a general ship movement so ships don't just stop right next the the enemy they've just blown up to get caught in the blast radius.

cicero111
Posts: 108
Joined: Sat, 13. Aug 11, 14:30
x4

Post by cicero111 » Sat, 15. Nov 14, 15:31

@werewolves?
Have a rough prototype in the works which does such evasion - starts to move away a bit earlier when enemy hull gets below a certain %.
Also have somewhat the opposite where a captain may decide to start a suicide run and try to get as close as possible to the enemy before they explode. This requires high morale or are machine (i.e. xenon), and check happens when their hull gets below x%.

Also have a panic mode implemented where the captain may decide to bravely run away if low morale (xenon will never do this). + are thinking about how to put some additional random madness in there :)
The goal is if the battle is replayed (and observed from a distance) it will not end up the same way twice.

And are working on a framework for different strategy selection based on skill, ship type and opposition among other things - lots of ideas, only some are implemented yet.

User avatar
YorrickVander
Posts: 2689
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander » Sat, 15. Nov 14, 20:56

The major issue I see with current ai is that the movement 'to' position is calculated at far too long an interval. Ships will try to park in their target as the target moves but the move to point is not updated; conversely the attacker can fly past the target by some km and back out of weapon range again....

The second issue is relative speed. watching 2 olmekrons fail to catch a k while it flies to a target in the opposite direction to the defending caps is tragic to watch. EDIT especially since the escort ai is too primitive to take off and maybe knock out some engines to prevent it's escape.

Looking forward to comparing your results with clj's and eventually ES's :)
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 8074
Joined: Tue, 30. Mar 04, 12:28
x4

Post by Sparky Sparkycorp » Sat, 15. Nov 14, 21:08

cicero111 wrote: Also have a panic mode implemented where the captain may decide to bravely run away if low morale (xenon will never do this). + are thinking about how to put some additional random madness in there :)
The goal is if the battle is replayed (and observed from a distance) it will not end up the same way twice.
Sir Robin approves of this :)

http://2.bp.blogspot.com/-893YnvA1d8o/T ... _small.jpg

swatti
Posts: 1278
Joined: Sun, 7. Dec 03, 12:03
x4

Post by swatti » Sat, 15. Nov 14, 21:09

Sucellus VS Xenon K

Sucellus runs at full speed while trying to turn towards its target, this is the fail.
An artillery needs to stay put and turn towards its target. If not in range by then, move closer, if in range, let em have it and reverse if target still coming towards you. Once too close, full throttle and do a fly-by to gain x-distance. Then again, turn in place and use the range.

wwdragon
Posts: 3746
Joined: Mon, 1. Oct 07, 02:18
x4

Post by wwdragon » Sat, 15. Nov 14, 22:44

I'm so happy to see this topic got us the info about Egosoft people making those siege ship changes. :D
Editing posts since long before I remember.

Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 8074
Joined: Tue, 30. Mar 04, 12:28
x4

Post by Sparky Sparkycorp » Sat, 15. Nov 14, 22:56

Me to. Fresh pancakes for cicero111 :)

cicero111
Posts: 108
Joined: Sat, 13. Aug 11, 14:30
x4

Post by cicero111 » Sun, 16. Nov 14, 15:08

@YorrickVander
Yup, that long update interval does not work good in "close combat" situations. Are experimenting with different strategies, update intervals and interrupts based on ranges, ship type and hull/shield states on both sides.
On close range evade strategy (enemy hull below 15%) I've removed the target destroyed interrupt to avoid them stopping to take a close look at the explosion if no new targets, and using a fixed "runaway" timer instead.

@swatti
The mod should do this + are coming in ego's new AI package too.
Ranges for Sucellus in current alpha is:
Maxdistance: 7500
Holddistance: 3500
Minimum distance: 1000.
For station targets the ranges are increased with 2KM.
It will prefer to be between max and hold distance ranges (hold position/rotate to target), start reversing when between hold and minimum, and break off and try to gain distance when below minimum. Have changed minimum range to 2KM in the version I'm working on now.

swatti
Posts: 1278
Joined: Sun, 7. Dec 03, 12:03
x4

Post by swatti » Sun, 16. Nov 14, 18:15

Was this changed just now or?

Cause mine wasnt staying put but instead flying at the target, slightly orbiting it and then bumping into it.

Post Reply

Return to “X Rebirth - Scripts and Modding”