use of me.wobblyyyy.pathfinder2.geometry.PointXY in project Pathfinder2 by Wobblyyyy.
the class TestLocalizedPathGen method testUnobstructedNegativePathfinding.
@Test
public void testUnobstructedNegativePathfinding() {
List<Zone> zones = new ArrayList<>();
LocalizedPathGen gen = new LocalizedPathGen(zones, 0.5, 0.5);
PointXY start = new PointXY(-5, -5);
PointXY end = new PointXY(5, 5);
List<PointXY> path = gen.getPath(start, end);
Assertions.assertNotNull(path);
Assertions.assertEquals(2, path.size());
}
use of me.wobblyyyy.pathfinder2.geometry.PointXY in project Pathfinder2 by Wobblyyyy.
the class TestLocalizedPathGen method testUnobstructedPath.
@Test
public void testUnobstructedPath() {
List<Zone> zones = new ArrayList<>();
LocalizedPathGen gen = new LocalizedPathGen(zones, 0.5, 0.5);
PointXY start = new PointXY(0, 0);
PointXY end = new PointXY(10, 10);
List<PointXY> path = gen.getPath(start, end);
}
use of me.wobblyyyy.pathfinder2.geometry.PointXY in project Pathfinder2 by Wobblyyyy.
the class TestNodeValidator method testNodeValidation.
@Test
public void testNodeValidation() {
LocalizedGrid grid = new LocalizedGrid(Grid.generateGrid(10, 10), 0, 0, 10, 10);
Rectangle blocker = new Rectangle(5, 0, 10, 10);
Zone blockerZone = new Zone(blocker);
List<Zone> zones = new ArrayList<Zone>(1) {
{
add(blockerZone);
}
};
NodeValidator.validateNodes(grid, zones);
Assertions.assertTrue(grid.getNode(new PointXY(0, 0)).isValid());
Assertions.assertFalse(grid.getNode(new PointXY(6, 6)).isValid());
Assertions.assertFalse(grid.getNode(new PointXY(5, 0)).isValid());
Assertions.assertTrue(grid.getNode(new PointXY(3, 5)).isValid());
Assertions.assertFalse(grid.getNode(new PointXY(7, 7)).isValid());
Assertions.assertFalse(grid.getNode(new PointXY(8, 8)).isValid());
}
use of me.wobblyyyy.pathfinder2.geometry.PointXY in project Pathfinder2 by Wobblyyyy.
the class TestPathOptimizer method testLinearOptimization.
@Test
public void testLinearOptimization() {
List<Zone> zones = new ArrayList<>();
LocalizedPathGen gen = new LocalizedPathGen(zones, 0.5, 0.5);
PointXY start = new PointXY(0, 0);
PointXY end = new PointXY(10, 10);
List<PointXY> path = gen.getPath(start, end);
path = PathOptimizer.optimize(path);
Assertions.assertNotNull(path);
}
use of me.wobblyyyy.pathfinder2.geometry.PointXY in project Pathfinder2 by Wobblyyyy.
the class TestPathOptimizer method testNonlinearOptimization.
@Test
public void testNonlinearOptimization() {
Rectangle blockerShape = new Rectangle(5, 1, 6, 10);
Zone blockerZone = new Zone(blockerShape);
List<Zone> zones = new ArrayList<Zone>() {
{
add(blockerZone);
}
};
LocalizedPathGen gen = new LocalizedPathGen(zones, 0.5, 0.5);
PointXY start = new PointXY(0, 0);
PointXY end = new PointXY(10, 10);
List<PointXY> unoptimized = gen.getPath(start, end);
List<PointXY> optimized = PathOptimizer.optimize(unoptimized);
List<PointXY> overOptimized = PathOptimizer.optimize(optimized);
Assertions.assertNotNull(unoptimized);
Assertions.assertNotNull(optimized);
Assertions.assertNotNull(overOptimized);
int unoptimizedSize = unoptimized.size();
int optimizedSize = optimized.size();
int overOptimizedSize = overOptimized.size();
double unoptimizedLength = PathOptimizer.determineLength(unoptimized);
double optimizedLength = PathOptimizer.determineLength(optimized);
double overOptimizedLength = PathOptimizer.determineLength(overOptimized);
// Assertions.assertEquals(30, unoptimizedSize);
// Assertions.assertEquals(16, optimizedSize);
// Assertions.assertEquals(16, overOptimizedSize);
// Assertions.assertTrue(Equals.soft(16.778, unoptimizedLength, 0.01));
// Assertions.assertEquals(optimizedLength, overOptimizedLength);
}
Aggregations