#Horizontal Velocity Calculator inaccuracies

1 messages ยท Page 1 of 1 (latest)

hybrid charmBOT
#

<@&987246652869971988> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
Im making a horizontal Velocity Calculator class for my anticheat but it produces data between 2-5% from the correct value and i have tried everything to make it as accurate os possible if somone could help i would immensley greatful

ke sure the calculations are accurate.

Here are some possible reasons why your Horizontal Velocity Calculator may be producing inaccurate results:

  1. Calculation errors: Double-check your code to ensure that the mathematical formulas used to calculate horizontal velocity are correct. Even a small error in the calculation can lead to significant discrepancies in the final result.

  2. Rounding errors: Make sure you are not rounding off intermediate results too early in the calculation process. Round off only the final result to avoid cumulative errors.

  3. Data type issues: Check that you are using appropriate data types for variables involved in the calculation. Using floating-point numbers instead of integers can help improve accuracy.

  4. Input data inconsistencies: Ensure that the input data provided to the calculator is accurate and consistent. Any inconsistencies or inaccuracies in the input values can affect the final output.

  5. Testing and validation: Run extensive tests on your calculator with different input values to identify any patterns or trends in inaccuracies. This can help pinpoint specific areas of improvement in your code.

By addressing these potential issues and fine-tuning your Horizontal Velocity Calculator code, you should be able to improve its accuracy and produce more reliable results for your anticheat system.

cold pulsar
#

i will put my classes here

hybrid charmBOT
cold pulsar
hybrid charmBOT
cold pulsar
#

package ac.kosko.vigilanceAnticheat.Processor;

import ac.kosko.vigilanceAnticheat.Packets.PlayerData;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

public class HorizontalVelocityChecker {
private static final Logger LOGGER = Logger.getLogger(HorizontalVelocityChecker.class.getName());
private PlayerData playerData;
private double lastX;
private double lastZ;
private long lastPacketReceiveTime;
private float horizontalVelocity;

public HorizontalVelocityChecker(PlayerData playerData) {
    this.playerData = playerData;
    this.lastX = 0.0;
    this.lastZ = 0.0;
    this.lastPacketReceiveTime = 0L;
    this.horizontalVelocity = 0.0f;
    LOGGER.info("HorizontalVelocityChecker initialized for player " + playerData.getUuid());
}

public void processPacket(double x, double z, long receiveTime) {
    if (this.lastPacketReceiveTime != 0L) {
        double deltaX = x - this.lastX;
        double deltaZ = z - this.lastZ;
        double distance = Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
        long timeDiff = receiveTime - this.lastPacketReceiveTime;
        double timeDiffSeconds = timeDiff / 1000.0; // Convert milliseconds to seconds
        double horizontalVelocity = distance / timeDiffSeconds;
        this.horizontalVelocity = (float) horizontalVelocity;
    } else {
        LOGGER.info("First packet received, skipping velocity calculation");
    }

    this.lastX = x;
    this.lastZ = z;
    this.lastPacketReceiveTime = receiveTime;
}

public double getHorizontalVelocity() {
    Player player = Bukkit.getPlayer(this.playerData.getUuid());
    player.sendMessage("Returning horizontal velocity: " + this.horizontalVelocity + " m/s");
    return this.horizontalVelocity;
}

}

#

i know its a lot of code and compl;icated for somone to help so i dont expect anyone to reply as it would take them a while to read understand the code and help find the problem

next epoch
#

I assume you're using data types with the most precision?

#

I would put down some print statements to see the results of each calculation and where it's going wrong

spring topaz
#

Time to learn how to incorporate unit testing into your project.

river kindle
cold pulsar
# next epoch I assume you're using data types with the most precision?

yeah when my proccessor proccess them and stores it in the player data class it is usign the most precise data type

i am i can see the caclulation and every 2 ticks i get a message detailing the calculated speed and it is sayign 5.7xxxxx m/s sometimes 5.8xxxxxm/s

but the correct value is 5.6xxxxm/s

cold pulsar
cold pulsar
#

plus the correxct protocol libs api and the correct spigot api

#

the problem doesnt seem to be with any of that tho maybe i am casting smth to the wrogn class maybe my equasion ios missing smth out idkl thats why i posted here to see if asomone could help

cold pulsar
#

i have found a solution i implimented a Kalman filter that also includes the calculated velocity as an input at that has helped signifcantly