From 5baa56bb29245a4b52a4794f59bc84dc95c15524 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 23 Aug 2018 08:52:05 -0700 Subject: [PATCH] add option for pythagorean metric --- src/main/java/baritone/Settings.java | 5 +++++ src/main/java/baritone/pathing/goals/GoalXZ.java | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index f1ac0474..c689d05a 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -107,6 +107,11 @@ public class Settings { */ public Setting minimumImprovementRepropagation = new Setting<>(true); + /** + * Use a pythagorean metric (as opposed to the more accurate hybrid diagonal / traverse). + */ + public Setting pythagoreanMetric = new Setting<>(false); + /** * After calculating a path (potentially through cached chunks), artificially cut it off to just the part that is * entirely within currently loaded chunks. Improves path safety because cached chunks are heavily simplified. diff --git a/src/main/java/baritone/pathing/goals/GoalXZ.java b/src/main/java/baritone/pathing/goals/GoalXZ.java index d8153b00..de48da83 100644 --- a/src/main/java/baritone/pathing/goals/GoalXZ.java +++ b/src/main/java/baritone/pathing/goals/GoalXZ.java @@ -64,6 +64,9 @@ public class GoalXZ implements Goal { } public static double calculate(double xDiff, double zDiff) { + if (Baritone.settings().pythagoreanMetric.get()) { + return Math.sqrt(xDiff * xDiff + zDiff * zDiff) * Baritone.settings().costHeuristic.get(); + } //This is a combination of pythagorean and manhattan distance //It takes into account the fact that pathing can either walk diagonally or forwards