From 4885d3fef8f974f3d84d08201ede6fa4d6b40c01 Mon Sep 17 00:00:00 2001 From: Redstone1024 <2824517378@qq.com> Date: Wed, 28 Aug 2024 14:13:18 +0800 Subject: [PATCH] Add probe interpolation to improve accuracy --- .../com/example/addon/modules/Prediction.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/example/addon/modules/Prediction.java b/src/main/java/com/example/addon/modules/Prediction.java index 2de6572..db5acfb 100644 --- a/src/main/java/com/example/addon/modules/Prediction.java +++ b/src/main/java/com/example/addon/modules/Prediction.java @@ -648,7 +648,7 @@ public class Prediction extends Module { boolean findPitch = false; // Basic physics prediction - if (predictionLevel.get() >= 1) { + { // Solve for the highest pitch { double minPitch = -90.0; @@ -715,8 +715,8 @@ public class Prediction extends Module { for (int i = 0; i < numProbe * 2 + 1; ++i) { for (int j = 0; j < numProbe * 2 + 1; ++j) { - targetYaw = centerYaw - (i - numProbe) * delta; - targetPitch = centerPitch - (j - numProbe) * delta; + targetYaw = centerYaw + (i - numProbe) * delta; + targetPitch = centerPitch + (j - numProbe) * delta; calculatePath(); arrayProbe[i][j] = isHitTarget; } @@ -743,20 +743,30 @@ public class Prediction extends Module { } int maxProbe = 0; - targetYaw = centerYaw; - targetPitch = centerPitch; + int maxI = numProbe; + int maxJ = numProbe; for (int i = numProbe * 2; i >= 0; --i) { for (int j = numProbe * 2; j >= 0; --j) { int x = Math.max(Math.min(validProbe[i][j][0], validProbe[i][j][1]), Math.min(validProbe[i][j][2], validProbe[i][j][3])); if (x > maxProbe) { maxProbe = x; - targetYaw = centerYaw - (i - numProbe) * delta; - targetPitch = centerPitch - (j - numProbe) * delta; + maxI = i; + maxJ = j; } } } + targetYaw = centerYaw; + targetPitch = centerPitch; + targetYaw += (maxI - numProbe) * delta; + targetPitch += (maxJ - numProbe) * delta; + + if (maxI != 0 && arrayProbe[maxI - 1][maxJ]) targetYaw -= delta / 2.0; + if (maxJ != 0 && arrayProbe[maxI][maxJ - 1]) targetPitch -= delta / 2.0; + if (maxI != numProbe * 2 && arrayProbe[maxI + 1][maxJ]) targetYaw += delta / 2.0; + if (maxJ != numProbe * 2 && arrayProbe[maxI][maxJ + 1]) targetPitch += delta / 2.0; + calculatePath(); }