#Cannon Inaccuracy Rework

1 messages · Page 1 of 1 (latest)

restive sable
#

Currently, the way inaccuracy works for all projectile-based guns, as well as lasers in FtD, functions based on a rectangular, or uniform, distribution. This means that the azimuth and elevation axes are assigned a uniform inaccuracy, with all shells guaranteed to fall within the listed value.
This is, of course, unrealistic. Real cannons and ballistic systems of all kinds will usually have a Gaussian distribution, where shots will group more tightly towards the center with a few more spurious outliers.

{MATH AHEAD, PROCEED AT YOUR OWN PERIL}
variables going forward:
x = azimuth or elevation. Given the distribution for azimuth f(x), and the same for elevation g(x), the full distribution function h(θ, φ) = f(φ)*g(θ).
A = nominal inaccuracy value
σ = standard deviation
We can consider the inaccuracy distribution in FtD to be
F(x) = rect(x/2A)/2A.
This probability distribution describes a region from +A to -A, which integrates to 1.
It can be determined that given this function, the standard deviation is equal to
σ = A/sqrt(3).

Standard deviation can be best described as how inaccurate any particular distribution "feels."

Now, a Gaussian distribution function that has this same standard deviation can be produced, and is equal to:
G(x) = sqrt(3)•exp(-3x^2/2A^2)/(A•sqrt(2•pi))

Now, the obvious problem with the Gaussian distribution is that its domain stretches from positive to negative infinity. This means that there is an astronomically low, but nonzero chance of a given shell firing with an inaccuracy of 180 degrees and hitting its own cannon. To address this, I propose that any shot that would otherwise fire with an inaccuracy greater than 2A on either axis will instead be forced to fire with perfect accuracy. This covers the edge cases (there is approximately a 0.053% chance of shells falling outside 2A this way, and so it will not appreciably change the standard deviation.)

muted bobcat
#

funny thing about inaccuracy, it used to be gaussian vertically, and uniform horizontally. but now it's just uniform in both axes

#

I suppose a rectangular shape is much easier to calculate, though it would be nice to have something more circular. but in practice it doesn't affect combat that much

ebon edge
#

It might be nice for shots to somewhat favor closer to the center (on both axis) but still be mostly uniform. But it's not going to matter a whole lot if it's not.

restive sable
#

I know it's a QoL feature more than a proper balance change, in fact i specifically meant for it mathematically to be neither a buff nor a nerf.
However I can definitely see why it would be computationally expensive, especially with craft firing batteries of dozens of shells in one physics tick.

mighty lake
#

from experience with using gaussians for this exact purpose in quantities greater than in ftd, it’s not noticeably expensive

thin knoll
#

Could also do something like a cached box-muller transform
I'd think that the real question is balance, given that you'd need a significantly wider normal distribution to get the same average inaccuracy, and even then you'd get a lot more shots hitting close to dead-center which favors drilling weapons

restive sable
restive sable
#

I specifically defined a Gaussian which would have the exact same average inaccuracy (aka standard deviation) as the current form of the vanilla inaccuracy distribution

fluid locust
#

Useful in game examples for this topic

#

Something to consider, realistic accuracy would be a big buff to the accuracy of projectiles., which may not be intended by the devs

restive sable
#

The tighter concentration of many shots closer to the center is mathematically perfectly offset by the smaller amount of very spurious shots

fluid locust
#

Unless your turning the current volume of the square shaped spread patterns into a circle while keeping the same volume, the result seems highly redundant

restive sable
# fluid locust Unless your turning the current volume of the square shaped spread patterns into...

Essentially, there exists a statistical parameter for any given probability density function called standard deviation. It measures the average extent to which any given instance is expected to err from the average position. (which in our case is the true aimpoint).
Essentially, I gave a mathematical function which does two things.
-It bakes in a more circular distribution rather than square, and
-It produces a gradually decreasing probability that any given shot will be a certain error from the aimpoint, which is probabilistically more true to how actual cannons of all kinds function.

Shown here is the 1-dimensional probability density functions I described (current FtD model in red, proposed Gaussian model in green). Notice that the Gaussian function has a higher peak probability density function in the center, but extends out past the nominal inaccuracy mark.

#

basically, there is a mathematically rigorous way to prove that a cannon with this specific Gaussian distribution and one with the existing uniform distribution have exactly the same amount of average error on shots, and so should score hits on a given target equally often

muted bobcat
#

well, not necessarily

#

the gaussian would hit more often against a small target and the uniform would hit more often against a large target

willow crane
#

ngl, instead of gaussian, you could just do a pyramid, with the very edges having a 30% chance of the shell going there, and then increases in the middle, so instead of pure maths you can just have like 3 preset numbers

#

like 10% 20% 40% 20% 10%

#

in a square, like the game already has

#

would be a lot more mathematically simple

#

tough the outer parts have more area so youd have to mess with the percentages to make it so the mid part gets more shells

tropic plover
restive sable
#

Define "precision" and "optimal range"

tropic plover
#

It also would completely require redoing all inaccuracies in the game

#

Since precision would become a lot more different for all weapons

restive sable
#

If by optimal range you mean the range at which shells have the highest likelihood to hit, this value is trivial at 0m for any cannon

tropic plover
restive sable
tropic plover
#

No.

I want to hit a boat one kilometer away.
Given inaccuracy X, what percentage of shots will hit the block I'm aiming at within 5 blocks?

#

Assume trivial planar geometry

#

If I want to create a vessel that only shoots when the stability, range and inaccuracy would lead to a shot landing within some specified radius of target block, rectangular inacc is much much easier to deal with than normal

restive sable
#

This is trivial in desmos

#

Set up an integral

tropic plover
#

I want to do that in game

#

No integrals in BB

#

no error function

#

unless you want to approximate

restive sable
#

You can use the CDF function of the Gaussian for this

tropic plover
#

CDF of gauss has an erf which is not a thing in breadboards

restive sable
#

Basically a CDF (cumulative density function) is the integral of a probability density function which is what I showed here

tropic plover
#

The CDF of gauss uses a non-algebraic function erf

restive sable
#

It's reasonably approximatable with arctan

#

Or even a piecewise linear function if you're feeling extra engineer

tropic plover
#

Even then, disregarding the BB issues, this would completely and utterly change the balance of the game.

#

Especially stuff like 0Q lasers which would become significantly more penetrative

restive sable
#

Not really, as they would spend non-zero amounts of ticks shooting way outside the nominal inaccuracy metric

tropic plover
#

This would look very strange, don't you think?

#

A ton of laser shots will seemingly randomly drift a trillion light years away for 1 frame

#

They hit 40 times a second after all

#

But most shots will hit much tighter than they do now

#

That's why I'm saying they would become more penetrative

#

More shots will land at intended targets

restive sable
#

~68% of shots will land within one inaccuracy metric, 95% within two, and nearly all within three

tropic plover
restive sable
#

I am aware

tropic plover
#

That's kind of the thing though.

restive sable
#

With rectangular distribution, 100% of all shots land within a rectangular prism in space. Given that all of FtD's parts are roughly rectangular, this actually makes rectangularly distributed lasers significantly better at boring a minimally sized hole if the the distance error at target is roughly on the order of 1m, assuming the target is not at an angle

#

There is an effective maximum sampling pixel density baked into combat in the form of the fact that boats are made of 1m voxels, which completely overpowers any changes to the distribution when error is less than this distance (this is very much often the case for lasers, at least out to 1.2km or so with 0.05° inacc)

tropic plover
#

Okay, I did some calculations

#

Say, our inaccuracy square is 5x5. We want to bore a hole. That means the laser will only be hitting the central block 4% [1/25] of times with rectangular distribution.
With gauss, however, it becomes roughly 2.46%

#

So things actually become more inaccurate

#

That's a negative change in other words

#

Still a huge balance change

#

Things become around 33% less accurate overall

restive sable
#

Maybe make a chart detailing the probability of hitting center square for any 2n+1 length and width?

tropic plover
#

I'm monte-carloing it rn, writing out the formula analytically would make me tear out my hair

#

since blocks are square

#

the uhhh

#

the double integral for 2D gaussian PDF over -1 to 1 for both x and y

restive sable
#

Ah so you're doing this in 2d

#

Cool stuff

tropic plover
#

well duh

#

obviously

#

you're rolling the dice twice

#

for azimuth and for elevation

#

Also, I fucked up

#

it's not 2.46%

#

I did not account for tan

#

this is azimuth/elevation

#

fuck

#

uno momento por favor

restive sable
#

I should also mention that the Gaussian function in 2d inherently has radial symmetry, this would mean that you are neither rewarded or punished when firing at a craft that is at a steep angle

tropic plover
#

btw, you also did not account for how inaccuracy happens over distance I think

#

The distribution for ele and azi change might be uniform

#

but the effect it has on where the shot lands is not

#

It's already non-uniform

#

i.e. when a laser bores a hole, over infinite time it will be a rectangular hole

#

but short-term it's not

#

it also depends on inaccuracy itself of course

restive sable
#

This is extremely computationally difficult to test, but I would imagine that a Gaussian, being radially symmetric, would also punish certain shaped craft who happen to just barely take up all the space of their inaccuracy distribution

#

consider this case

tropic plover
#

Okay, so here's a more concrete example.
0.2 inaccuracy, 1000 meters distance: uniform distribution: 8.25% hit rate
Gauss: 5.06%

#

1 inacc: 1000 meters, uniform: 3.28%, gauss: 2.13%

#

Finally

#

0.05 inacc, 1000 meters

Uniform: 100%
Gauss: 55.9%

#

This is a huge drop

restive sable
#

see this is part of my point

#

consider a cube-shaped craft

#

it will almost always get hit by incoming shells where the inaccuracy is on the order of its total size, just because of its shape

#

rotating it by 45 degrees suddenly causes some of these shots to miss

tropic plover
#

Nobody makes cube shaped craft though

#

For obvious reasons

#

and rotating with least exposed area is literally the meta so

restive sable
#

yes but i mean

#

rolling with respect to the direction of incoming fire

#

should do nothing to help or harm you

#

yet with rectangular distribution, it does

tropic plover
#

It still would because of the way inaccuracy is set up

#

It does two rolls for azimuth and elevation separately

#

This inherently makes it triangular distribution with uniform

#

If it instead changed angle directly with one roll, then yes

#

Gauss multiplied by gauss is still gauss, but with a different scale

restive sable
tropic plover
#

Ah, found it, bessel function governs it

restive sable
#

ah yes, my beloved sombrero function

tropic plover
#

Regardless, because it sets azi and ele separately, it probably doesn't have quite the same mapping

restive sable
#

it would not be a triangular distribution going into a 2d graph.

#

rect(x)*rect(y) produces a uniform 1x1 rectangle in cartesian space

tropic plover
#

Okay, so I went ahead and implemented your idea

#

This is the histogram of hits for rect distribution.
The x axis is manhattan distance from the origin

#

1000 meters, 0.2 inacc

#

Gauss. I also did the with an inaccuracy greater than 2A on either axis will instead be forced to fire with perfect accuracy

#

oh wait

#

either

#

Yeah, this then

#

lol

#

either axis changes meaning a lot

#

@restive sable

#

Well, 2A implies that nearly 10% of shots must be nearly dead on.

#

Unless you mean on either as in, both must be >2A

#

and not one of them should be 2A for a shot to become perfect

#

2 sigma on either axis -> perfect shot makes gauss ridiculously more accurate than rect

restive sable
tropic plover
#

@restive sable

#

Apparently perfect hits are still way more likely in gauss in this case, but misses will be further away

#

with 3 sigma cutoff