Merge pull request #44 from TheLouisHong/master
heat solver: decay calculations now considers distances to tools. can now use 0 padding without issues.
This commit is contained in:
@@ -521,14 +521,14 @@ public interface EasyGiantsFoundryConfig extends Config
|
|||||||
)
|
)
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "heatActionBuffer", // renamed to reset player's settings for previous bugged implementation
|
keyName = "heatActionBuffer", // renamed to reset player's settings for previous bugged implementation
|
||||||
name = "Lava/Waterfall Padding Ticks",
|
name = "Padding Ticks",
|
||||||
description = "Units in ticks; buffers more than optimal heat when in lava/waterfall calculations to compensate for heat decay when the player is afk or running/walking slower than optimal.",
|
description = "Number of inefficient idle ticks between actions; calculations will pad more than optimal heat compensate for heat decay during idle/afk.",
|
||||||
position = 0,
|
position = 0,
|
||||||
section = advancedSettings
|
section = advancedSettings
|
||||||
)
|
)
|
||||||
default int heatActionPadTicks()
|
default int heatActionPadTicks()
|
||||||
{
|
{
|
||||||
return 4;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ public class EasyGiantsFoundryState
|
|||||||
private final List<Stage> stages = new ArrayList<>();
|
private final List<Stage> stages = new ArrayList<>();
|
||||||
private double heatRangeRatio = 0;
|
private double heatRangeRatio = 0;
|
||||||
|
|
||||||
|
public final HeatActionStateMachine heatActionStateMachine = new HeatActionStateMachine();
|
||||||
|
|
||||||
public void reset()
|
public void reset()
|
||||||
{
|
{
|
||||||
stages.clear();
|
stages.clear();
|
||||||
@@ -335,5 +337,9 @@ public class EasyGiantsFoundryState
|
|||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HeatActionStateMachine heatActionStateMachine = new HeatActionStateMachine();
|
|
||||||
|
public boolean isPlayerRunning()
|
||||||
|
{
|
||||||
|
return client.getVarpValue(173) == 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -222,12 +222,6 @@ public class FoundryOverlay3D extends Overlay
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
int sign = isLava ? 1 : -1;
|
|
||||||
int fastVelocity = 27 * sign;
|
|
||||||
int slowVelocity = 7 * sign;
|
|
||||||
int fastAccelBonus = 2 * sign;
|
|
||||||
int slowAccelBonus = 0;
|
|
||||||
|
|
||||||
HeatActionSolver.DurationResult fastResult =
|
HeatActionSolver.DurationResult fastResult =
|
||||||
HeatActionSolver.solve(
|
HeatActionSolver.solve(
|
||||||
state.getCurrentStage(),
|
state.getCurrentStage(),
|
||||||
@@ -236,7 +230,8 @@ public class FoundryOverlay3D extends Overlay
|
|||||||
state.getHeatAmount(),
|
state.getHeatAmount(),
|
||||||
true,
|
true,
|
||||||
isLava,
|
isLava,
|
||||||
config.heatActionPadTicks() * 2
|
config.heatActionPadTicks(),
|
||||||
|
state.isPlayerRunning()
|
||||||
);
|
);
|
||||||
|
|
||||||
final int fastDuration = fastResult.getDuration();
|
final int fastDuration = fastResult.getDuration();
|
||||||
@@ -248,7 +243,8 @@ public class FoundryOverlay3D extends Overlay
|
|||||||
state.getHeatAmount(),
|
state.getHeatAmount(),
|
||||||
false,
|
false,
|
||||||
isLava,
|
isLava,
|
||||||
config.heatActionPadTicks() * 2
|
config.heatActionPadTicks(),
|
||||||
|
state.isPlayerRunning()
|
||||||
);
|
);
|
||||||
final int slowDuration = slowResult.getDuration();
|
final int slowDuration = slowResult.getDuration();
|
||||||
|
|
||||||
@@ -271,6 +267,11 @@ public class FoundryOverlay3D extends Overlay
|
|||||||
stageLoc = new LocalPoint(stageLoc.getX(), stageLoc.getY());
|
stageLoc = new LocalPoint(stageLoc.getX(), stageLoc.getY());
|
||||||
|
|
||||||
Point pos = Perspective.getCanvasTextLocation(client, graphics, stageLoc, text, 50);
|
Point pos = Perspective.getCanvasTextLocation(client, graphics, stageLoc, text, 50);
|
||||||
|
if (pos == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Color color = config.lavaWaterfallColour();
|
Color color = config.lavaWaterfallColour();
|
||||||
|
|
||||||
OverlayUtil.renderTextLocation(graphics, pos, text, color);
|
OverlayUtil.renderTextLocation(graphics, pos, text, color);
|
||||||
|
|||||||
@@ -119,6 +119,15 @@ public class HeatActionSolver
|
|||||||
95,
|
95,
|
||||||
91, // last one will always overshoot 1000
|
91, // last one will always overshoot 1000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// index is stage, ordinal order
|
||||||
|
public static final int[] TOOL_TICK_CYCLE = new int[] {
|
||||||
|
5,
|
||||||
|
2,
|
||||||
|
2
|
||||||
|
};
|
||||||
|
|
||||||
public static final int MAX_INDEX = DX_1.length;
|
public static final int MAX_INDEX = DX_1.length;
|
||||||
public static final int FAST_INDEX = 10;
|
public static final int FAST_INDEX = 10;
|
||||||
|
|
||||||
@@ -206,16 +215,24 @@ public class HeatActionSolver
|
|||||||
int start,
|
int start,
|
||||||
boolean isFast,
|
boolean isFast,
|
||||||
boolean isActionHeating,
|
boolean isActionHeating,
|
||||||
int padding)
|
int paddingTicks,
|
||||||
|
boolean isRunning)
|
||||||
{
|
{
|
||||||
|
|
||||||
final boolean isStageHeating = stage.isHeating();
|
final boolean isStageHeating = stage.isHeating();
|
||||||
|
// adding tool cycle ticks because the first cycle at a tool is almost always nulled
|
||||||
|
// (unless manually reaching the tile, then clicking the tool)
|
||||||
|
final int toolDelay = TOOL_TICK_CYCLE[stage.ordinal()];
|
||||||
|
final int travelTicks = solveTravelTicks(isRunning, stage, isActionHeating) + toolDelay;
|
||||||
|
final int travelDecay = (int) Math.ceil((double) travelTicks / 2);
|
||||||
|
|
||||||
|
final int paddingDecay = (int) Math.ceil((double) paddingTicks / 2);
|
||||||
|
|
||||||
// adding 2.4s/8ticks worth of padding so preform doesn't decay out of range
|
// adding 2.4s/8ticks worth of padding so preform doesn't decay out of range
|
||||||
// average distance from lava+waterfall around 8 ticks
|
// average distance from lava+waterfall around 8 ticks
|
||||||
// preform decays 1 heat every 2 ticks
|
// preform decays 1 heat every 2 ticks
|
||||||
final int min = Math.max(0, Math.min(1000, range[0] + padding));
|
final int min = Math.max(0, Math.min(1000, range[0] + paddingDecay + travelDecay));
|
||||||
final int max = Math.max(0, Math.min(1000, range[1] + padding));
|
final int max = Math.max(0, Math.min(1000, range[1] + paddingDecay + travelDecay));
|
||||||
|
|
||||||
final int actionsLeft_DeltaHeat = actionLeftInStage * stage.getHeatChange();
|
final int actionsLeft_DeltaHeat = actionLeftInStage * stage.getHeatChange();
|
||||||
|
|
||||||
@@ -340,5 +357,29 @@ public class HeatActionSolver
|
|||||||
return DurationResult.of(estimatedDuration, goalInRange, overshoot, start + dx0);
|
return DurationResult.of(estimatedDuration, goalInRange, overshoot, start + dx0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int solveTravelTicks(boolean isRunning, Stage stage, boolean isLava)
|
||||||
|
{
|
||||||
|
final int distance;
|
||||||
|
if (isLava)
|
||||||
|
{
|
||||||
|
distance = stage.getDistanceToLava();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
distance = stage.getDistanceToWaterfall();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isRunning)
|
||||||
|
{
|
||||||
|
// for odd distances, like 7
|
||||||
|
// 7 / 2 = 3.5
|
||||||
|
// rounded to 4
|
||||||
|
return (int) Math.ceil((double) distance / 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,8 @@ public class HeatActionStateMachine
|
|||||||
getStartingHeat(),
|
getStartingHeat(),
|
||||||
actionFast,
|
actionFast,
|
||||||
isHeating(),
|
isHeating(),
|
||||||
config.heatActionPadTicks() * 2
|
config.heatActionPadTicks(),
|
||||||
|
state.isPlayerRunning()
|
||||||
);
|
);
|
||||||
|
|
||||||
goalInRange = result.isGoalInRange();
|
goalInRange = result.isGoalInRange();
|
||||||
|
|||||||
@@ -7,15 +7,18 @@ import lombok.Getter;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum Stage
|
public enum Stage
|
||||||
{
|
{
|
||||||
TRIP_HAMMER("Hammer", Heat.HIGH, 20, -25),
|
TRIP_HAMMER("Hammer", Heat.HIGH, 20, -25, 4, 14),
|
||||||
GRINDSTONE("Grind", Heat.MED, 10, 15),
|
GRINDSTONE("Grind", Heat.MED, 10, 15, 7, 19),
|
||||||
POLISHING_WHEEL("Polish", Heat.LOW, 10, -17);
|
POLISHING_WHEEL("Polish", Heat.LOW, 10, -17, 12, 10);
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final Heat heat;
|
private final Heat heat;
|
||||||
private final int progressPerAction;
|
private final int progressPerAction;
|
||||||
private final int heatChange;
|
private final int heatChange;
|
||||||
|
|
||||||
|
private final int distanceToLava;
|
||||||
|
private final int distanceToWaterfall;
|
||||||
|
|
||||||
public boolean isHeating()
|
public boolean isHeating()
|
||||||
{
|
{
|
||||||
return heatChange > 0;
|
return heatChange > 0;
|
||||||
@@ -25,4 +28,5 @@ public enum Stage
|
|||||||
{
|
{
|
||||||
return heatChange < 0;
|
return heatChange < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user