diff --git a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryState.java b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryState.java index 45c6bf6..17bde7d 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryState.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryState.java @@ -44,7 +44,7 @@ public class EasyGiantsFoundryState @Setter @Getter - private int lastKnownCrucibleScore = -1; // will be set when "Pour"ed + private int lastKnownCrucibleScore = -1; // will be set when "Pour"ed (because the crucible will be empty then) private final List stages = new ArrayList<>(); private double heatRangeRatio = 0; diff --git a/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay3D.java b/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay3D.java index d93101d..4987835 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay3D.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay3D.java @@ -158,11 +158,11 @@ public class FoundryOverlay3D extends Overlay if (state.heatingCoolingState.isCooling()) { - drawHeatingCoolingOverlay(graphics, waterfall); + drawHeatChangerOverlay(graphics, waterfall); } if (state.heatingCoolingState.isHeating()) { - drawHeatingCoolingOverlay(graphics, lavaPool); + drawHeatChangerOverlay(graphics, lavaPool); } @@ -195,7 +195,7 @@ public class FoundryOverlay3D extends Overlay modelOutlineRenderer.drawOutline(stageObject, config.borderThickness(), _color, config.borderFeather()); } - private void drawHeatingCoolingOverlay( + private void drawHeatChangerOverlay( Graphics2D graphics, GameObject stageObject ) diff --git a/src/main/java/com/toofifty/easygiantsfoundry/HeatActionSolver.java b/src/main/java/com/toofifty/easygiantsfoundry/HeatActionSolver.java index e500b9d..55e9ee6 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/HeatActionSolver.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/HeatActionSolver.java @@ -78,22 +78,30 @@ public class HeatActionSolver { /** - * Warning: this method prefers overshooting goal. For example, if goal is 957, - * it will return index that reaches >957.
- * This may be desirable if we're aiming to heat over range minimum, - * but undesirable when cooling below range maximum; make sure to -1 the index if so. + *

Warning: this method prefers overshooting goal. For example, if goal is 957, + * it will return index that reaches >957.

+ * + *

This may be desirable if we're aiming to heat just over range minimum; + * for example if the stage is heating (grind stone),

+ * + *

but undesirable when heating to just below range maximum; + * for example if the stage is cooling (hammer.)

+ * + *

+ * Make sure to subtract 1 tick from duration, if so. + *

* * * * @param goal the desired heat destination - * @param init_dx1 initial speed of heating/cooling. currently 7 for heat/cool, 27 for dunk/quench. + * @param dx1_init initial speed of heating/cooling. currently 7 for heat/cool, 27 for dunk/quench. * @param dx2_offset bonus acceleration. currently, 0 for heat/cool, 2 for dunk/quench. * @return Index here refers to tick. So an index of 10 means the goal can be reached in 10 ticks. */ - public static int findDx0Index(int goal, int init_dx1, int dx2_offset) + public static int findDuration(int goal, int dx1_init, int dx2_offset) { int dx0 = 0; - int dx1 = init_dx1; + int dx1 = dx1_init; int count_index = 0; for (int dx2 = 1; dx0 <= goal; dx2++) { // Start from 1 up to the count inclusive diff --git a/src/main/java/com/toofifty/easygiantsfoundry/HeatActionStateMachine.java b/src/main/java/com/toofifty/easygiantsfoundry/HeatActionStateMachine.java index 00e0da6..d18b443 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/HeatActionStateMachine.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/HeatActionStateMachine.java @@ -121,6 +121,7 @@ public class HeatActionStateMachine Stage stage = State.getCurrentStage(); int actionsLeft = State.getActionsLeftInStage(); int actionsLeft_DeltaHeat = (actionsLeft+1) * stage.getHeatChange(); + if (isHeating()) { if (stage.isHeating()) @@ -128,14 +129,15 @@ public class HeatActionStateMachine GoalHeat = Math.max(stageMin, stageMax - actionsLeft_DeltaHeat); if (StartingHeat < GoalHeat) { - int duration = HeatActionSolver.findDx0Index( + int duration = HeatActionSolver.findDuration( GoalHeat - StartingHeat, Velocity, AccelerationBonus ); + // compensate for heat decay during (1 heat every 2 ticks) GoalHeat += duration / 2; - EstimatedDuration = HeatActionSolver.findDx0Index( + EstimatedDuration = HeatActionSolver.findDuration( GoalHeat - StartingHeat, Velocity, AccelerationBonus ); @@ -151,14 +153,14 @@ public class HeatActionStateMachine GoalHeat = Math.min(stageMax, stageMin - actionsLeft_DeltaHeat); if (StartingHeat < GoalHeat) { - int duration = HeatActionSolver.findDx0Index( + int duration = HeatActionSolver.findDuration( GoalHeat - StartingHeat, Velocity, AccelerationBonus ) - 1; GoalHeat -= duration / 2; - EstimatedDuration = HeatActionSolver.findDx0Index( + EstimatedDuration = HeatActionSolver.findDuration( GoalHeat - StartingHeat, Velocity, AccelerationBonus ) - 1; @@ -175,14 +177,14 @@ public class HeatActionStateMachine GoalHeat = Math.max(stageMin, stageMax - actionsLeft_DeltaHeat); if (StartingHeat > GoalHeat) { - int duration = HeatActionSolver.findDx0Index( + int duration = HeatActionSolver.findDuration( StartingHeat - GoalHeat, Math.abs(Velocity), Math.abs(AccelerationBonus) ) - 1; GoalHeat += duration / 2; - EstimatedDuration = HeatActionSolver.findDx0Index( + EstimatedDuration = HeatActionSolver.findDuration( (StartingHeat - GoalHeat), Math.abs(Velocity), Math.abs(AccelerationBonus) ) - 1; @@ -197,14 +199,14 @@ public class HeatActionStateMachine GoalHeat = Math.max(stageMax, stageMin + actionsLeft_DeltaHeat); if (StartingHeat > GoalHeat) // too hot { - int duration = HeatActionSolver.findDx0Index( + int duration = HeatActionSolver.findDuration( StartingHeat - GoalHeat, Math.abs(Velocity), Math.abs(AccelerationBonus) ); GoalHeat -= duration / 2; - EstimatedDuration = HeatActionSolver.findDx0Index( + EstimatedDuration = HeatActionSolver.findDuration( StartingHeat - GoalHeat, Math.abs(Velocity), Math.abs(AccelerationBonus) ); diff --git a/src/test/java/com/toofifty/easygiantsfoundry/HeatSolverTest.java b/src/test/java/com/toofifty/easygiantsfoundry/HeatSolverTest.java index f5fb53b..b017fad 100644 --- a/src/test/java/com/toofifty/easygiantsfoundry/HeatSolverTest.java +++ b/src/test/java/com/toofifty/easygiantsfoundry/HeatSolverTest.java @@ -99,7 +99,7 @@ public class HeatSolverTest { for (int i = 0; i < 50; i++) { - System.err.println("[" + (350 + i) + "]" + HeatActionSolver.findDx0Index(350 + i, 7, 0)); + System.err.println("[" + (350 + i) + "]" + HeatActionSolver.findDuration(350 + i, 7, 0)); } } @@ -131,18 +131,18 @@ public class HeatSolverTest // System.err.println( // HeatSolver.findDx0IndexContinue(1000, 7, 0)); System.err.println( - HeatActionSolver.findDx0Index(957, 27, 2)); + HeatActionSolver.findDuration(957, 27, 2)); // System.err.println( -// HeatActionSolver.findDx0Index(1000, 7, 1)); +// HeatActionSolver.findDuration(1000, 7, 1)); } public void TestHeatSolver_Dx0_Helper(int dx0, int constant, int answer_index) { - System.err.print(dx0 + "->" + HeatActionSolver.findDx0Index(dx0, constant, 0) + ","); + System.err.print(dx0 + "->" + HeatActionSolver.findDuration(dx0, constant, 0) + ","); // test calcDx0Index assertEquals("Asserting dx0 for index " + answer_index, - answer_index, HeatActionSolver.findDx0Index(dx0, constant, 0)); + answer_index, HeatActionSolver.findDuration(dx0, constant, 0)); } @Test