openset refactor

This commit is contained in:
Leijurv
2018-08-04 23:19:32 -04:00
parent 5a573f52bf
commit 72c69eb962
9 changed files with 62 additions and 279 deletions

View File

@@ -1,4 +1,4 @@
package baritone.bot.pathing.openset;
package baritone.bot.pathing.calc.openset;
import baritone.bot.pathing.calc.PathNode;
import baritone.bot.pathing.goals.GoalBlock;

View File

@@ -3,17 +3,30 @@ package baritone.bot.pathing.movement;
import org.junit.Test;
import static baritone.bot.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.FALL_N_BLOCKS_COST;
import static baritone.bot.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.velocity;
import static org.junit.Assert.assertEquals;
public class ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest {
@Test
public void testFallNBlocksCost() {
assertEquals(FALL_N_BLOCKS_COST.length, 257); // Fall 0 blocks through fall 256 blocks
for (int i = 0; i < 256; i++) {
double t = FALL_N_BLOCKS_COST[i];
double fallDistance = 3.92 * (99 - 49.50 * (Math.pow(0.98, t) + 1) - t);
assertEquals(fallDistance, -i, 0.000000000001); // If you add another 0 the test fails at i=43 LOL
for (int i = 0; i < 257; i++) {
double blocks = ticksToBlocks(FALL_N_BLOCKS_COST[i]);
assertEquals(blocks, i, 0.01);
}
}
public double ticksToBlocks(double ticks) {
double fallDistance = 0;
int integralComponent = (int) Math.floor(ticks);
for (int tick = 0; tick < integralComponent; tick++) {
fallDistance += velocity(tick);
}
double partialTickComponent = ticks - Math.floor(ticks);
double finalPartialTickVelocity = velocity(integralComponent);
double finalPartialTickDistance = finalPartialTickVelocity * partialTickComponent;
fallDistance += finalPartialTickDistance;
return fallDistance;
}
}