baritone/src/test/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesTh...

51 lines
2.0 KiB
Java
Raw Normal View History

2018-08-08 03:16:53 +00:00
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
2018-08-08 03:16:53 +00:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
2018-08-22 20:15:56 +00:00
package baritone.pathing.movement;
2018-08-04 22:28:36 +00:00
import org.junit.Test;
2018-08-22 20:15:56 +00:00
import static baritone.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.*;
2018-08-04 22:28:36 +00:00
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
2018-08-05 03:19:32 +00:00
for (int i = 0; i < 257; i++) {
double blocks = ticksToBlocks(FALL_N_BLOCKS_COST[i]);
2018-08-05 03:25:05 +00:00
assertEquals(blocks, i, 0.000000000001); // If you add another 0 the test fails at i=217 LOL
2018-08-04 22:28:36 +00:00
}
2018-08-17 19:24:40 +00:00
assertEquals(FALL_1_25_BLOCKS_COST, 6.2344, 0.00001);
assertEquals(FALL_0_25_BLOCKS_COST, 3.0710, 0.00001);
assertEquals(JUMP_ONE_BLOCK_COST, 3.1634, 0.00001);
2018-08-04 22:28:36 +00:00
}
2018-08-05 03:19:32 +00:00
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;
}
2018-08-04 22:28:36 +00:00
}