Diep Motion Mechanics

Posted byu/Aznatf

Motion Mechanics #1 (Movement Speed)

This is the first of a series of posts that focuses on explaining the science of the motion of different entities and stats which sideeffects can lead to a change in velocity.

Definitions and Conventions

In order to can talk about speeds in general we need to establish a measuring system of length and time. An intuitive choice for length would be the length of 1 grid square, also known as 1 grid unit, as seen in the background. For time we simply use the standart unit of 1 second.

Unit

1 gu

1 s

Meaning

1 grid unit

1 second

An example : If an object travels 3 grid units in 5 seconds it has a speed of 3/5 or 0.6 gu/s

An useful extension of this units is to include the more fundamental time known as frames/loops and length which I like to call 1 diep unit. A frame/loop is 0.04 seconds long and 1 diep unit is 1/50th the length of a grid square.

Note : The conversion between gu/s and du/x is 1 gu/s = 2 du/x

Unaccelerated Entities

Every moving object experiences friction in the game. At every frame an unaccelerated object losses 10% of the speed it had on the previous frame. This is equivalent of multiplying the previous speed by 0.9 to get the speed for the next frame.

An example : Let's assume an object travels with constant 10 du/x across the map. At the moment it decides to not accelerate anymore would turn it into an unaccelerated object which speeds over time would look this.

V(0) : velocity at the 0th frame ; V(1) : velocity at the 1st frame ; and so on

This ominous 0.9 is called the constant of friction!

What this table shows us is that with every frame the velocity approach closer and closer to 0 but never actually reaches 0. So even a standing tank might still move into one direction. But of course if the value for speeds gets too small to handle it gets set 0 but in theory it would never quite reach it.

Accelerated Entities

Like for unaccelerated objects the constant of friction also affect accelerated object but a bit differently. The game apllies the acceleration part first and then calculates the velocity for the next frame before applying the constant of friction to the velocity. It cycles through this system once every frame.

Acceleration, Velocity, Constant of Friction (Deceleration)

The acceleration of an object has the unit du/x² and represent the change in speed on the first frame or if there would be no friction at all.

Note : Friction is the reason objects have top speeds and can't accelerate forever with the starting acceleration. A tank has reached its top speed when 10% of its current speed is equal to its acceleration.

An example : Let's take a lvl 1 tank with 0 du/x. It has an acceleration of 2.55 du/x² meaning it gains 2.55 du/x per frame if if there would be no friction. Its corresponding velocities look like this

Note : It's basically like the deceleration table but in the decelarion table the acceleratio part was 0.

Explanation : Remember the cycle → Acceleration, Velocity, Constant of Friction (Deceleration)

Since the tank has a velocity of 0 du/x the next thing the game does is to apply the constant of friction (0.9). But since 0.9 * 0 = 0 it changes nothing. Next is applying the acceleration of 2.55 du/x which gives us a new velocity of 2.55 du/x which the game applies cause after acceleration follows velocity. And if you repeat the cycle you get the list above.

Top Speed and Movement Speed Equation

The top speed of an object is 10 times its acceleration.

Example : The lvl 1 tank would have a top speed of 10 * 2.55 du/x = 25.5 du/x or 12.75 gu/s

Since all tanks are created equally in terms of movement speed we can find one movement speed equation which describes all of them. The top speed of an tank depends on the points spent in movement speed and on the level. The higher the level the slower the tank.

By testing in 2tdm with various builds at different levels you get following equation.

Examples :

Note : For each point in movement speed your acceleration and with it your top speed increases by 7% and you lose 1.5% for every newly reached level. Both of this facts make movement speed the second stat in the game, after reload, to behave exponetially rather than linear.

Fun facts

Credits

Very huge respect and credit to u/cx_diep aka CX for finding all of this out and telling me how it works. I only tested all the speeds in 2tdm to see if this holds up and matches the theoretical results but CX did most of the work for finding this equation.

TL;DR Movement speed is exponential and later stat points are overall more valuable

Motion Mechanics #2 (Recoil and Recoil Speed

Definition and Introduction

The recoil of a bullet/drone/trap is defined to be the distance that a tank covers with 1 shot while being stationary. A fundamental property of recoil is that it's constant for each bullet/drone/trap of the same barrel it comes out from, meaning it's a hard coded value and no stat in the game affects or changes it by any means. Recoil is always applied in the opposite direction of the where the projectile is heading at.

Recoil Table

To get a better perspective of things I list you all recoil values in the game. Not included are recoils from tanks which recoils cancels each others out and those whichs projectiles can't be desynchronized for recoil measurement i.e Quad Tank and Triple Twin

Note : Despite not knowing what the recoil per bullet of a barrel of (for example) Flank Guard might be, it can still be assumed it's 0.4 gu since tanks inherit abilities and properties of their predecessors. Same goes for other "recoil-symmetrical" tanks like Tri-trapper, Octo Tank or Battleship.

Recoil Speed

Recoil speed is the terminal speed a tank achieves only by constantly firing bullets into one direction.

Generally speaking the recoil speed (V_RC) is equal to the recoil divided by the reload time : V_RC = RC / RT

An example : The recoil speed of a 7 bullet reload Basic Tank is : 0.4 gu / 0.32 s = 1.25 gu/s

If you wanna know why this is the case you're either happy with the explanation that a distance divided by a time gives a speed or you can look at the frame to frame analysis of recoil to decude the same fact.

Frame by Frame Analysis

Recoil behaves on a frame to frame basis exactly like an unaccelerated entity. It starts out with a fixed initial speed and it decreases by 10% at each frame due to friction. The Initial speed is determined by 1/10 of the recoil a projectile will provide. You can also call the inital speed the boost the bullets gives you and that accelerates you forwards.

An example : Let's pick a Sniper which gives us a recoil of 60 du meaning the corresponding inital speed would be 6 du/x. The following table shows what happens to the tank after only one bullet is shot.

Note : The speed will decrease until it reaches 0.01 du/x. After that the game sets it to 0 du/x and the tank doesn't move at all.

If you take all the sum over all speeds up to infinity in the list it will result in 60 du which is the recoil we started out with. So in a sense you can say that acceleration is to an accelerated entity what the intial speed is to an unaccelerated one.

Seperation Principle

Since a tank can shoot multiple bullets at sets intervalls, we have to question what happens on the frame where the second bullet is being shot. In this case the seperation principle takes over. It states that the total speed gained from recoil at each frame is the sum of each bullets contribution to it on this exact frame.

An example : A 7 reload basic tank has 8x as a reload time, meaning after 9 frames it shoots the next bullet. The first bullet would contribute on this frame 2 * 0.9^8 du/x and the second one 2 du/x flat since it just spawned. Meaning the total speed on frame 9 is 2 + 2 * 0.9^8 du/x = 2.9565938 du/x

Visualization :

Note : 2.9565938 du/x * 0.9 = 2.66093442 du/x and 2.66093442 du/x + 0.9 * 2.39480978 du/x. This means you can instead of using the seperation principle just taking the total speed on a given frame and multiply it by 0.9 to get to the next. Just be aware of the critical points at the 9th, 17th, 25th and so on frame, where you gotta add plus 2 in this case.

This principle holds true with any amount of bullets as long as they are shot all along the same direction. If bullets are instead shot at an angle it's wiser to use sine and cosine and seperate it further into the speed in the direction of the x-axis and y-axis and use the seperation principle for both x and y independently to get the correct speed!

Besides that the recoil speed doesn't instantly set in. The tank just approaches this speed will firing more and more bullets. This can be also seen in the graph above. If you take the average speed of the first 8 frames you will get an average speed of 1.42383198 du/x which isn't not the recoil speed. The recoil speed is what we get after infinite iterations. For the next 8 frames (frame 9 to 16) we get : 2.03674495 du/x. The speed will steadily grow until we hit our recoil speed of 2.5 du/x.

Coorelation with Movement Speed

If we now add movement speed to the mix then it then it would be the same as if we would just have more bullets. In this case the total speed at each frame is calculated by taking the movement speed at a given frame plus the sum of all other bullets shot up to that point on that same frame.

An example : A lvl 1 basic tank with 7 reload. I know it's impossible but it's just a hypothetical example!

Visualization :

As a tank shoots more and more bullets, while accelerating, its total end speed (the speed with which it'll move after infinite frames) will approach its top movement speed plus its recoil speed.

In this case top movement speed = 10 * 2.55 du/x = 25.5 du/x and recoil speed 20 du / 8x = 2.5 du/x→ Total End speed = 25.5 du/x + 2.5 du/x = 28 du/x or 14 gu/s.

If it were to only shoot bullets then the end speed is just its recoil speed.

Consequence of the Principle

A consequence of the principle is that it tells us that we can calculate the speed of a tank on the next frame by taking the speed a tank had on the previous frame and treating it like it's accelerating. For the derivation we use the general expressions for movement speed and recoil speed on a frame to frame basis.

In the end we get that the total speed after is just the same as the total speed before modified via the acceleration process. You just have to not forget to add the intial speed on every frame a new bullet spawns, otherwise the speed won't sink up with the real speed. For a deceleration process you can just set A(0) to 0 and you'll get the same relationship.

Another calculation example

If you don't care about calculating the speed at each given frame and you only wanna know how fast a given tank will be after a reasonable amount of time then here is what you do.

Let's pick Triplet with 0 reload and on lvl 45 with 7 movement speed.

Here is another example where you have to take the angles into accounts cause otherwise it won't give you the right speed.

Example by Samuel17 : https://www.reddit.com/r/Diepio/comments/9ie97g/booster_exposed_ft_the_destroyer_classes_and_a/Credits to u/TheSamuel17 for providing a detailed calculation for a more complicated case!

Funfacts

TL;DR Recoil is a constant and provides a speed boost depending on reload!