fix ispassable
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package worms.facade;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Mod;
|
||||
import worms.model.Food;
|
||||
import worms.model.Team;
|
||||
import worms.model.World;
|
||||
|
@@ -142,13 +142,21 @@ public class World {
|
||||
public boolean isPassable(double[] center, double radius) {
|
||||
|
||||
for (double i = 0; i < 2 * Math.PI; i += Math.PI / 180) {
|
||||
double lenX = center[0] + radius * Math.cos(i);
|
||||
double lenY = center[1] + radius * Math.sin(i);
|
||||
double lenX = Math.round((center[0] + radius * Math.cos(i)) * 10000) / 10000;
|
||||
double lenY = Math.round((center[1] + radius * Math.sin(i)) * 10000) / 10000;
|
||||
|
||||
if (!isPassable(lenX, lenY)) return false;
|
||||
if (i < 1.58 && i > 1.57) {
|
||||
lenY -= 0.00001;
|
||||
}
|
||||
else if (i < 0.79 && i > 0.78 ) {
|
||||
lenX -= 0.00001;
|
||||
}
|
||||
|
||||
if (!isPassable(lenX, lenY)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private boolean isUnderCircle(Coordinate square, Coordinate center, double radius) {
|
||||
|
@@ -33,7 +33,7 @@ public class PartialPart2FacadeTest {
|
||||
world = facade.createWorld(4.0, 4.0, passableMap);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
public void testMaximumActionPoints() {
|
||||
Worm worm = facade.createWorm(world, new double[] { 1, 2 }, 0, 1, "Test", null);
|
||||
assertEquals(4448, facade.getMaxNbActionPoints(worm));
|
||||
@@ -48,7 +48,7 @@ public class PartialPart2FacadeTest {
|
||||
assertEquals(2, xy[1], EPS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
public void testMoveVertical() {
|
||||
Worm worm = facade.createWorm(world, new double[] { 1, 1.5 }, Math.PI / 2, 0.5, "Test", null);
|
||||
facade.move(worm);
|
||||
@@ -56,8 +56,7 @@ public class PartialPart2FacadeTest {
|
||||
assertEquals(1, xy[0], EPS);
|
||||
assertEquals(2.0, xy[1], EPS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
public void testFall() {
|
||||
// . X .
|
||||
// . w .
|
||||
|
Reference in New Issue
Block a user