Targeting logic

For code related discussions and questions
raycast
Trained
Trained
Posts: 131
Joined: 12 Sep 2012, 19:16

Targeting logic

Post by raycast » 27 Oct 2012, 22:01

See http://developer.wz2100.net/ticket/3748 for a patch to (hopefully) improve targeting a bit.
Please help test the patch, and report which behaviour you like better.

User avatar
Stratadrake
Trained
Trained
Posts: 197
Joined: 07 Sep 2008, 09:43
Location: Pacific NW
Contact:

Re: Targeting logic

Post by Stratadrake » 28 Oct 2012, 21:40

Interesting. This is definitely a bug caused by the "prophetic" target accuracy quirk.

As far as I'm concerned, conceptually speaking:
* If there is only one possible target in the area and it is "probably doomed", the unit should wait for the projectile to actually impact before shooting another but it must not ignore the target entirely. The downside comes with homing weaponry a.k.a. SAMs - a VTOL may be out of targetting range by the time said impact occurs.
* If there are several possible targets, or a specific attack queue of targets, the unit is free to ignore "probably doomed" targets in favor of other targets readily available.
Strata @dA, @FAC

raycast
Trained
Trained
Posts: 131
Joined: 12 Sep 2012, 19:16

Re: Targeting logic

Post by raycast » 29 Oct 2012, 11:47

When the incoming projectiles miss, the target will already no longer be "probably doomed". Since I assume the "fire sequence" is deterministic, it is likely that the very same artillery will try again and again. Even if a fast-reloading nearby weapon would have much better chances of hitting.

The logic my second patch implements is as follows:
* If the weapon is indirect, and the target is probably doomed, it will not be shot again immediately
* Otherwise, if the target is probably doomed, it will be given a priority penalty, so that other targets are preferred

However, this is not yet optimal. Assume you have an array of non-indirect slow-reloading weapons. Say Gauss cannons or Scourge missiles (which are "direct" I believe?). Now an army consisting of a lone cyborg and a dozen heavy weapons arrives. The cyborg will receive all the scourge missiles, and then there is the reload pause. And well, cyborgs are cheap.

By taking the reload time into account, and instead of testing on the indirect status, this could IMHO be further improved.
* If the weapon has a reload of larger than X, and the target is probably doomed, it will not be shot again immediately
* Otherwise, if the target is probably doomed, it will be given a priority penalty, so that other targets are preferred

If the threshold is appropriately, only one scourge or gauss would fire the cyborg (which would make it "probably doomed"), the other would wait and then fire on the main battle group.

User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Targeting logic

Post by aubergine » 29 Oct 2012, 17:18

Is this not killing off the tactic of sending cannon fodder troops ahead of a main attack force - so the cannon fodder take the hit and thus chances of main attack force getting to target are increased?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

raycast
Trained
Trained
Posts: 131
Joined: 12 Sep 2012, 19:16

Re: Targeting logic

Post by raycast » 29 Oct 2012, 17:39

Not completely. You just need enough cannon fodder. And seriously, it is not realistic to have 20 scourge towers fire at a single cyborg coming in range, when they might even see the army waiting just behind it...

User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Re: Targeting logic

Post by Shadow Wolf TJC » 29 Oct 2012, 23:18

@raycast: Actually, could you make it so that higher rate-of-fire weapons get much higher attack priority on "probably doomed" targets (regardless of whether they're direct or indirect fire weapons, since some indirect fire weapons are short-ranged, like MRAs, Seraphs, and even Mortars in some cases) than lower rate-of-fire weapons, since they could better afford to miss their targets, regardless of their range? I personally wouldn't want to see my Lancers shoot at anything that would've died from a shot from a weaker but higher rate-of-fire weapon, such as an Assault Cannon, Minipod, MRA, or Ripple Rocket salvo.
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100

raycast
Trained
Trained
Posts: 131
Joined: 12 Sep 2012, 19:16

Re: Targeting logic

Post by raycast » 30 Oct 2012, 10:44

The attack priority is per-attacker, not per-target. And it needs to execute often and fast. I've been wondering whether maybe high-damage, low-rate weapons should fire first, or low-range (as they have a smaller choice), but all that requires sorting, and that probably messes up things or is too slow. The "don't attack if doomed and you are low-firing-rate" should at least be as cheap computationally as the current code.

A more advanced logic could e.g. take into account whether there are units about to come into firing range (with an ETA less than reload time), but all that likely wastes CPU we could better use otherwise.

User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Targeting logic

Post by aubergine » 30 Oct 2012, 19:32

With the current RC3 my personal feeling is that the way base defences are working is much too clinical. It's a war game and I expect war to be messy. As such, I wouldn't expect base defences to be overly smart - they see something, they shoot, unless it's obvious that the target is about to die because loads of stuff already shot at it.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Re: Targeting logic

Post by Shadow Wolf TJC » 30 Oct 2012, 20:42

raycast wrote:I've been wondering whether maybe high-damage, low-rate weapons should fire first
Certainly, unless another weapon nearby could finish the target off with less firepower. No sense wasting Lancer rounds on an almost dead tank when a Minipod or Light Cannon could finish it off instead, and/or when there's a juicier target around in the form of a healthier tank.
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100

raycast
Trained
Trained
Posts: 131
Joined: 12 Sep 2012, 19:16

Re: Targeting logic

Post by raycast » 30 Oct 2012, 23:19

Shadow Wolf TJC wrote:Certainly, unless another weapon nearby could finish the target off with less firepower. No sense wasting Lancer rounds on an almost dead tank when a Minipod or Light Cannon could finish it off instead, and/or when there's a juicier target around in the form of a healthier tank.
At which point, we pretty much have the bin packing problem, which is NP-hard. Once per tick... (well, n should be somewhat small, and we can use heurisics) :lecture:

Seriously, this likely won't be fast, or at least it will require fine tuned heuristics and likely some major incompatible changes to the way data is organized (e.g. keeping unit and structure lists sorted by firepower or unit health etc.). I'd definitely aim for the much simpler solution I outlined before, which we can essentially add for free. At least for 3.1, a more complex solution could then come much later if the simple one still is unsatisfactory.

raycast
Trained
Trained
Posts: 131
Joined: 12 Sep 2012, 19:16

Re: Targeting logic

Post by raycast » 31 Oct 2012, 21:24

Here's another iteration of the patch. I havn't play tested it yet, so it might not work.

Behaviour of this patch is as follows:
  • If target is not yet doomed, consider as before.
  • If target is doomed and (upgraded) ROF is larger/equal 21, consider with a penalty of 10
  • If target is doomed and (upgraded) ROF is smaller than 21, ignore as before.
21 was a guess from the weapons list in the guide. For upgraded weapons, that seems to be roughly the tradeoff for my favorite weapons. I hope the numbers from the guide and the game align... According to the guide, a fully upgraded Hellstorm has a ROF of 24 (up from 12). A Pepperpot starts at 33. A scourge missile tower has 11.5 - 20.9, a pulse laser 15-27.3, rail 12-21.8, Gauss 10-18.2, Medium Cannon 15-37.5, Heavy Cannon 10-25.

Remember that weapons over the threshold will still prefer a different unit when in range.

So a number of weapons will - when fully upgraded - overkill targets. But usually that will only give you half a second to get extra units in range, fire, and retreat.
Attachments
patch3.diff
Fixed patch. if was the wrong way.
(4.87 KiB) Downloaded 254 times
Last edited by raycast on 01 Nov 2012, 13:39, edited 1 time in total.

User avatar
Avestron
Trained
Trained
Posts: 314
Joined: 03 Jul 2009, 02:23

Re: Targeting logic

Post by Avestron » 31 Oct 2012, 23:50

A few comments - forgive the intrusion.

One thing I should point out here is that that 'almost dead' or 'doomed' tank with lancer weapon might be pointing at your buddy in similarly worse shape. Regardless of all the math, I'd say its plausible that any but the most stoic of tank drivers would spend a little more ammunition than strictly necessary to silence that tank's weapons.

On the other hand it would be nice if a tank faced with a number of targets has a 'possibility' of shifting targets temporarily every now and then. I'd still expect more rounds to land on the weaker target but it'd be great to avoid a situation where a single tank is pelted into bad shape while a pack of associates still have polished armoured shells with narry a scratch.

It would also be nice, being presented with a choice of targets, having the largest threat being singled out as a prime target for firepower. This would allow larger, heavier armed targets to soak some damage for the lighter bodied associates.
Image

raycast
Trained
Trained
Posts: 131
Joined: 12 Sep 2012, 19:16

Re: Targeting logic

Post by raycast » 01 Nov 2012, 11:46

There is quite a logic in place for choosing the most appropriate target. This involves how much the targets are damaged and such. Please have a look at the code to see the details for yourself.

Note that if you have a good defense set up, it will probably involve some high-rate weapons such as assault guns. They will try to finish off doomed enemies, too. The single one thing that I'm trying to get is to strike a better balance between: A) all turrets firing at the first unit coming in range, even if that means 20 scourge missile on a single cyborg (in earlier WZ versions), and B) only a single remote artillery firing at the unit, and then maybe even missing, while a nearby MG bunker refuses to shoot the cyborg (current WZ) as it is considered doomed. Which is why I tried to just use both approaches, but for different weapons. Slow-reloading weapons will wait for projectiles to impact, high-rate weapons will try to kill as much as possible.

But again, for doomed targets I assign a penalty. The existing priority logic may or may not prefer a different target. It might decide that the attacker is so badly damaged that it can be finished of with a single shot and thus goes for this, even when the target is already considered doomed. Or it may decide that the next incoming unit is a much larger threat and instead give the cyborg that extra seconds until it is probably squashed by an artillery shot. It depends on various things, including short/long range, damage etc.

raycast
Trained
Trained
Posts: 131
Joined: 12 Sep 2012, 19:16

Re: Targeting logic

Post by raycast » 01 Nov 2012, 12:18

On a side note, the walkthrough suggested to use decoy buildings in some situations. I.e. place a turret in some place to draw fire, but not bother to finish it. Judging from the code, this doesn't work well anymore. Unfinished buildings get a penalty, so they should be mostly shot at if there is nothing else in range. Of course some people will cry that it disables one of their favorite tactics, but others will consider it reasonable. In particular, when you are attacking some base or outpost, chances are that you can kill some trucks that are just trying to build extra defenses. Clearly, the trucks should be the primary target for everything than the most stupid AI.

One thing that concerns me is the doomedness prediction. AFAICT so far, it does not yet take the accuracy into account. There are some weapons where you know you barely get the full damage, but indirect damage is also okay (albeit much lower). Roughly said, if you have a weapon with 60% accuracy and ~120% strong enough to kill the incoming VTOL, I belive only a single shot will be fired. But with this accuracy, two shots would be smarter.

User avatar
Iluvalar
Regular
Regular
Posts: 1819
Joined: 02 Oct 2010, 18:44

Re: Targeting logic

Post by Iluvalar » 02 Dec 2012, 19:01

interesting cludge. But when the accuracy roll declare it's a hit, the reality should bend to his will. Otherwise we have huge glitches appearing everywhere. And a total incapacity to balance the game.
Heretic 2.3 improver and proud of it.

Post Reply