Anisoptera Games

Some Basic AI Improvements
Page 1 of 1

Author:  Three1415 [ Tue Jun 14, 2016 8:54 pm ]
Post subject:  Some Basic AI Improvements

Allow me to preface this by stating that the AI in Reassembly is far from bad. Indeed, it should be applauded for being so versatile, and able to handle such a large number of ship and weapon types. But I believe the majority of players who compete in tournaments can attest to the fact that the AI can contribute to significant frustration when testing, as it often feels as if one is fighting against, rather than working with, the AI when trying to make a combat-effective fleet.

There are a number of factors that contribute to this that I've identified; resolving these issues entirely would no doubt require a very significant quantity of development time, and with that consideration in mind I have pinpointed three major problems that significantly impair AI performance but should be (at least with my limited knowledge of Reassembly's internal structure) fairly easily resolved.

Remove execution behavior from any ship with the ATTACK flag

For those that might not know, execution behavior is initiated whenever the AI targets a damaged ship that has lost its weapons. It will cause the attacking ship to close to its minimum weapon range, and only upon reaching it will the former actually attempt to fire and destroy its target. Understandably, this can result in problems in fleet-on-fleet battles in tournaments, with many ships potentially charging in towards certain doom for no good reason (after all, it's not as if executing a ship that one has been successfully destroying up to that point will really accomplish anything other than putting one's own fleet at risk).

Because, as far as I know, ships in tournament mode are the only ones to utilize the ATTACK flag, simply removing this behavior from there should be fairly easy and not result in any loss anywhere else in the game, and can really only be beneficial to performance.

Adjust the effective range computation on the AI

Admittedly I am not entirely sure how the AI computes the effective weapons range of the ship it is currently on, but I have observed that this value appears to be capped to about 2400 (assuming the sandbox displays the actual number), regardless of the true range of any equipped weapons, up to and including Tinkrell cannons. Likewise, even if short-range weapons, such as lasers, are set to PD, they appear to still diminish this value, and missiles, regardless of their effective range, don't seem to contribute to it at all. This makes building functional kiting ships quite difficult, and thus such efforts largely require coercing the AI into moving backwards against its will (e.g., using Tinkrell cannon recoil, providing it only rear-facing turning thrusters, etc.).

I've seen the AI settings options in the bindings window (although, unless the latest version changed something, they don't appear to do anything significant yet), so I know this is probably in the process of being implemented, but just removing the range cap, removing contributions from PD weapons, and giving missiles a "range" of sorts internally should significantly help.

Improve the targeting algorithm

This is the biggest of the non-flight-related issues, and probably the hardest one to actually fix. Right now the AI just targets whatever ship is closest to the command core, which can lead to ludicrous behavior such as your entire fleet chasing a single 40P distractor while getting slaughtered by the remainder of one's opponents'. A weighted algorithm that scans across all enemy ships and selects targets via a combination of range and P would be a significant improvement, and one that would probably not impose too much of a performance hit except in very large battles, especially if the search were only performed every few ticks. Here's a general outline of what I have in mind (although, again, I know comparatively little about how Reassembly operates internally):

1-Assuming there's some way of grabbing all ships in the arena at one time, select from all enemy ships.
2-Get each enemy ship's P value and its range with respect to the host ship
3-Apply some sort of weighting to each involving that data (e.g., my suggestion would be to give a ship a priority of p = enemy_ship_P_value/(enemy_ship_range)^2/3)
4-Either choose the ship with the highest priority, or normalize all priorities (such that they add up to 1) and make a random weighted roll to select a target.

Such a weighting would bias the AI towards focusing on more substantial, if farther away, targets, which should limit the efficacy of distractor ships (although no doubt more fine-tuning of the weighting algorithm would be necessary). An additional layer of complexity could factor in the range and damage output of enemy ships to better prioritize a target.

These changes would, in my opinion, go a long way towards improving the AI generally, and should hopefully not be too difficult to implement in a reasonable length of time.

Finally, is there any way to access the AI code for modding potential? Attempting to improve the AI is something I would gladly undertake personally, so it would be great if there were some way to alter it. Of course, I understand if you wish to keep Reassembly's internals hidden, but it would definitely be something I would take a look at if given the chance.



Author:  ★ Conga ★ [ Mon Jun 27, 2016 1:02 am ]
Post subject:  Re: Some Basic AI Improvements

I can agree with this~

Author:  danny420dale [ Mon Jun 27, 2016 7:16 am ]
Post subject:  Re: Some Basic AI Improvements

Thirded on all counts.

Author:  MonsPubis [ Sun Jul 31, 2016 6:01 pm ]
Post subject:  Re: Some Basic AI Improvements

I was just getting ready to make one of these, and much to my delight this one is still at the top and well worded. I would like to add some things though:

Three1415 wrote:
execution behavior

Absolutely agreed. This behavior alone has caused more than a few tournament upsets. "Well, we crippled this one, everyone charge it!" This was at its worst with melee spike-covered trollships. You would watch entire fleets suicide into them. Tagging the melee spikes as weapons seems to have helped, but the behavior can still be seen. It also seems to proceed to execution range against any ship with significantly lower deadliness than itself, even if it has no reason to (i.e. ships with only drones as dedicated weapons).

Three1415 wrote:
effective range

Additionally, if the enemy's effective range is greater than my own, that shouldn't mean I engage at point blank. I see this pretty often. I also think weapons in the third category, the automatic firing ones, should not count in effective range. This would cause ships to more accurately emulate player behavior. Ships approaching a target should not travel directly at it, but at a tangent of distance equal to their effective range, unless trying to ram. This would stop a lot of the silliness with little ships careening into big ones and getting ruined. Finally, do Tinkrell guns count just the cannon's range, or does it include all the modules as well? Because from the best I've been able to tell, they only regard the cannon's default range.

Three1415 wrote:
target selection

I think it should also be weighted by the deadliness of the ship doing the selection. Smaller ships should prefer to fight smaller ships, for example, before proceeding to larger ones. Or perhaps a secondary dropdown in the ship bindings to select smaller, larger, similar, or any size opponent. To coopt your formula:

priority = (enemy_ship_P_value-difference_in_P_value)/(ship_range^2/3)

Author:  danny420dale [ Mon Aug 01, 2016 7:44 am ]
Post subject:  Re: Some Basic AI Improvements

I'm not sure about range on Tinkrell guns, but lead calculation for them seems to account for weapon mods that change projectile velocity better after one of @Arthur's recent updates. This change seems to have propagated to other species using weapon mods, such as Voltaire and Marklob.

Author:  danny420dale [ Fri Oct 14, 2016 9:28 am ]
Post subject:  Re: Some Basic AI Improvements

Suggestion for new AI flag: [SHOTCHARGE] and have it set a coefficient between 0 and 1 that would tell the AI what charge its 'preference' to fire any charging weapons would be. 0 would be as-is where the AI attempts to spam minimum-charge shots as rapidly as possible after the first shot. 1 would be 'charge every shot to maximum before firing'. Numbers between 0 and 1 would be the difference between mincharge and maxcharge the AI would 'prefer' to shoot.

Another idea is [SMARTCHARGE] which adjusts the coefficient higher or lower for bigger or smaller targets. Not sure if target P or mass is better for calculating this.

Author:  The_Patrician [ Tue Nov 08, 2016 3:01 am ]
Post subject:  Re: Some Basic AI Improvements

Personally, and I have an extremely limited experience with code so I have no idea how difficult this would be, I understand build-able AIs the best.

AIs which have a variety of components and inputs such as "(If [R] [>] [1000], then spawn [ShipName / SlotNumber])"
Where all the parts in square brackets [] are editable by the player in-game.

These sorts of AIs I really understand and enjoy because they are easily customize-able and versatile. Then you simply add a priority system and viola!
You could have something like:

If [Enemy] = [Less P than] [1000] then [snipe/attack]
If [Self] = [Nearer to] [Ship:Example] then [Heal]
Or even, If [Enemy] = [Less Distance than] [500] then [rush]
If [Enemy] = [More Thrust than] [100k] then [kite]

Something like that. I feel it would really help though again, don't know how hard that would be to make.

On a final note, even something as simple as a basic 'follow unit X' and 'target unit Y' command, where you can set up formations of ships, would make a massive difference to how people build and structure their fleets.

I think it would be awesome.

Author:  McEw [ Fri Oct 12, 2018 12:05 am ]
Post subject:  Re: Some Basic AI Improvements

Some points based on my own experience:

1. Take into account thruster placement to decide optimal maneuvering strategy, maybe even change overarching behaviour based on thruster placement. Use absolute direction logic for maneuvering, taking into account maximum thruster efficiency. Move like a crab if must.
If more backwards thrusters than forwards are placed/left, while most weapons faces frontwards, consider maneuver or kite instead of rush. Because it’s not like you’ll be moving forwards a lot.
If not enough thrusters to reach a certain speed while enemy out speeds you, If more dps can be achieved on the spot, instead of charging closer at risk of exposing flank/not using weapons, consider maneuver instead of rush, prioritising using thrusters to pivot and turn so largest dps of weapons are constantly trained on target.
Weapon-on-target priority over move. Secondary priority to get out of weapon-on-target capability of enemy (dodge). If enemy is about to get into range to out-dps you, but which you can fix by moving slightly out of range, attempt to kite and move out of range for a bit.
Unless damaged, in which case if it will not sacrifice too much dps, sometimes consider turning still-armoured sections towards enemy instead of exposing valuable modules like shields/weapons/etc.

So an example of a ship doing all the above points is a ship that moves sideways to get into firing range because it had more sideways thrusters than front/back, pivots to fire, then pivots to speed back out sideways as the enemy moves in to bring weapons to bear. After one of its flanks is heavily damaged, but with enough thrusters to still maneuver effectively towards the other sideways side, it changes its sideways maneuver direction with its still-armoured side facing enemy.

2. Take into account weapon hit probability based on recognition of enemy stats.

If enemy ship is fast, prioritize hit-chance weapons (ie. fast projectile speed, instant hit, fire uptime) if enemy tries to stay st range, prioritize ranged weapons. If enemy is armoured, prioritize dps unless too much negative pointer on enemy out-dpsing you at close range. Bring your most efficient weapons to bear over lesser ones, changing behaviour on the fly.

Fire at any possible targets excluding drones (maybe even drones and missiles but with lesser priority) whenever possible. Take recoil into account. Randomise a bit the target tracking so it can sometimes miss, but will not always lead by too much/pre-fire and completely miss. Take energy usage into account, pause non-crucial weapons if must, as the pointers show.

Basically mark a lot of pointers with either positive/negative rating and have the AI make a qualitative decision based on evaluation of everything combined. A step further (highly advanced) would be to learn in real time how to deal with opponent, ie. pre-move for boxing in and pre-juke in reverse. Bait and trap tactics, or multi-phase tactics, such as charging with armoured section towards enemy, baiting a pre-emoted barrage, then switching direction to bring weapons to bear once safe/in optimal kill range. Retreat back out upon finishing “run” instead of stay within melee range even at risk of exposing wrong direction/sides to enemy. Decide on continuous offensive instead of re-maneuver/ rest and recharge.

3. Take self stats compared to enemy into account.
Since P worth will almost always be the same, take P worth of summarized modular attributes instead of pure P worth. Aka. P worth into maneuvering, weapons, HP worth, make rough offensive/defensive evaluations on the spot. Try to counter this P worth by acting pre-emptively, countering oppponent meta strategy, nullifying their strengths with own capability.

Allow player to define and customize preset AI pointers just as they could build the ship, so AI design is just as much a part of the ship building as ship design. Even set weight for different parts/stages. This will allow for some incredible depth in strategy, and world class competitive potential into these ships, instead of just kite/rush/bulldozer.

Allow players to customize reaction priority based on enemy evaluation too. Highly advanced.

Page 1 of 1 All times are UTC - 8 hours [ DST ]
Powered by phpBB® Forum Software © phpBB Group