diff options
author | syeyoung <cyougn06@naver.com> | 2022-01-12 22:17:02 +0900 |
---|---|---|
committer | syeyoung <cyougn06@naver.com> | 2022-01-12 22:17:02 +0900 |
commit | 945eb217de8e304168a0a35b8c5e1011f1f7799a (patch) | |
tree | d78c3f511dc6cdec94814cd1c90572f087dbcc95 /src/main/java/kr/syeyoung | |
parent | 4cc2746d8c26dc9cf2b9cccdc7aaa51ceaa8c07c (diff) | |
download | Skyblock-Dungeons-Guide-945eb217de8e304168a0a35b8c5e1011f1f7799a.tar.gz Skyblock-Dungeons-Guide-945eb217de8e304168a0a35b8c5e1011f1f7799a.tar.bz2 Skyblock-Dungeons-Guide-945eb217de8e304168a0a35b8c5e1011f1f7799a.zip |
- Fix Timescore approximation with data
Diffstat (limited to 'src/main/java/kr/syeyoung')
3 files changed, 98 insertions, 7 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java index e8f3ada5..f120f94f 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java @@ -36,6 +36,7 @@ import kr.syeyoung.dungeonsguide.stomp.CloseListener; import kr.syeyoung.dungeonsguide.stomp.StompClient; import kr.syeyoung.dungeonsguide.stomp.StompInterface; import kr.syeyoung.dungeonsguide.utils.AhUtils; +import kr.syeyoung.dungeonsguide.utils.TimeScoreUtil; import kr.syeyoung.dungeonsguide.wsresource.StaticResourceCache; import lombok.Getter; import net.minecraft.client.Minecraft; @@ -157,6 +158,7 @@ public class DungeonsGuide implements DGInterface, CloseListener { if (FeatureRegistry.DISCORD_DONOTUSE.isEnabled()) System.setProperty("dg.safe", "true"); MinecraftForge.EVENT_BUS.register(RichPresenceManager.INSTANCE); + TimeScoreUtil.init(); ProgressManager.pop(progressbar); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java index 533e3dfe..f10d7262 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java @@ -35,6 +35,7 @@ import kr.syeyoung.dungeonsguide.stomp.StompMessageHandler; import kr.syeyoung.dungeonsguide.stomp.StompPayload; import kr.syeyoung.dungeonsguide.stomp.StompSubscription; import kr.syeyoung.dungeonsguide.utils.TextUtils; +import kr.syeyoung.dungeonsguide.utils.TimeScoreUtil; import kr.syeyoung.dungeonsguide.wsresource.StaticResource; import kr.syeyoung.dungeonsguide.wsresource.StaticResourceCache; import lombok.AllArgsConstructor; @@ -274,13 +275,14 @@ public class FeatureDungeonScore extends TextHUDFeature { int time = 0; { int maxTime = context.getMaxSpeed(); - int timeSec = FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed() / 1000 - maxTime + 480; - - if (timeSec <= 480) time = 100; - else if (timeSec <= 580) time = (int) Math.ceil(148 - 0.1 * timeSec); - else if (timeSec <= 980) time = (int) Math.ceil(119 - 0.05 * timeSec); - else if (timeSec < 3060) time = (int) Math.ceil(3102 - (1/30.0) * timeSec); - time = MathHelper.clamp_int(time, 0, 100); // just in case. +// int timeSec = FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed() / 1000 - maxTime + 480; +// +// if (timeSec <= 480) time = 100; +// else if (timeSec <= 580) time = (int) Math.ceil(148 - 0.1 * timeSec); +// else if (timeSec <= 980) time = (int) Math.ceil(119 - 0.05 * timeSec); +// else if (timeSec < 3060) time = (int) Math.ceil(3102 - (1/30.0) * timeSec); +// time = MathHelper.clamp_int(time, 0, 100); // just in case. + time = TimeScoreUtil.estimate(FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed(), maxTime); } int bonus = 0; int tombs; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/TimeScoreUtil.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/TimeScoreUtil.java new file mode 100644 index 00000000..f43a1f17 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/TimeScoreUtil.java @@ -0,0 +1,87 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.utils; + +import kr.syeyoung.dungeonsguide.Main; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ResourceLocation; +import org.apache.commons.io.IOUtils; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +public class TimeScoreUtil { + private static final TreeMap<Integer, Integer> min8 = new TreeMap<Integer, Integer>(); + private static final TreeMap<Integer, Integer> min10 = new TreeMap<Integer, Integer>(); + private static final TreeMap<Integer, Integer> min12 = new TreeMap<Integer, Integer>(); + public static void init() { + try { + load("8.csv", min8); + } catch (IOException e) { + e.printStackTrace(); + } + try { + load("10.csv", min10); + } catch (IOException e) { + e.printStackTrace(); + } + try { + load("12.csv", min12); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static void load(String name, TreeMap<Integer, Integer> minutes) throws IOException { + minutes.clear(); + List<String> lines = IOUtils.readLines(Main.class.getResourceAsStream("/timescore/"+name)); + for (String line:lines) { + String[] split = line.split(","); + minutes.put(Integer.parseInt(split[0]), Integer.parseInt(split[1])); + } + } + + public static int estimate(int mills, int drop) { + if (drop == 600) return estimate(mills, min10); + if (drop == 480) return estimate(mills, min8); + if (drop == 720) return estimate(mills, min12); + return -1; + } + + private static int estimate(int mills, TreeMap<Integer, Integer> lookup_table){ + Map.Entry<Integer, Integer> high = lookup_table.ceilingEntry(mills); + Map.Entry<Integer, Integer> low = lookup_table.floorEntry(mills); + + + if (low == null && high == null) return 0; + if (low == null) return high.getValue(); + if (high == null) return low.getValue(); + + int distHigh = high.getKey() - mills; + int distLow = mills - low.getKey(); + + if (distHigh > distLow) return high.getValue(); + else return low.getValue(); + } +} |