Jump to content

Accuracy = spread?


Recommended Posts

So my understanding is that the attack spread is how accurate a unit is at hitting the target and the higher the number ie spread of 20 is a lot less accurate than a spread of 2.  Is this correct?   What exactly does the spread = ?  within x distance of target? 

I've been playing around with the files a little creating a mod based off of community mod.  Generally speaking I feel like the further the range, the less accurate.  If you are trying to hit something 60 meters away, its harder than hitting something 30 meters away.  So I figured the spread should be higher for longer ranged units, ie archers higher than slingers/xbows, higher than javs.  But then I realized jsut cause they have a logner range, doesnt mean they are always reaching that max range.  if 30 is low end of the max ranged units and they are all trying to hit somethign 20 meters away what should be more accurate, a bow and arrow, someone slinging a tiny rock or a jav?  
Also would make sense to me that the equivalent unit mounted would be slightly less accurate than its infantry counterpart. 

Anyone able to help explain how accuracy works in this game and what the spread means?  Also feel free to disagree as to wether further distance should = less accuracy and answer the question at the same distance which weapon would be more accurate?

Thanks!

  • Like 1
Link to comment
Share on other sites

Hello, the spread mechanism has been discussed here:

The key takeaway here is that we are sampling 2 random variables following a 2D Gaussian distribution in order to get 2 multipliers X and Y. Then we multiply the Distance from target by the multipliers to get the deviation ..

Let me know if you need further explanations of the JavaScript code or the mathematical details B)

Edited by AInur
Link to comment
Share on other sites

On 04/11/2024 at 1:26 PM, Emacz said:

Is it possible to try and break it down into layman's terms

Of course, I will try to explain.

By default, the arrows are aimed perfectly at the target's location and all hits will be 100% precise. In order to introduce spreads and near misses, the developers added random errors to the target coordinates, so that the arrows will always land some distance away from the target location. The units in 0AD have a non-zero but finite sized hit box, so anything which lands within the unit's hitbox is still considered a direct hit. On a 2 Dimensional map, mathematically, we have:

Target coordinates: (x, z)

The landing coordinates of arrows, after adding errors: (x + offsetX, z + offsetZ)

The value of the offsets (random errors) are computed by: offset = (distance from target * spread multiplier / 100) * RandomNumber

The random number here is generated by taking computer generated values following a Gaussian (Normal) distribution:

Module 6 Normal Distribution Introduction | Readings for MTH107

In our case, the mean is 0 and the standard deviation is 1. So it is the most likely to return some small value near 0, and our arrow will hit the target unit. But there are also small chances that it gives us a very large value and our arrows will miss.

For example, there is a 68% chance that our RandomNumber < 1, a 96% chance that our RandomNumber < 2.

Increasing the spread multiplier and the distance target will lower the maximum tolerable RandomNumber that we can take to hit, therefore the probability of a direct hit will decrease and chances of missing will increase. In a sense, greater spread multiplier and distance squeeze your acceptable region from the lighter blue to the only the darker blue.

 

Above was a high level theoretical overview; there are a few computational details to be aware of:

  • The distribution that we are sampling from is not exactly the Gaussian distribution shown above, but a Box-Muller transform of the Gaussian Distribution. This is because taking samples from the real Gaussian distribution is too slow and will result in lag, but the Box-Muller transformed distribution is much faster.
  • The Box-Muller distribution samples from 2 random variables following an Uniform Distribution between 0 and 1, then calculates a result from these 2. Details here: https://en.wikipedia.org/wiki/Box–Muller_transform
  • The random variables are not truly random but pseudorandom, meaning that all 'random' numbers we get are actually taken from a predictable chain. This chain is determined by a seed, which is generated and written to the replay files while the match is loading. Having this key, you can predict all future 'random' values and hence predict where exactly each one of your arrows will land.
  • The developers forgot about the height dimension; the arrows will not miss vertically (will not fly above the target unit's head and miss).
Edited by AInur
  • Like 1
Link to comment
Share on other sites

Wow, thanks I really appreciate this.  I think it makes a little more sense :)

So I really need to think about it as if all three ranged weapons, or 4 I guess right?  Jav, Bow, Xbow, Slinger are trying to hit something at the same distance.  If the target is 5m away they probably should all hit it about 99.9% of the time, 10 meters away, maybe the Jav becomes just a little less accurate.

When can you really start to notice the difference?  Ive heard if you set spread to 20 its pretty funny, but have yet to try it myself.

My goal with my mod is to try and make things as historically accurate as possible, yet still balanced and fun.  So this will take a little time to play around with and really think about.

I'm open to ideas on what to set spreads too.... My thought is infantry would be slighlty more accurate than their mounted counterpart.  Also merc slightly more accurate than regular solidiers and champs the most accurate.

 

Link to comment
Share on other sites

8 minutes ago, Lion.Kanzen said:

How will you do it?

trial and error and imput for people who try my mods.  What I am thinking right now, and these numbers are completely arbitrary is:

Jav spread of 5, range 30 speed 70 Cav version spread 5.5, range 28 speed 75

Slinger spread 3.5 range 45 speed speed 75 Cav version spread 4, range 42, speed 80

Xbow spread 1.5 range 45 speed 90 Cav version spread 2.0 range 42, speed 95

Bow spread 2.0 range 60 speed 85 Cav version spread 2.5 speed 90, range 57

I dont even know what role speed plays.... Merc of that same unit Probably subtract .5 from spread, add 2-3 to range keep seed the same. Champs subtract 11 from spread, range 3-5, speed +5. Heroes..... OPP :)

  • Thanks 1
Link to comment
Share on other sites

4 minutes ago, real_tabasco_sauce said:

speed is just the projectile speed. Units account for the direction of their target when attacking, but not any changes after that. So speed effectively controls how easily projectiles may be dodged.

I think for a few units, projectile speed is too fast.

Let me know which ones :)  From what I read XBOW is more accurate than bow due to speed, so I actually switched the speeds around a ltitle, bow was at 100 dropped it to 85 and put xbow at 90

Link to comment
Share on other sites

1 minute ago, Lion.Kanzen said:

Are you going to change the development version or the a26?

I just do this for fun, so I built a mod on top of com mod 26.13... I just change the txt in those files.  Im a nub programmer :(

Link to comment
Share on other sites

https://gitea.wildfiregames.com/0ad/0ad

You have several options.

It would be nice to download a git client, it's easier and paste the url.

The game files will be downloaded.

Screenshot_20241105-214756.thumb.jpg.1b5672af39945d54e43fc3efd5b4de19.jpg

I'm stuck using SVN, you must using another link using Tortoise SVN.

It depends on which client you prefer.

https://git-scm.com/downloads/guis

I use clients with interface, it's easier.

I recommend Tortoise git, because it's easy. But I don't know if it's the best.

For SVN you use tortoise SVN.

https://tortoisesvn.net/

 

  • Like 1
Link to comment
Share on other sites

@Emacz

Speed is the flying speed of projectile in meters per second. Faster speeds prevent the target unit from escaping, so no dodge or dance moves would be possible - very much like laser weapons.Slower speeds are more cinematic but players can dodge projectile by waltzing units around.

It's up to you which one you prefer, but I like high speed projectiles, after seeing absorber dancing troll and scout leaks in another RTS game.

If your archer has a projectile speed of 70 m/s then it will reach the target in 1 second after firing. The speed of an infantry unit is about 8m/s. In 1 turn, the infantry can travel 1.6 meters. The 95% likely landing zone of your arrows is a circle with radius approximately 1.5 meters, from the calculation above, so if the other player reacted quickly enough (within 3 turns or 0.6 seconds), then they can always dodge the arrow successfully, theoretically. The average human reaction time is 0.25s, just over 1 turn.

If you don't want dodging to happen, you should use a very fast projectile speed, e.g. 1100m/s (similar to a modern sniper rifle).

I don't understand what is the point of adding spread mechanism. The random sampling is extra load on the CPU and does almost the same as just lowering the arrow damage, except with more uncertainty and luck. Just simply decrease the arrow damage to an appropriate amount would fix these issues completely.

Edited by AInur
  • Like 1
Link to comment
Share on other sites

There is one additional parameter regarding ranged units - gravity.

0ad projectile trajectories are parabolic curves that intercept the archer and the target, modelled based on your ballistic arrow in vacuum. The gravity parameter decides the curvature of the trajectory and the developers manipulates the visual shape of the trajectory using this parameter. The issue here is that if your gravity parameter is too high compared to your launch speed, then your projectile might not be able to reach your target before it lands.

This page may be helpful: https://en.wikipedia.org/wiki/Projectile_motion

  • Like 1
Link to comment
Share on other sites

18 minutes ago, AInur said:

I don't understand what is the point of adding spread mechanism.

You assume 1 target only, but usually there are bunch clumped together. So spread may even make projectiles more effective. Imagine 20 of your units shooting the same unit when 5 are already enough to drain all health of said unit. In that case you might get even 2 or 3 units instead of just one with the volley.

  • Like 2
Link to comment
Share on other sites

7 hours ago, AInur said:

@Emacz

Speed is the flying speed of projectile in meters per second. Faster speeds prevent the target unit from escaping, so no dodge or dance moves would be possible - very much like laser weapons.Slower speeds are more cinematic but players can dodge projectile by waltzing units around.

It's up to you which one you prefer, but I like high speed projectiles, after seeing absorber dancing troll and scout leaks in another RTS game.

If your archer has a projectile speed of 70 m/s then it will reach the target in 1 second after firing. The speed of an infantry unit is about 8m/s. In 1 turn, the infantry can travel 1.6 meters. The 95% likely landing zone of your arrows is a circle with radius approximately 1.5 meters, from the calculation above, so if the other player reacted quickly enough (within 3 turns or 0.6 seconds), then they can always dodge the arrow successfully, theoretically. The average human reaction time is 0.25s, just over 1 turn.

If you don't want dodging to happen, you should use a very fast projectile speed, e.g. 1100m/s (similar to a modern sniper rifle).

I don't understand what is the point of adding spread mechanism. The random sampling is extra load on the CPU and does almost the same as just lowering the arrow damage, except with more uncertainty and luck. Just simply decrease the arrow damage to an appropriate amount would fix these issues completely.

Thanks, 

While I think Hero dancing is an issue, i do think that some micro/dodging/avoiding is good.  Im going to use this spread sheet to mess around with things and hopefully get in game feedback to make changes if necessary.

 

0AD units - Ranged.pdf

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...