heat solver: decay calculations now considers distances to tools. can now use 0 padding without issues.

This commit is contained in:
Louis Hong
2024-11-21 11:46:46 -08:00
parent d6281c1754
commit 77e2e2ebe4
5 changed files with 64 additions and 11 deletions

View File

@@ -520,15 +520,15 @@ public interface EasyGiantsFoundryConfig extends Config
max = 50
)
@ConfigItem(
keyName = "heatActionBuffer", // renamed to reset player's settings for previous bugged implementation
name = "Lava/Waterfall 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.",
keyName = "paddingTicks", // renamed to reset player's settings for previous bugged implementation
name = "Padding Ticks",
description = "Number of inefficient idle ticks between actions; calculations will pad more than optimal heat compensate for heat decay during idle/afk.",
position = 0,
section = advancedSettings
)
default int heatActionPadTicks()
{
return 4;
return 3;
}
@ConfigItem(

View File

@@ -49,6 +49,8 @@ public class EasyGiantsFoundryState
private final List<Stage> stages = new ArrayList<>();
private double heatRangeRatio = 0;
public final HeatActionStateMachine heatActionStateMachine = new HeatActionStateMachine();
public void reset()
{
stages.clear();
@@ -335,5 +337,9 @@ public class EasyGiantsFoundryState
return actions;
}
public HeatActionStateMachine heatActionStateMachine = new HeatActionStateMachine();
public boolean isPlayerRunning()
{
return client.getVarpValue(173) == 1;
}
}

View File

@@ -230,7 +230,8 @@ public class FoundryOverlay3D extends Overlay
state.getHeatAmount(),
true,
isLava,
config.heatActionPadTicks() * 2
config.heatActionPadTicks(),
state.isPlayerRunning()
);
final int fastDuration = fastResult.getDuration();
@@ -242,7 +243,8 @@ public class FoundryOverlay3D extends Overlay
state.getHeatAmount(),
false,
isLava,
config.heatActionPadTicks() * 2
config.heatActionPadTicks(),
state.isPlayerRunning()
);
final int slowDuration = slowResult.getDuration();

View File

@@ -119,6 +119,24 @@ public class HeatActionSolver
95,
91, // last one will always overshoot 1000
};
// index 1 is stage, ordinal order
// index 2 [0] = lava [1] = waterfall
// in units of tiles
public static final int[][] DISTANCE_TO_STAGE = new int[][] {
new int[] {4, 14},
new int[] {7, 9},
new int[] {12, 10}
};
// 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 FAST_INDEX = 10;
@@ -206,16 +224,24 @@ public class HeatActionSolver
int start,
boolean isFast,
boolean isActionHeating,
int padding)
int paddingTicks,
boolean isRunning)
{
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
// average distance from lava+waterfall around 8 ticks
// preform decays 1 heat every 2 ticks
final int min = Math.max(0, Math.min(1000, range[0] + padding));
final int max = Math.max(0, Math.min(1000, range[1] + 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] + paddingDecay + travelDecay));
final int actionsLeft_DeltaHeat = actionLeftInStage * stage.getHeatChange();
@@ -340,5 +366,23 @@ public class HeatActionSolver
return DurationResult.of(estimatedDuration, goalInRange, overshoot, start + dx0);
}
private static int solveTravelTicks(boolean isRunning, Stage stage, boolean isLava)
{
final int index1 = stage.ordinal();
final int index2 = isLava ? 0 : 1;
final int distance = DISTANCE_TO_STAGE[index1][index2];
if (isRunning)
{
// for odd distances, like 7
// 7 / 2 = 3.5
// rounded to 4
return (int) Math.ceil((double) distance / 2);
}
else
{
return distance;
}
}
}

View File

@@ -121,7 +121,8 @@ public class HeatActionStateMachine
getStartingHeat(),
actionFast,
isHeating(),
config.heatActionPadTicks() * 2
config.heatActionPadTicks(),
state.isPlayerRunning()
);
goalInRange = result.isGoalInRange();