Combat Preferred Targetting

For what's not in 'Top Priority Game Design'. Post your ideas, visions, suggestions for the game, rules, modifications, etc.
Message
Author
Ophiuchus
Vacuum Dragon
Posts: 569
Joined: Tue Sep 30, 2014 10:01 am

Combat Preferred Targetting

#1 Post by Ophiuchus » Sat Aug 18, 2018 12:32 pm

Following the discussions about flak and space boats i had a look at the combat system. I found that a general targetting system could enhance the system in an easy to implement way.

General Design:
  • weapons and space boats get a precision value. Higher precision value means it is more likely to hit an intended target
  • weapons and space boats get a preferred prey condition. This condition specifies intended targets.

FOCS/content interface:
  • weapon and hangar part have a field 'precision' - an integer value ; a value of 1 means no targetting preference; higher values increase chance to hit preferredPrey; default value 2
  • weapon and hangar part have a field 'preferredPrey' - a condition which gets matched against eligible targets; default is to match any target
Ideal Combat System: we dont know what that will be, but the general design and content interface should be ok for many combat systems.

Stop-gap Combat system details:
  • in the combat system there is a random "target dice roll" which target to hit for every shot. precision is interpreted how often a shot may get rolled in order to hit an intended target. Thus if precision is 2 and space ships are preferred prey, and the first target roll is a planet, the target roll is repeated once, more or less doubling the chance to hit a space ship.
  • The preferredPrey is a normal FOCS condition matched against universe objects. As there is no FOCS symbol yet for space boats (universe/Fighter), And [ Not Planet Not Ship ] is used to match boats
  • Compared to before, the random roll is now inside a for loop with precision as the number of repetitions. After the roll the preferredPrey condition is matched against the universe object. If it matches, it breaks out of the loop.
FOCS/content details:
  • spinal antimatter cannon - hunts for ships with high hitpoints
  • flak - hunts for space boats
  • bomber boat - hunts for space ships
  • interceptor boat - hunts for space boats
Things to be done/discussed:
  • Content - e.g. should all short range weapons prefer to hunt ships?
  • Content - what about monster weapons etc.?
  • Content - should there be weapons targetting planet defenses?
  • TBD: code cleanup/review
  • Content - precision balancing
  • How to balance AI designs?
  • Should there be other sources of precision/preferredPrey and combination of those?
  • Extensions of the preferred prey condition; e.g. taking into account statistics of the combat; or taking into account the current number of rerolls
Code can be found in PR-2249
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Oberlus
Small Juggernaut
Posts: 738
Joined: Mon Apr 10, 2017 4:25 pm

Re: Combat Preferred Targetting

#2 Post by Oberlus » Sun Aug 19, 2018 12:29 pm

A drawback (for some of us) of this approach is that it requieres two or three times more RNG calls per combat and still be very influentiable by fleet compositions.
For example, if I have 1 huge carrier (9 fighters) and 9 small carriers (6 fighters), against 10 huge gunners with DRs and spinal cannons, first turn will work out just fine because there are no boats to target, but then the chances to actually hit a ship would be around 25%. I mean, it's still so awkward that the spinal is targetting boats while there is a straight line between the spinal cannon and the best possible objective, which has been visible from before the combat started (i.e. nothing prevents the spinal cannon to fire directly at it from the beginning).

After much thinking on all this matters (during last months) I am very inclined to prefer deterministic targetting (e.g. spinal cannons ONLY target capital ships, interceptors ONLY target boats, etc.).

Jaumito
Space Kraken
Posts: 158
Joined: Tue May 16, 2017 3:42 am
Location: Catalonia, France, Europe, Earth, Sol, Orion Arm, Milky Way, Virgo Cluster

Re: Combat Preferred Targetting

#3 Post by Jaumito » Sun Aug 19, 2018 2:04 pm

The way I'd do it would be to give each weapon part type (that's including hangars) a set of condition/weight pairs, rather than only one. Weights could have some predetermined values like (1 being the default value)
  • -1 - never an eligible target
  • 0 - can't be fired at unless no other eligible target is present
  • 1-100 - used as a standard weight value in computations
  • 101+ - priority target: as long as a target of specified type is present, lower weighted values will be ignored; if more than one, subtract 100 and use the result as the real weight
For instance, the spinal gun could be (I added a bunch of conditions of my own to show how the system could be extended)

Code: Select all

[Not Planet Not Ship]: -1
[Planet] 100
[Huge_Armed_Ship] 110
[Huge_Carrier_Ship] 120
[Troop_Transport] 0
[Ship_with_Bombs] 20

(anything else would get the default - 1)
In this example, huge ships would be fired at first, with a 2-to-1 preference for carriers vs non-carriers. Then anything that's not a troop transport or a fighter, with a huge focus on planet defenses, and a milder one on bombers. Then only, troop transports if there are any left.

Depending on the set of available conditions and chosen weights, you could get a pretty deterministic outcome out of this if you wish.

Ophiuchus
Vacuum Dragon
Posts: 569
Joined: Tue Sep 30, 2014 10:01 am

Re: Combat Preferred Targetting

#4 Post by Ophiuchus » Sun Aug 19, 2018 8:24 pm

Oberlus wrote:
Sun Aug 19, 2018 12:29 pm
A drawback (for some of us) of this approach is that it requieres two or three times more RNG calls per combat and still be very influentiable by fleet compositions.
For example, if I have 1 huge carrier (9 fighters) and 9 small carriers (6 fighters), against 10 huge gunners with DRs and spinal cannons, first turn will work out just fine because there are no boats to target, but then the chances to actually hit a ship would be around 25%. I mean, it's still so awkward that the spinal is targetting boats while there is a straight line between the spinal cannon and the best possible objective, which has been visible from before the combat started (i.e. nothing prevents the spinal cannon to fire directly at it from the beginning).

After much thinking on all this matters (during last months) I am very inclined to prefer deterministic targetting (e.g. spinal cannons ONLY target capital ships, interceptors ONLY target boats, etc.).
I think the rng performance hit is negligible. Targetting preferences definitly degrade depending on the fleet compositions, but its much better than what we have.
I also went for 5 rolls for the specialised weapons in the prototype. So in your example that would be a ~50% chance to hit the right target.

You could clone and modify my branch for checking out your deterministic targetting idea, shouldnt be very difficult. Rebalancing everything though would probably a big task.
Jaumito wrote:
Sun Aug 19, 2018 2:04 pm
The way I'd do it would be to give each weapon part type (that's including hangars) a set of condition/weight pairs, rather than only one. Weights could have some predetermined values like (1 being the default value)
...
Depending on the set of available conditions and chosen weights, you could get a pretty deterministic outcome out of this if you wish.
So you suggest a deterministic tier and a preferred tier and roll weighted dice inside each tier to determine the target right?

With my implementation the available conditions are normal FOCS conditions against a single enemy object (e.g. ship or boat or planet). One should be able to query for tags, species, ship stats and parts. These conditions are not predefined and would be different for different parts.

Also there is another issue coming that geoff wanted to have some parts determining the target preferences of a design (one could also extend that idea to species target preferences and fleet/leader target preferences).
So there will be the composibility question (different target preferences for a ship). The flak part should probably always shoot at space boats no matter what target preference the design has. With the antimatter cannon that is not so sure. Maybe the targetting part should override the weapons parts preferences and determine the type of enemy to shoot. Maybe a regime of multiple tiers could sort that out actually.
But i guess that would complicate the content definition and implementation quite a bit.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Jaumito
Space Kraken
Posts: 158
Joined: Tue May 16, 2017 3:42 am
Location: Catalonia, France, Europe, Earth, Sol, Orion Arm, Milky Way, Virgo Cluster

Re: Combat Preferred Targetting

#5 Post by Jaumito » Mon Aug 20, 2018 7:50 am

Ophiuchus wrote:
Sun Aug 19, 2018 8:24 pm
So you suggest a deterministic tier and a preferred tier and roll weighted dice inside each tier to determine the target right?
Sort of, although there's no fundamental difference between the tiers, the only special cases for "weights" being -1 (I can't kill you) and 0 (I'll kill you last).

I've seen this logic used several times, typically the lower byte of an integer would be used as a weight-within-a-tier, and the upper byte(s) would define the tiers (typically again, using bit masks). In my example I had only two tiers, but of course you could use 1-100, 101-200, 201-300, etc. to get more. The general idea is to resolve tiers sequentially, from upper to lower. The deterministic part comes from the fact that you can't resolve lower tiers as long as there are targets meeting an upper tier condition. Which, if conditions are simple and few, makes a deterministic targeting logic easy to implement. The cool thing is (in my biased opinion), this would be dependent on the ship part - not the general algorithm.

User avatar
Oberlus
Small Juggernaut
Posts: 738
Joined: Mon Apr 10, 2017 4:25 pm

Re: Combat Preferred Targetting

#6 Post by Oberlus » Tue Aug 21, 2018 10:14 am

Jaumito, that system is great.

IMO, it should be implemented first in its general form (several tiers), and then content scripting (as sketched by Ophiuchus) would decide if the combat system is in the end purely deterministic, purely random or any middle point.

I think the things to be designed prior to any implementation is all that about leaders, targetting/computing ship parts, to see dependencies between the parts/leaders and the specification of preferred targets.

Ophiuchus
Vacuum Dragon
Posts: 569
Joined: Tue Sep 30, 2014 10:01 am

Re: Combat Preferred Targetting

#7 Post by Ophiuchus » Tue Aug 21, 2018 8:40 pm

I was putting some more thought into the tier system and how it can be used when multiple sources of preferences etc are combined.

First one thing about the suggested implementation: i definitly would abstain from exposing a bitmask-based system to the content scripting user.

But I think for the current iteration multiple tiers is overly complex. There is a more KISS version:

Combine preferredPrey conditions of all sources on the same level and use the precision as weight, adding all weights of conditions.
So if you have anti-xenophobe policy (2), a battle scanner (4) targetting armed targets, a flak (10) targetting space boats, a mass driver (2) targetting space ships and any target (1); the flak would attack e.g. trith bombers seventeen times as likely as an etty troop ship (weight 1+16 vs weight 1+0). The mass driver would attack trith bombers about two times as likely as an etty troop ship (7 vs 3)

If we wanted we would also define exclusions so the flak would exclude everything but space boats (and probably only get a precision of 3).

With the reroll implementation i would take the maximum precision of the applicable sources. I only dont have a clue how to implement the weighted choosing of a target..

From this design we could extend afterwards to multiple tiers, but that would be another step.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Oberlus
Small Juggernaut
Posts: 738
Joined: Mon Apr 10, 2017 4:25 pm

Re: Combat Preferred Targetting

#8 Post by Oberlus » Wed Aug 22, 2018 7:18 am

Ophiuchus wrote:
Tue Aug 21, 2018 8:40 pm
Combine preferredPrey conditions of all sources on the same level and use the precision as weight, adding all weights of conditions.
Great, a general prey_weighting formula that takes as input the relevant characteristics of the weapon (and the ones "inherited" from its ship's parts and fleet commander) and the target.

I would add to this relevant characteristics of the target, its damage output (maybe filtered by own shields) as well as its structure. Because one targeting preference could be for ships that deliver more damage, or more damage over structure (that is, you require to inflict less damage points for each enemy damage point you remove).
With the reroll implementation i would take the maximum precision of the applicable sources. I only dont have a clue how to implement the weighted choosing of a target..
I suggest tournament selection. It is often used in stochastic optimisation algorithms.
In N-way tournament you select with uniform probability N possible targets, calculate the weighting of each one and stick with the best of them. The higher N, the more chances to get a good prey.
The exclusions could be handled by ignoring such targets and rerolling that dice(*).

With this approach you must know in advance the number of rolls (N). For this I suggest assigning each weapon class a base "precission" (integer), possibly modifiable by parts, technologies and/or species traits. Two should be the minimum for any weapon that can target different classes, that I think will be all of them (the bombers can have different preferrence for different capital ships, the flak can have different preference between interceptors and bombers, etc.), and maximum values could be around 6.

(*) This can lead to long execution times in particular scenarios where the excluded targets (say boats) are majority and the RNG keep giving you boats. In my applications this happens a lot, I solved it by switching to different selection schemes after a few rejected dice rolls. E.g. if on an array of length X, sequentially go up or down from last ramdom excluded target until finding a non-excluded target.

Jaumito
Space Kraken
Posts: 158
Joined: Tue May 16, 2017 3:42 am
Location: Catalonia, France, Europe, Earth, Sol, Orion Arm, Milky Way, Virgo Cluster

Re: Combat Preferred Targetting

#9 Post by Jaumito » Wed Aug 22, 2018 8:03 am

Ophiuchus wrote:
Tue Aug 21, 2018 8:40 pm
With the reroll implementation i would take the maximum precision of the applicable sources. I only dont have a clue how to implement the weighted choosing of a target..
What's the problem, exactly? Once you've identified the targets matching at least one of your conditions, it should be trivial to create a weighted table of eligible targets and roll against it, so I guess the problem lies somewhere else?

Ophiuchus
Vacuum Dragon
Posts: 569
Joined: Tue Sep 30, 2014 10:01 am

Re: Combat Preferred Targetting

#10 Post by Ophiuchus » Wed Aug 22, 2018 2:01 pm

Jaumito wrote:
Wed Aug 22, 2018 8:03 am
Once you've identified the targets matching at least one of your conditions, it should be trivial to create a weighted table of eligible targets and roll against it, so I guess the problem lies somewhere else?
Im not sure what you mean with a weighted table in cpp terms. But meanwhile i found discrete_distribution which should suffice nicely make the dice roll.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Ophiuchus
Vacuum Dragon
Posts: 569
Joined: Tue Sep 30, 2014 10:01 am

Re: Combat Preferred Targetting

#11 Post by Ophiuchus » Wed Aug 22, 2018 2:08 pm

Oberlus wrote:
Wed Aug 22, 2018 7:18 am
I suggest tournament selection. It is often used in stochastic optimisation algorithms.
In N-way tournament you select with uniform probability N possible targets, calculate the weighting of each one and stick with the best of them. The higher N, the more chances to get a good prey.
Nice.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Vezzra
Release Manager, Design
Posts: 4686
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Combat Preferred Targetting

#12 Post by Vezzra » Sun Aug 26, 2018 12:21 pm

First of all, these are some interesting ideas you guys are coming up with here. However, IMO all of you are working with a faulty premise, which is that our current combat system/implementation primarily simulates/abstracts target selection and firing, and basically assumes that (when resolving space combat) more or less everyone is in range of everyone else. This statement by Oberlus illustrates it perfectly:
Oberlus wrote:
Sun Aug 19, 2018 12:29 pm
I mean, it's still so awkward that the spinal is targetting boats while there is a straight line between the spinal cannon and the best possible objective, which has been visible from before the combat started (i.e. nothing prevents the spinal cannon to fire directly at it from the beginning).
That's simply not the case.

Lets step back for a momentand try to take a more comprehensive look on how battles "work", particularly how they are usually modelled in war games. Basically there are two major "components" or "aspects" that make up battle/combat simulation: movement and firing (as we're talking space battles here, we don't need to generalize to include melee vs. ranged attacks). As I've already explained on different occasions in earlier discussions, our current combat model tries to abstract/simulate both equally (although in a very crudely simplified way, it's only a stop-gap solution after all).

Simply put, movement is where each opponent tries to maneuver their forces into positions where they can maximize how efficiently they can use their weapons against the enemy and minimize how efficiently the enemy can use their weapons against them. Firing is where, once opposing forces get into firing distance, targets are selected and weapons are fired. However, what targets are available to you very much depends on how cleverly (or not) you managed to outmaneuver your opponent.

This reminds me of something I dimly recall to have read many years ago about naval combat, IIRC it's called "to cross someone's T", which comes from the times when the cannons of warships were mounted on their broadsides. Now, with this setting, it was important to maneuver your ship so that you can fire as much of your cannons at the enemy, while preventing your enemy from doing the same. "Crossing your enemies T" meant accomplishing the ideal maneuver: you pass in front of the opposing ship's bow (or behind it's stern) with your broadside facing them (hence "T"). That meant, while passing the enemy ship, you could fire all the cannons of your broadside at them, while they couldn't return the fire (or just with the very few cannons mounted at the bow or stern, if they had that).

Which meant, you were able to make maximum use of your firepower, while your enemy could only use a fraction of theirs (if any at all). Basically jackpot, so to speak. This way a naval vessel with much less firepower could still sink a much stronger enemy ship, if it succeeded in cleverly outmaneuvering them.

Now apply that to FO space combat. Keep in mind, the current combat resolution does not just resolve a simple skirmish, but a battle that spans the entire star systems it takes place in. Meaning, we're talking about a prolonged battle spanning a vast area, which (particularly in cases where more than just a few spaceships are involved) most likely is broken up into a lot of smaller and larger skirmishes, and probably last weeks or months (not just a few hours).

This means, the current system abstracts/simulates all fleet operations, movement, maneuvering etc. all participants perform to bring their forces into optimal positions and strike against their enemies, as well as the actual exchange of fire whenever parts of their forces come into firing distance. So, to come back to the often cited example where the Spinal Antimatter Cannon shoots down a fighter and ignores that big enemy juggernaut right beside it: that's not what happens. If the Antimatter Cannon fires at a fighter while there are far more powerful targets still around, that simply means the ship with that cannon hasn't been able to get into a position where it can fire on a more eligible target. The fighter, as measly a target as it is, was the only/best target available.

Or maybe the fighter just sacrified itself by hurling itself between the cannon and it's intended target. Or maybe the fighter got into the firing line of the Antimatter Cannon just coincidentally, while involved in a dogfight. The more smaller crafts run around, the higher the chance one of those get in the way, so to speak.

Basically, in cases where the target selection of one of the combatants looks completely off, it's not because the idiot gunner thought that a fighter is a more valuable target for an Antimatter Cannon than a planet, but because the enemy managed to "cross their T": they outmaneuvered their opponent, so that said opponent could only use their weapons very inefficiently.

I guess you get the picture.

Now back to the suggestions presented here. The problem with those is, they only try to address/improve the targetting/firing aspect/part, while bascially ignoring the movement/maneuvering aspect/part. Which, IMO, means that with those changes you certainly get a combat simulation that works differently, but it won't be an improvement. It won't be any more "realistic". Best case, it's just different. Less than best case it might actually turn out worse than the current system (because more complex, but without really improving things).

Personally I think the current system works sufficiently well, once you adopt the right "fluff explanation" for it, so the Antimatter Cannon shooting down fighters doesn't bother you that much anymore. Sure, even with the above explanation, the current system is extremely crude, and certainly has some glaring flaws that should be fixed. The fighters taking a round to launch thing is one of them, as that doesn't fit at all with the abstraction level I explained above, makes things more complicated, harder to balance and compare, while adding exactly nothing interesting (IMO).

But all in all the current system it's still good enough as a stop-gap solution, so I don't really see the need to tinker with it (other than fixing said glaring glitches).

However, if you guys absolutely want to invest the time and energy to improve a system that's going to get discarded at some point, that's fine with me. But if you do that, do it right, which means any attempt at improvement has to take into account the whole picture, all the aspects of space combat abstracted by the current system, not just one part of it - that would only throw things out of balance IMO. So, if you want to have a more detailed/sophisticated simulation for target selection and firing, please also come up with something that provides an equally detailed/sophisticated simulation of the movement/maneuvering part.

Because I want to retain e.g. things like the current ability of carriers to hide behind the fighters they can field (or, in that particular case, improve it by removing that fighters take one round to launch thing). If a carrier goes up against a direct fire ship, the latter should have a hard time to get past the fighter screen to actually target the carrier. So it makes sense that most/all of the shots of the direct fire ship will hit fighters, not the carrier, at the start of the combat. Only by taking down enough fighters will increase the chance to get through to the carrier.

If only implementing the improvements to firing/targetting (as if all participating vessels where in range of each other anyway all the time), than that would change dynamics greatly to the disadvantage of the carrier, and defeat a good part of what makes fighters a distinct kind of weapon. A carrier should be able to keep enemies at distance with their fighter squadrons, after all.

And it should be difficult to get a ship equipped with a Spinal Antimatter Cannon into a position where it can use the cannon with maximum efficiency. Especially when facing an opponent who can cover their bigger assets behind lots of small crafts. The current system actually takes care of that quite well IMO. An improved system needs to take of all these things at least as well, otherwise it's really not worth the effort.

Ophiuchus
Vacuum Dragon
Posts: 569
Joined: Tue Sep 30, 2014 10:01 am

Re: Combat Preferred Targetting

#13 Post by Ophiuchus » Sun Aug 26, 2018 6:48 pm

Vezzra wrote:
Sun Aug 26, 2018 12:21 pm
So, if you want to have a more detailed/sophisticated simulation for target selection and firing, please also come up with something that provides an equally detailed/sophisticated simulation of the movement/maneuvering part.
I dont think this reasoning is logically sound. But if you like to think so in the current implementation movement/maneuvering is as important as choosing your target. Its probabalistic skewing the randomness in direction of an intended goal, so the ships are moved in a position trying to hit the right kind of target.

For the real system only the weight and the preference condition will stay; if the combat system changes, the meaning and balancing will change as well.

Also I dont know who will implement the final system, and if there was a real discussion about the vision for that I think I missed the thread. Reading between the lines I guess people had expressed preference for a space soap naval combat system, but I may be wrong. Anyway that is pretty OT here.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Oberlus
Small Juggernaut
Posts: 738
Joined: Mon Apr 10, 2017 4:25 pm

Re: Combat Preferred Targetting

#14 Post by Oberlus » Sun Aug 26, 2018 7:30 pm

Great post, Vezzra (in every way :D), but I disagree with the premises.

Space combat is way different than naval combat.
Space is open, huge and has no horizont.

This hugeness and openness means:
- Unless effective stealth is in place, everything is on "sight" of your sensors from way further than your weapons can fire. There is no hiding, and if there is, then there is no combat. There is a straight line between any pair of objects, and trying to shield huge ships with small ones is hard and easy to counter.
- Weapons can fire from very long distances (missiles could be fired from earth to mars, lasers could be effective at a few light-seconds (1,000,000 km)).
- Speeds are immense, mindblowing. A realistic orbital (within the gravitational pit of a star) rendezvous would be similar to jousts (knights on a horse charging at each other, if none falls then they must turn back and charge again), adversaries having hours or days en route to the battle at insane speeds then passing at weapon range of each other for a few seconds and not being able to meet again until costly orbital maneuvers are done (again hours or days).
- There is no way to cross other's T. Trying to circle a ship covering millions of km while it can just turn around in less than a second gets you nothing.

I'll add a link to a very good post on this. Sorry I cant quote, I'm on a crappy mobile.

https://forums.spacebattles.com/threads ... te.131056/

User avatar
Krikkitone
Creative Contributor
Posts: 1416
Joined: Sat Sep 13, 2003 6:52 pm

Re: Combat Preferred Targetting

#15 Post by Krikkitone » Mon Aug 27, 2018 2:52 am

Firstly, no realism.

The idea that combat is random (and relies on attempting to damage an enemy that is attempting to damage you) works well enough.

However if there needs to be weapons builds that do some degree of countering each other, there needs to be excluded targets OR preferred targets.

Excluded is easier conceptually...but it doesn't allow things like

veteran ships
highly trained troops
accurate weapons (not just more damage)
advanced maneuvering engines (not just faster)
etc.

So that is where preferred targeting would come in....but that is also where "weapon targets nothing" can come in. can add more detail in the morning.

Post Reply