|
|
@@ -12,7 +12,7 @@ import org.junit.*;
|
|
|
|
import worms.facade.Facade;
|
|
|
|
import worms.facade.Facade;
|
|
|
|
import worms.facade.IFacade;
|
|
|
|
import worms.facade.IFacade;
|
|
|
|
import worms.internal.gui.game.IActionHandler;
|
|
|
|
import worms.internal.gui.game.IActionHandler;
|
|
|
|
import worms.programs.ProgramFactory;
|
|
|
|
import worms.programs.IProgramFactory;
|
|
|
|
import worms.programs.ProgramParser;
|
|
|
|
import worms.programs.ProgramParser;
|
|
|
|
import worms.util.*;
|
|
|
|
import worms.util.*;
|
|
|
|
|
|
|
|
|
|
|
@@ -27,7 +27,7 @@ public class Part3_FullFacadeTest {
|
|
|
|
|
|
|
|
|
|
|
|
private final static IFacade facade = new Facade();
|
|
|
|
private final static IFacade facade = new Facade();
|
|
|
|
private final static IActionHandler actionHandler = new SimpleActionHandler(facade);
|
|
|
|
private final static IActionHandler actionHandler = new SimpleActionHandler(facade);
|
|
|
|
private final static ProgramFactory programFactory = new ProgramFactory();
|
|
|
|
private final static IProgramFactory<?, ?, ?, ? extends Program> programFactory = facade.createProgramFactory();
|
|
|
|
|
|
|
|
|
|
|
|
private static final double[] FIXTURE_LOCATION = new double[] { 3.0, -7.0 };
|
|
|
|
private static final double[] FIXTURE_LOCATION = new double[] { 3.0, -7.0 };
|
|
|
|
private static final double FIXTURE_RADIUS = 0.30;
|
|
|
|
private static final double FIXTURE_RADIUS = 0.30;
|
|
|
@@ -73,6 +73,7 @@ public class Part3_FullFacadeTest {
|
|
|
|
System.out.println();
|
|
|
|
System.out.println();
|
|
|
|
System.out.println(" FINAL SCORE: " + score + "/" + max_score);
|
|
|
|
System.out.println(" FINAL SCORE: " + score + "/" + max_score);
|
|
|
|
System.out.println();
|
|
|
|
System.out.println();
|
|
|
|
|
|
|
|
if (max_score > 0)
|
|
|
|
System.out.println(" FINAL PERCENTAGE: " + Math.round(score * 100 / max_score) + "%");
|
|
|
|
System.out.println(" FINAL PERCENTAGE: " + Math.round(score * 100 / max_score) + "%");
|
|
|
|
System.out.println();
|
|
|
|
System.out.println();
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -130,7 +131,6 @@ public class Part3_FullFacadeTest {
|
|
|
|
return Math.sqrt(dx * dx + dy * dy);
|
|
|
|
return Math.sqrt(dx * dx + dy * dy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**************
|
|
|
|
/**************
|
|
|
|
* WORLD TESTS
|
|
|
|
* WORLD TESTS
|
|
|
|
*************/
|
|
|
|
*************/
|
|
|
@@ -218,7 +218,6 @@ public class Part3_FullFacadeTest {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
assertEquals(0, facade.getAllTeams(theWorld).size());
|
|
|
|
assertEquals(0, facade.getAllTeams(theWorld).size());
|
|
|
|
} catch (MustNotImplementException exc) {
|
|
|
|
} catch (MustNotImplementException exc) {
|
|
|
|
max_score -= 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
score += 1;
|
|
|
|
score += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -704,6 +703,7 @@ public class Part3_FullFacadeTest {
|
|
|
|
facade.decreaseNbActionPoints(worm, 20);
|
|
|
|
facade.decreaseNbActionPoints(worm, 20);
|
|
|
|
BigInteger nbHitPoints = facade.getNbHitPoints(worm);
|
|
|
|
BigInteger nbHitPoints = facade.getNbHitPoints(worm);
|
|
|
|
facade.startGame(theWorld);
|
|
|
|
facade.startGame(theWorld);
|
|
|
|
|
|
|
|
assertTrue(facade.hasActiveGame(theWorld));
|
|
|
|
assertEquals(worm, facade.getActiveWorm(theWorld));
|
|
|
|
assertEquals(worm, facade.getActiveWorm(theWorld));
|
|
|
|
assertEquals(facade.getMaxNbActionPoints(worm), facade.getNbActionPoints(worm));
|
|
|
|
assertEquals(facade.getMaxNbActionPoints(worm), facade.getNbActionPoints(worm));
|
|
|
|
assertEquals(nbHitPoints.add(BigInteger.TEN), facade.getNbHitPoints(worm));
|
|
|
|
assertEquals(nbHitPoints.add(BigInteger.TEN), facade.getNbHitPoints(worm));
|
|
|
@@ -721,8 +721,9 @@ public class Part3_FullFacadeTest {
|
|
|
|
facade.decreaseNbActionPoints(wormB, 20);
|
|
|
|
facade.decreaseNbActionPoints(wormB, 20);
|
|
|
|
BigInteger nbHitPointsB = facade.getNbHitPoints(wormB);
|
|
|
|
BigInteger nbHitPointsB = facade.getNbHitPoints(wormB);
|
|
|
|
facade.decreaseNbActionPoints(wormC, 20);
|
|
|
|
facade.decreaseNbActionPoints(wormC, 20);
|
|
|
|
BigInteger nbHitPointsC = facade.getNbHitPoints(wormA);
|
|
|
|
BigInteger nbHitPointsC = facade.getNbHitPoints(wormC);
|
|
|
|
facade.startGame(theWorld);
|
|
|
|
facade.startGame(theWorld);
|
|
|
|
|
|
|
|
assertTrue(facade.hasActiveGame(theWorld));
|
|
|
|
Worm activeWorm = facade.getActiveWorm(theWorld);
|
|
|
|
Worm activeWorm = facade.getActiveWorm(theWorld);
|
|
|
|
assertTrue(facade.getAllWorms(theWorld).contains(activeWorm));
|
|
|
|
assertTrue(facade.getAllWorms(theWorld).contains(activeWorm));
|
|
|
|
if (activeWorm == wormA) {
|
|
|
|
if (activeWorm == wormA) {
|
|
|
@@ -746,7 +747,7 @@ public class Part3_FullFacadeTest {
|
|
|
|
facade.createWorm(theWorld, new double[] { 7.95, 4.0 }, 0.1, 1.0, "Worm", null);
|
|
|
|
facade.createWorm(theWorld, new double[] { 7.95, 4.0 }, 0.1, 1.0, "Worm", null);
|
|
|
|
facade.startGame(theWorld);
|
|
|
|
facade.startGame(theWorld);
|
|
|
|
facade.finishGame(theWorld);
|
|
|
|
facade.finishGame(theWorld);
|
|
|
|
assertNull(facade.getActiveWorm(theWorld));
|
|
|
|
assertFalse(facade.hasActiveGame(theWorld));
|
|
|
|
score += 1;
|
|
|
|
score += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -755,7 +756,7 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score += 1;
|
|
|
|
max_score += 1;
|
|
|
|
facade.createWorm(theWorld, new double[] { 7.95, 4.0 }, 0.1, 1.0, "Worm", null);
|
|
|
|
facade.createWorm(theWorld, new double[] { 7.95, 4.0 }, 0.1, 1.0, "Worm", null);
|
|
|
|
facade.finishGame(theWorld);
|
|
|
|
facade.finishGame(theWorld);
|
|
|
|
assertNull(facade.getActiveWorm(theWorld));
|
|
|
|
assertFalse(facade.hasActiveGame(theWorld));
|
|
|
|
score += 1;
|
|
|
|
score += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -843,6 +844,7 @@ public class Part3_FullFacadeTest {
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 7.95, 4.0 }, 0.1, 1.0, "FirstWorm", null);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 7.95, 4.0 }, 0.1, 1.0, "FirstWorm", null);
|
|
|
|
Worm worm2 = facade.createWorm(theWorld, new double[] { 2.5, 7.95 }, 0.1, 1.0, "SecondWorm", null);
|
|
|
|
Worm worm2 = facade.createWorm(theWorld, new double[] { 2.5, 7.95 }, 0.1, 1.0, "SecondWorm", null);
|
|
|
|
Worm worm3 = facade.createWorm(theWorld, new double[] { 6.5, 7.95 }, 0.1, 1.0, "ThirdWorm", null);
|
|
|
|
Worm worm3 = facade.createWorm(theWorld, new double[] { 6.5, 7.95 }, 0.1, 1.0, "ThirdWorm", null);
|
|
|
|
|
|
|
|
try {
|
|
|
|
Team someTeam = facade.createTeam(theWorld, "SomeTeam");
|
|
|
|
Team someTeam = facade.createTeam(theWorld, "SomeTeam");
|
|
|
|
facade.addWormsToTeam(someTeam, worm1, worm3);
|
|
|
|
facade.addWormsToTeam(someTeam, worm1, worm3);
|
|
|
|
facade.startGame(theWorld);
|
|
|
|
facade.startGame(theWorld);
|
|
|
@@ -852,6 +854,9 @@ public class Part3_FullFacadeTest {
|
|
|
|
facade.activateNextWorm(theWorld);
|
|
|
|
facade.activateNextWorm(theWorld);
|
|
|
|
assertEquals(facade.getName(someTeam), facade.getWinner(theWorld));
|
|
|
|
assertEquals(facade.getName(someTeam), facade.getWinner(theWorld));
|
|
|
|
score += 4;
|
|
|
|
score += 4;
|
|
|
|
|
|
|
|
} catch (MustNotImplementException exc) {
|
|
|
|
|
|
|
|
max_score -= 4;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@@ -877,6 +882,7 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score += 1;
|
|
|
|
max_score += 1;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 7.95, 4.0 }, 0.1, 1.0, "FirstWorm", null);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 7.95, 4.0 }, 0.1, 1.0, "FirstWorm", null);
|
|
|
|
Worm worm2 = facade.createWorm(theWorld, new double[] { 2.5, 7.95 }, 0.1, 1.0, "SecondWorm", null);
|
|
|
|
Worm worm2 = facade.createWorm(theWorld, new double[] { 2.5, 7.95 }, 0.1, 1.0, "SecondWorm", null);
|
|
|
|
|
|
|
|
try {
|
|
|
|
Team teamA = facade.createTeam(theWorld, "TeamA");
|
|
|
|
Team teamA = facade.createTeam(theWorld, "TeamA");
|
|
|
|
facade.addWormsToTeam(teamA, worm1);
|
|
|
|
facade.addWormsToTeam(teamA, worm1);
|
|
|
|
Team teamB = facade.createTeam(theWorld, "TeamB");
|
|
|
|
Team teamB = facade.createTeam(theWorld, "TeamB");
|
|
|
@@ -884,6 +890,9 @@ public class Part3_FullFacadeTest {
|
|
|
|
facade.startGame(theWorld);
|
|
|
|
facade.startGame(theWorld);
|
|
|
|
assertNull(facade.getWinner(theWorld));
|
|
|
|
assertNull(facade.getWinner(theWorld));
|
|
|
|
score += 1;
|
|
|
|
score += 1;
|
|
|
|
|
|
|
|
} catch (MustNotImplementException exc) {
|
|
|
|
|
|
|
|
max_score -= 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@@ -891,11 +900,15 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score += 1;
|
|
|
|
max_score += 1;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 7.95, 4.0 }, 0.1, 1.0, "FirstWorm", null);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 7.95, 4.0 }, 0.1, 1.0, "FirstWorm", null);
|
|
|
|
facade.createWorm(theWorld, new double[] { 2.5, 7.95 }, 0.1, 1.0, "SecondWorm", null);
|
|
|
|
facade.createWorm(theWorld, new double[] { 2.5, 7.95 }, 0.1, 1.0, "SecondWorm", null);
|
|
|
|
|
|
|
|
try {
|
|
|
|
Team teamA = facade.createTeam(theWorld, "TeamA");
|
|
|
|
Team teamA = facade.createTeam(theWorld, "TeamA");
|
|
|
|
facade.addWormsToTeam(teamA, worm1);
|
|
|
|
facade.addWormsToTeam(teamA, worm1);
|
|
|
|
facade.startGame(theWorld);
|
|
|
|
facade.startGame(theWorld);
|
|
|
|
assertNull(facade.getWinner(theWorld));
|
|
|
|
assertNull(facade.getWinner(theWorld));
|
|
|
|
score += 1;
|
|
|
|
score += 1;
|
|
|
|
|
|
|
|
} catch (MustNotImplementException exc) {
|
|
|
|
|
|
|
|
max_score -= 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************
|
|
|
|
/**************
|
|
|
@@ -1133,7 +1146,7 @@ public class Part3_FullFacadeTest {
|
|
|
|
assertTrue(facade.getAllWormsOfTeam(theTeam).isEmpty());
|
|
|
|
assertTrue(facade.getAllWormsOfTeam(theTeam).isEmpty());
|
|
|
|
score += 1;
|
|
|
|
score += 1;
|
|
|
|
} catch (MustNotImplementException exc) {
|
|
|
|
} catch (MustNotImplementException exc) {
|
|
|
|
max_score = -1;
|
|
|
|
max_score -= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -1244,9 +1257,9 @@ public class Part3_FullFacadeTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void decreaseActionPoints_DeltaTooLarge() {
|
|
|
|
public void decreaseActionPoints_DeltaTooLarge() {
|
|
|
|
max_score += 1;
|
|
|
|
max_score += 1;
|
|
|
|
long oldNbActionPoints = facade.getNbActionPoints(fixtureWorm);
|
|
|
|
|
|
|
|
facade.decreaseNbActionPoints(fixtureWorm, Integer.MAX_VALUE);
|
|
|
|
facade.decreaseNbActionPoints(fixtureWorm, Integer.MAX_VALUE);
|
|
|
|
assertEquals(oldNbActionPoints, facade.getNbActionPoints(fixtureWorm));
|
|
|
|
assertTrue(0 <= facade.getNbActionPoints(fixtureWorm));
|
|
|
|
|
|
|
|
assertTrue(facade.getNbActionPoints(fixtureWorm) <= facade.getMaxNbActionPoints(fixtureWorm));
|
|
|
|
score += 1;
|
|
|
|
score += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -1257,7 +1270,8 @@ public class Part3_FullFacadeTest {
|
|
|
|
long maxNbActionPoints = facade.getMaxNbActionPoints(fixtureWorm);
|
|
|
|
long maxNbActionPoints = facade.getMaxNbActionPoints(fixtureWorm);
|
|
|
|
long delta = oldNbActionPoints - maxNbActionPoints - 10;
|
|
|
|
long delta = oldNbActionPoints - maxNbActionPoints - 10;
|
|
|
|
facade.decreaseNbActionPoints(fixtureWorm, delta);
|
|
|
|
facade.decreaseNbActionPoints(fixtureWorm, delta);
|
|
|
|
assertEquals(oldNbActionPoints, facade.getNbActionPoints(fixtureWorm));
|
|
|
|
assertTrue(0 <= facade.getNbActionPoints(fixtureWorm));
|
|
|
|
|
|
|
|
assertTrue(facade.getNbActionPoints(fixtureWorm) <= facade.getMaxNbActionPoints(fixtureWorm));
|
|
|
|
score += 1;
|
|
|
|
score += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -1509,8 +1523,10 @@ public class Part3_FullFacadeTest {
|
|
|
|
double[] newLocation = facade.getLocation(theWorm);
|
|
|
|
double[] newLocation = facade.getLocation(theWorm);
|
|
|
|
double[] expectedLocation = new double[] { 7.5, 8.0 };
|
|
|
|
double[] expectedLocation = new double[] { 7.5, 8.0 };
|
|
|
|
assertTrue(facade.isAdjacent(theWorld, newLocation, facade.getRadius(theWorm)));
|
|
|
|
assertTrue(facade.isAdjacent(theWorld, newLocation, facade.getRadius(theWorm)));
|
|
|
|
assertEquals(expectedLocation[0]+facade.getRadius(theWorm)*0.1/2.0, newLocation[0], facade.getRadius(theWorm)*0.12/2.0);
|
|
|
|
assertEquals(expectedLocation[0] + facade.getRadius(theWorm) * 0.1 / 2.0, newLocation[0],
|
|
|
|
assertEquals(expectedLocation[1]-facade.getRadius(theWorm)*0.1/2.0, newLocation[1], facade.getRadius(theWorm)*0.12/2.0);
|
|
|
|
facade.getRadius(theWorm) * 0.12 / 2.0);
|
|
|
|
|
|
|
|
assertEquals(expectedLocation[1] - facade.getRadius(theWorm) * 0.1 / 2.0, newLocation[1],
|
|
|
|
|
|
|
|
facade.getRadius(theWorm) * 0.12 / 2.0);
|
|
|
|
// We allow a deviation of +/-1 in calculating the action points.
|
|
|
|
// We allow a deviation of +/-1 in calculating the action points.
|
|
|
|
assertTrue((facade.getNbActionPoints(theWorm) >= oldNbActionPoints - 4)
|
|
|
|
assertTrue((facade.getNbActionPoints(theWorm) >= oldNbActionPoints - 4)
|
|
|
|
&& (facade.getNbActionPoints(theWorm) <= oldNbActionPoints - 2));
|
|
|
|
&& (facade.getNbActionPoints(theWorm) <= oldNbActionPoints - 2));
|
|
|
@@ -1520,15 +1536,15 @@ public class Part3_FullFacadeTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void move_OnlyPassableTerrainInDirection() {
|
|
|
|
public void move_OnlyPassableTerrainInDirection() {
|
|
|
|
max_score += 15;
|
|
|
|
max_score += 15;
|
|
|
|
Worm theWorm = facade.createWorm(theWorld, new double[] { 7.0, 3.0 }, PI, 2.0, "Worm", null);
|
|
|
|
Worm theWorm = facade.createWorm(theWorld, new double[] { 8.375, 3.0 }, PI, 0.6, "Worm", null);
|
|
|
|
long oldNbActionPoints = facade.getNbActionPoints(theWorm);
|
|
|
|
long oldNbActionPoints = facade.getNbActionPoints(theWorm);
|
|
|
|
facade.move(theWorm);
|
|
|
|
facade.move(theWorm);
|
|
|
|
double[] newLocation = facade.getLocation(theWorm);
|
|
|
|
double[] newLocation = facade.getLocation(theWorm);
|
|
|
|
assertEquals(7.0 - 2.0, newLocation[0], EPS);
|
|
|
|
assertEquals(8.375 - 0.6, newLocation[0], EPS);
|
|
|
|
assertEquals(3.0, newLocation[1], EPS);
|
|
|
|
assertEquals(3.0, newLocation[1], EPS);
|
|
|
|
// We allow a deviation of +/-1 in calculating the action points.
|
|
|
|
// We allow a deviation of +/-1 in calculating the action points.
|
|
|
|
assertTrue((facade.getNbActionPoints(theWorm) >= oldNbActionPoints - 3)
|
|
|
|
assertTrue((facade.getNbActionPoints(theWorm) >= oldNbActionPoints - 1)
|
|
|
|
&& (facade.getNbActionPoints(theWorm) <= oldNbActionPoints - 1));
|
|
|
|
&& (facade.getNbActionPoints(theWorm) <= oldNbActionPoints));
|
|
|
|
score += 15;
|
|
|
|
score += 15;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -1543,10 +1559,12 @@ public class Part3_FullFacadeTest {
|
|
|
|
// adjacent to the vertical wall.
|
|
|
|
// adjacent to the vertical wall.
|
|
|
|
double[] expectedLocation = new double[] { 8.0, 6.0 };
|
|
|
|
double[] expectedLocation = new double[] { 8.0, 6.0 };
|
|
|
|
assertTrue(facade.isAdjacent(theWorld, newLocation, facade.getRadius(theWorm)));
|
|
|
|
assertTrue(facade.isAdjacent(theWorld, newLocation, facade.getRadius(theWorm)));
|
|
|
|
assertEquals(expectedLocation[0]-facade.getRadius(theWorm)*0.1/2.0, newLocation[0], facade.getRadius(theWorm)*0.12/2.0);
|
|
|
|
assertEquals(expectedLocation[0] - facade.getRadius(theWorm) * 0.1 / 2.0, newLocation[0],
|
|
|
|
assertEquals(expectedLocation[1]-facade.getRadius(theWorm)*0.1/2.0, newLocation[1], facade.getRadius(theWorm)*0.12/2.0);
|
|
|
|
facade.getRadius(theWorm) * 0.12 / 2.0);
|
|
|
|
|
|
|
|
assertEquals(expectedLocation[1] - facade.getRadius(theWorm) * 0.1 / 2.0, newLocation[1],
|
|
|
|
|
|
|
|
facade.getRadius(theWorm) );
|
|
|
|
assertTrue((facade.getNbActionPoints(theWorm) >= oldNbActionPoints - 5)
|
|
|
|
assertTrue((facade.getNbActionPoints(theWorm) >= oldNbActionPoints - 5)
|
|
|
|
&& (facade.getNbActionPoints(theWorm) <= oldNbActionPoints - 3));
|
|
|
|
&& (facade.getNbActionPoints(theWorm) <= oldNbActionPoints - 1));
|
|
|
|
score += 15;
|
|
|
|
score += 15;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -1564,7 +1582,7 @@ public class Part3_FullFacadeTest {
|
|
|
|
{ true, true, true, true, false, true, true, true, true, false },
|
|
|
|
{ true, true, true, true, false, true, true, true, true, false },
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false }, };
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false }, };
|
|
|
|
World otherWorld = facade.createWorld(10.0, 10.0, map10x10);
|
|
|
|
World otherWorld = facade.createWorld(10.0, 10.0, map10x10);
|
|
|
|
Worm theWorm = facade.createWorm(otherWorld, new double[] { 7.0, 5.0 }, PI, 2.0, "Worm", null);
|
|
|
|
Worm theWorm = facade.createWorm(otherWorld, new double[] { 6.85, 5.0 }, PI, 2.0, "Worm", null);
|
|
|
|
long oldNbActionPoints = facade.getNbActionPoints(theWorm);
|
|
|
|
long oldNbActionPoints = facade.getNbActionPoints(theWorm);
|
|
|
|
facade.move(theWorm);
|
|
|
|
facade.move(theWorm);
|
|
|
|
double[] newLocation = facade.getLocation(theWorm);
|
|
|
|
double[] newLocation = facade.getLocation(theWorm);
|
|
|
@@ -1572,8 +1590,8 @@ public class Part3_FullFacadeTest {
|
|
|
|
assertTrue(facade.isAdjacent(otherWorld, newLocation, 2.0));
|
|
|
|
assertTrue(facade.isAdjacent(otherWorld, newLocation, 2.0));
|
|
|
|
double distanceToEdge = Math.sqrt(Math.pow(newLocation[0] - 5.0, 2.0) + Math.pow(newLocation[1] - 2.0, 2.0));
|
|
|
|
double distanceToEdge = Math.sqrt(Math.pow(newLocation[0] - 5.0, 2.0) + Math.pow(newLocation[1] - 2.0, 2.0));
|
|
|
|
assertEquals(2.1, distanceToEdge, 0.2);
|
|
|
|
assertEquals(2.1, distanceToEdge, 0.2);
|
|
|
|
assertTrue((facade.getNbActionPoints(theWorm) >= oldNbActionPoints - 5)
|
|
|
|
assertTrue((facade.getNbActionPoints(theWorm) >= oldNbActionPoints - 7)
|
|
|
|
&& (facade.getNbActionPoints(theWorm) <= oldNbActionPoints - 3));
|
|
|
|
&& (facade.getNbActionPoints(theWorm) <= oldNbActionPoints - 5));
|
|
|
|
score += 15;
|
|
|
|
score += 15;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -1591,7 +1609,7 @@ public class Part3_FullFacadeTest {
|
|
|
|
{ true, true, true, true, false, true, true, true, true, false },
|
|
|
|
{ true, true, true, true, false, true, true, true, true, false },
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false }, };
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false }, };
|
|
|
|
World otherWorld = facade.createWorld(10.0, 10.0, map10x10);
|
|
|
|
World otherWorld = facade.createWorld(10.0, 10.0, map10x10);
|
|
|
|
Worm theWorm = facade.createWorm(otherWorld, new double[] { 7.0, 5.0 }, PI, 2.0, "Worm", null);
|
|
|
|
Worm theWorm = facade.createWorm(otherWorld, new double[] { 6.85, 5.0 }, PI, 2.0, "Worm", null);
|
|
|
|
long oldNbActionPoints = facade.getNbActionPoints(theWorm);
|
|
|
|
long oldNbActionPoints = facade.getNbActionPoints(theWorm);
|
|
|
|
facade.move(theWorm);
|
|
|
|
facade.move(theWorm);
|
|
|
|
double[] newLocation = facade.getLocation(theWorm);
|
|
|
|
double[] newLocation = facade.getLocation(theWorm);
|
|
|
@@ -1602,8 +1620,8 @@ public class Part3_FullFacadeTest {
|
|
|
|
Math.sqrt(Math.pow(newLocation[0] - 5.0, 2.0) + Math.pow(newLocation[1] - 2.0, 2.0)),
|
|
|
|
Math.sqrt(Math.pow(newLocation[0] - 5.0, 2.0) + Math.pow(newLocation[1] - 2.0, 2.0)),
|
|
|
|
Math.sqrt(Math.pow(newLocation[0] - 5.0, 2.0) + Math.pow(newLocation[1] - 8.0, 2.0)));
|
|
|
|
Math.sqrt(Math.pow(newLocation[0] - 5.0, 2.0) + Math.pow(newLocation[1] - 8.0, 2.0)));
|
|
|
|
assertEquals(2.1, distanceToEdge, 0.2);
|
|
|
|
assertEquals(2.1, distanceToEdge, 0.2);
|
|
|
|
assertTrue((facade.getNbActionPoints(theWorm) >= oldNbActionPoints - 5)
|
|
|
|
assertTrue((facade.getNbActionPoints(theWorm) >= oldNbActionPoints - 7)
|
|
|
|
&& (facade.getNbActionPoints(theWorm) <= oldNbActionPoints - 3));
|
|
|
|
&& (facade.getNbActionPoints(theWorm) <= oldNbActionPoints - 5));
|
|
|
|
score += 15;
|
|
|
|
score += 15;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -1718,15 +1736,17 @@ public class Part3_FullFacadeTest {
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false },
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false },
|
|
|
|
{ true, true, true, true, false, true, true, true, true, false }, };
|
|
|
|
{ true, true, true, true, false, true, true, true, true, false }, };
|
|
|
|
World otherWorld = facade.createWorld(10.0, 10.0, map10x10);
|
|
|
|
World otherWorld = facade.createWorld(10.0, 10.0, map10x10);
|
|
|
|
Worm theWorm = facade.createWorm(otherWorld, new double[] { 4.5, 6.0 }, PI, 2.0, "Worm", null);
|
|
|
|
Worm theWorm = facade.createWorm(otherWorld, new double[] { 4.5, 7.375 }, 3 * PI / 2.0, 0.6, "Worm", null);
|
|
|
|
|
|
|
|
facade.move(theWorm);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
BigInteger oldNbHitPoints = facade.getNbHitPoints(theWorm);
|
|
|
|
BigInteger oldNbHitPoints = facade.getNbHitPoints(theWorm);
|
|
|
|
facade.fall(theWorm);
|
|
|
|
facade.fall(theWorm);
|
|
|
|
double[] newLocation = facade.getLocation(theWorm);
|
|
|
|
double[] newLocation = facade.getLocation(theWorm);
|
|
|
|
assertTrue(facade.isAdjacent(otherWorld, newLocation, facade.getRadius(theWorm)));
|
|
|
|
assertTrue(facade.isAdjacent(otherWorld, newLocation, facade.getRadius(theWorm)));
|
|
|
|
assertEquals(4.5, newLocation[0], EPS);
|
|
|
|
assertEquals(4.5, newLocation[0], EPS);
|
|
|
|
assertEquals(3.0+facade.getRadius(theWorm)*0.1/2.0, newLocation[1], facade.getRadius(theWorm)*0.12/2.0);
|
|
|
|
assertEquals(1.6 + facade.getRadius(theWorm) * 0.1 / 2.0, newLocation[1],
|
|
|
|
assertEquals(oldNbHitPoints.subtract(BigInteger.valueOf(9)),facade.getNbHitPoints(theWorm) );
|
|
|
|
facade.getRadius(theWorm) * 0.12 / 2.0);
|
|
|
|
|
|
|
|
assertEquals(oldNbHitPoints.subtract(BigInteger.valueOf(15)), facade.getNbHitPoints(theWorm));
|
|
|
|
score += 15;
|
|
|
|
score += 15;
|
|
|
|
} catch (MustNotImplementException exc) {
|
|
|
|
} catch (MustNotImplementException exc) {
|
|
|
|
max_score -= 15;
|
|
|
|
max_score -= 15;
|
|
|
@@ -1736,8 +1756,8 @@ public class Part3_FullFacadeTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void fall_InWorldOverlappingWorms() {
|
|
|
|
public void fall_InWorldOverlappingWorms() {
|
|
|
|
max_score += 12;
|
|
|
|
max_score += 12;
|
|
|
|
map10x10 = new boolean[][] { { true, true, true, true, true, true, true, true, true, false },
|
|
|
|
map10x10 = new boolean[][] { { false, false, false, false, false, false, false, false, false, false },
|
|
|
|
{ true, true, true, true, false, false, true, true, true, false },
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false },
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false },
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false },
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false },
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false },
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false },
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false },
|
|
|
@@ -1747,15 +1767,16 @@ public class Part3_FullFacadeTest {
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false },
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false },
|
|
|
|
{ true, true, true, false, false, false, true, true, true, false }, };
|
|
|
|
{ true, true, true, false, false, false, true, true, true, false }, };
|
|
|
|
World otherWorld = facade.createWorld(10.0, 10.0, map10x10);
|
|
|
|
World otherWorld = facade.createWorld(10.0, 10.0, map10x10);
|
|
|
|
Worm theWorm = facade.createWorm(otherWorld, new double[] { 4.5, 6.0 }, PI, 2.0, "Worm", null);
|
|
|
|
Worm theWorm = facade.createWorm(otherWorld, new double[] { 4.5, 8.375 }, 3 * PI / 2, 0.6, "Worm", null);
|
|
|
|
Worm worm1 = facade.createWorm(otherWorld, new double[] { 5.5, 2.0 }, PI, 1.0, "WormA", null);
|
|
|
|
Worm worm1 = facade.createWorm(otherWorld, new double[] { 4.8, 1.31 }, PI, 0.3, "WormA", null);
|
|
|
|
Worm worm2 = facade.createWorm(otherWorld, new double[] { 3.5, 2.0 }, PI, 1.0, "WormB", null);
|
|
|
|
Worm worm2 = facade.createWorm(otherWorld, new double[] { 4.2, 1.31 }, PI, 0.3, "WormB", null);
|
|
|
|
|
|
|
|
facade.move(theWorm);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
long oldNbHitPoints_TheWorm = facade.getNbHitPoints(theWorm).longValue();
|
|
|
|
long oldNbHitPoints_TheWorm = facade.getNbHitPoints(theWorm).longValue();
|
|
|
|
long oldNbHitPoints_worm1 = facade.getNbHitPoints(worm1).longValue();
|
|
|
|
long oldNbHitPoints_worm1 = facade.getNbHitPoints(worm1).longValue();
|
|
|
|
long oldNbHitPoints_worm2 = facade.getNbHitPoints(worm2).longValue();
|
|
|
|
long oldNbHitPoints_worm2 = facade.getNbHitPoints(worm2).longValue();
|
|
|
|
facade.fall(theWorm);
|
|
|
|
facade.fall(theWorm);
|
|
|
|
assertEquals(oldNbHitPoints_TheWorm - 9 + oldNbHitPoints_worm1 / 2 + oldNbHitPoints_worm2 / 2,
|
|
|
|
assertEquals(oldNbHitPoints_TheWorm - 18 + oldNbHitPoints_worm1 / 2 + oldNbHitPoints_worm2 / 2,
|
|
|
|
facade.getNbHitPoints(theWorm).longValue());
|
|
|
|
facade.getNbHitPoints(theWorm).longValue());
|
|
|
|
assertEquals(facade.getNbHitPoints(worm1).longValue(), oldNbHitPoints_worm1 / 2);
|
|
|
|
assertEquals(facade.getNbHitPoints(worm1).longValue(), oldNbHitPoints_worm1 / 2);
|
|
|
|
assertEquals(facade.getNbHitPoints(worm2).longValue(), oldNbHitPoints_worm2 / 2);
|
|
|
|
assertEquals(facade.getNbHitPoints(worm2).longValue(), oldNbHitPoints_worm2 / 2);
|
|
|
@@ -1769,7 +1790,8 @@ public class Part3_FullFacadeTest {
|
|
|
|
public void fall_OutOfWorld() {
|
|
|
|
public void fall_OutOfWorld() {
|
|
|
|
max_score += 6;
|
|
|
|
max_score += 6;
|
|
|
|
// Worm hanging on the ceiling.
|
|
|
|
// Worm hanging on the ceiling.
|
|
|
|
Worm theWorm = facade.createWorm(theWorld, new double[] { 3.0, 8.0 }, 3 * PI / 4.0, 1.0, "Worm", null);
|
|
|
|
Worm theWorm = facade.createWorm(theWorld, new double[] { 3.0, 8.375 }, 3 * PI / 2.0, 0.6, "Worm", null);
|
|
|
|
|
|
|
|
facade.move(theWorm);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
facade.fall(theWorm);
|
|
|
|
facade.fall(theWorm);
|
|
|
|
assertFalse(facade.hasAsWorm(theWorld, theWorm));
|
|
|
|
assertFalse(facade.hasAsWorm(theWorld, theWorm));
|
|
|
@@ -1779,7 +1801,8 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score -= 3;
|
|
|
|
max_score -= 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Worm hanging on side wall.
|
|
|
|
// Worm hanging on side wall.
|
|
|
|
Worm otherWorm = facade.createWorm(theWorld, new double[] { 8.0, 3.0 }, 3 * PI / 4.0, 1.0, "WormB", null);
|
|
|
|
Worm otherWorm = facade.createWorm(theWorld, new double[] { 8.375, 3.0 }, PI, 0.6, "WormB", null);
|
|
|
|
|
|
|
|
facade.move(otherWorm);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
facade.fall(otherWorm);
|
|
|
|
facade.fall(otherWorm);
|
|
|
|
assertFalse(facade.hasAsWorm(theWorld, otherWorm));
|
|
|
|
assertFalse(facade.hasAsWorm(theWorld, otherWorm));
|
|
|
@@ -1896,12 +1919,12 @@ public class Part3_FullFacadeTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void jumpTime_ReachingImpassableTerrain() {
|
|
|
|
public void jumpTime_ReachingImpassableTerrain() {
|
|
|
|
max_score += 14;
|
|
|
|
max_score += 14;
|
|
|
|
double[] worm_location = new double[] { 7.5, 6.5 };
|
|
|
|
double[] worm_location = new double[] { 7.5, 6.3 };
|
|
|
|
double worm_orientation = 3 * PI / 4.0;
|
|
|
|
double worm_orientation = 3 * PI / 4.0;
|
|
|
|
double worm_radius = 1.5;
|
|
|
|
double worm_radius = 1.5;
|
|
|
|
Worm theWorm = facade.createWorm(theWorld, worm_location, worm_orientation, worm_radius, "Worm", null);
|
|
|
|
Worm theWorm = facade.createWorm(theWorld, worm_location, worm_orientation, worm_radius, "Worm", null);
|
|
|
|
double jumpTime = facade.getJumpTime(theWorm, 0.01);
|
|
|
|
double jumpTime = facade.getJumpTime(theWorm, 0.01);
|
|
|
|
assertEquals(0.39, jumpTime, 0.05);
|
|
|
|
assertEquals(0.5, jumpTime, 0.2);
|
|
|
|
double[] locationAfterJump = facade.getJumpStep(theWorm, jumpTime);
|
|
|
|
double[] locationAfterJump = facade.getJumpStep(theWorm, jumpTime);
|
|
|
|
assertTrue(facade.isAdjacent(theWorld, locationAfterJump, worm_radius));
|
|
|
|
assertTrue(facade.isAdjacent(theWorld, locationAfterJump, worm_radius));
|
|
|
|
score += 14;
|
|
|
|
score += 14;
|
|
|
@@ -1915,8 +1938,9 @@ public class Part3_FullFacadeTest {
|
|
|
|
double worm_radius = 0.5;
|
|
|
|
double worm_radius = 0.5;
|
|
|
|
Worm theWorm = facade.createWorm(theWorld, worm_location, worm_orientation, worm_radius, "Worm", null);
|
|
|
|
Worm theWorm = facade.createWorm(theWorld, worm_location, worm_orientation, worm_radius, "Worm", null);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
facade.getJumpTime(theWorm, 0.05);
|
|
|
|
double jumpTime = facade.getJumpTime(theWorm, 0.05);
|
|
|
|
fail();
|
|
|
|
assertTrue(jumpTime >= 0.0);
|
|
|
|
|
|
|
|
score += 8;
|
|
|
|
} catch (ModelException exc) {
|
|
|
|
} catch (ModelException exc) {
|
|
|
|
score += 8;
|
|
|
|
score += 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -1951,7 +1975,7 @@ public class Part3_FullFacadeTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void jump_ReachingImpassableTerrain() {
|
|
|
|
public void jump_ReachingImpassableTerrain() {
|
|
|
|
max_score += 9;
|
|
|
|
max_score += 9;
|
|
|
|
double[] worm_location = new double[] { 7.5, 6.5 };
|
|
|
|
double[] worm_location = new double[] { 7.5, 6.3 };
|
|
|
|
double worm_orientation = 3 * PI / 4.0;
|
|
|
|
double worm_orientation = 3 * PI / 4.0;
|
|
|
|
double worm_radius = 1.5;
|
|
|
|
double worm_radius = 1.5;
|
|
|
|
Worm theWorm = facade.createWorm(theWorld, worm_location, worm_orientation, worm_radius, "Worm", null);
|
|
|
|
Worm theWorm = facade.createWorm(theWorld, worm_location, worm_orientation, worm_radius, "Worm", null);
|
|
|
@@ -1989,7 +2013,7 @@ public class Part3_FullFacadeTest {
|
|
|
|
long newNbHitPoints_worm1 = facade.getNbHitPoints(worm1).longValue();
|
|
|
|
long newNbHitPoints_worm1 = facade.getNbHitPoints(worm1).longValue();
|
|
|
|
assertTrue((newNbHitPoints_TheWorm < oldNbHitPoints_TheWorm) ^ (newNbHitPoints_worm1 < oldNbHitPoints_worm1));
|
|
|
|
assertTrue((newNbHitPoints_TheWorm < oldNbHitPoints_TheWorm) ^ (newNbHitPoints_worm1 < oldNbHitPoints_worm1));
|
|
|
|
assertTrue((newNbHitPoints_TheWorm == 0) || (newNbHitPoints_TheWorm >= oldNbHitPoints_TheWorm - 5));
|
|
|
|
assertTrue((newNbHitPoints_TheWorm == 0) || (newNbHitPoints_TheWorm >= oldNbHitPoints_TheWorm - 5));
|
|
|
|
assertTrue((newNbHitPoints_worm1 == 0) || (newNbHitPoints_worm1 >= oldNbHitPoints_TheWorm - 40));
|
|
|
|
assertTrue((newNbHitPoints_worm1 == 0) || (newNbHitPoints_worm1 >= oldNbHitPoints_worm1 - 40));
|
|
|
|
score += 11;
|
|
|
|
score += 11;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -2211,11 +2235,22 @@ public class Part3_FullFacadeTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void eat_EnlargedWormNotFullyInWorld() {
|
|
|
|
public void eat_EnlargedWormNotFullyInWorld() {
|
|
|
|
max_score += 8;
|
|
|
|
max_score += 8;
|
|
|
|
double[] worm_location = new double[] { 7.5, 1.505 };
|
|
|
|
map10x10 = new boolean[][] { { true, true, true, true, true, true, true, true, true, true },
|
|
|
|
|
|
|
|
{ true, true, true, true, true, true, true, true, true, true },
|
|
|
|
|
|
|
|
{ true, true, true, true, true, true, true, true, true, true },
|
|
|
|
|
|
|
|
{ true, true, true, true, true, true, true, true, true, true },
|
|
|
|
|
|
|
|
{ true, true, true, true, true, true, true, true, true, true },
|
|
|
|
|
|
|
|
{ true, true, true, true, true, true, true, false, false, false },
|
|
|
|
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false },
|
|
|
|
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false },
|
|
|
|
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false },
|
|
|
|
|
|
|
|
{ true, true, true, true, true, true, true, true, true, false } };
|
|
|
|
|
|
|
|
World theWorld = facade.createWorld(10.0, 10.0, map10x10);
|
|
|
|
|
|
|
|
double[] worm_location = new double[] { 6.995, 1.95 };
|
|
|
|
double worm_orientation = 3 * PI / 2.0;
|
|
|
|
double worm_orientation = 3 * PI / 2.0;
|
|
|
|
double worm_radius = 1.5;
|
|
|
|
double worm_radius = 1.9;
|
|
|
|
Worm theWorm = facade.createWorm(theWorld, worm_location, worm_orientation, worm_radius, "Worm", null);
|
|
|
|
Worm theWorm = facade.createWorm(theWorld, worm_location, worm_orientation, worm_radius, "Worm", null);
|
|
|
|
double[] location = new double[] { 8.795, 1.5 };
|
|
|
|
double[] location = new double[] { 8.795, 1.9 };
|
|
|
|
Food newFood = facade.createFood(theWorld, location);
|
|
|
|
Food newFood = facade.createFood(theWorld, location);
|
|
|
|
long oldNbActionPoints = facade.getNbActionPoints(theWorm);
|
|
|
|
long oldNbActionPoints = facade.getNbActionPoints(theWorm);
|
|
|
|
facade.eat(theWorm);
|
|
|
|
facade.eat(theWorm);
|
|
|
@@ -2432,9 +2467,9 @@ public class Part3_FullFacadeTest {
|
|
|
|
facade.createWorm(theWorld, new double[] { 7.5, 7.5 }, 0.0, 1.5, "Other", null);
|
|
|
|
facade.createWorm(theWorld, new double[] { 7.5, 7.5 }, 0.0, 1.5, "Other", null);
|
|
|
|
Projectile projectile = facade.fire(theWorm);
|
|
|
|
Projectile projectile = facade.fire(theWorm);
|
|
|
|
double jumpTime = facade.getJumpTime(projectile, 0.00001);
|
|
|
|
double jumpTime = facade.getJumpTime(projectile, 0.00001);
|
|
|
|
assertTrue((Math.abs(jumpTime - 0.08) < 0.01) || (Math.abs(jumpTime - 0.53) < 0.01));
|
|
|
|
assertTrue((Math.abs(jumpTime - 0.08) < 0.05) || (Math.abs(jumpTime - 0.53) < 0.4));
|
|
|
|
double[] locationAfterJump = facade.getJumpStep(projectile, jumpTime);
|
|
|
|
double[] locationAfterJump = facade.getJumpStep(projectile, jumpTime);
|
|
|
|
assertTrue(locationAfterJump[1] >= 6.0 - facade.getRadius(projectile));
|
|
|
|
assertTrue(locationAfterJump[1] >= 5.9 - facade.getRadius(projectile));
|
|
|
|
score += 8;
|
|
|
|
score += 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -2447,8 +2482,9 @@ public class Part3_FullFacadeTest {
|
|
|
|
Worm theWorm = facade.createWorm(theWorld, worm_location, worm_orientation, worm_radius, "Worm", null);
|
|
|
|
Worm theWorm = facade.createWorm(theWorld, worm_location, worm_orientation, worm_radius, "Worm", null);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Projectile projectile = facade.fire(theWorm);
|
|
|
|
Projectile projectile = facade.fire(theWorm);
|
|
|
|
facade.getJumpTime(projectile, 0.00001);
|
|
|
|
double jumpTime = facade.getJumpTime(projectile, 0.00001);
|
|
|
|
fail();
|
|
|
|
assertTrue(jumpTime >= 0.0);
|
|
|
|
|
|
|
|
score += 6;
|
|
|
|
} catch (ModelException exc) {
|
|
|
|
} catch (ModelException exc) {
|
|
|
|
score += 6;
|
|
|
|
score += 6;
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -2484,7 +2520,7 @@ public class Part3_FullFacadeTest {
|
|
|
|
Projectile projectile = facade.fire(theWorm);
|
|
|
|
Projectile projectile = facade.fire(theWorm);
|
|
|
|
facade.jump(projectile, 0.00001);
|
|
|
|
facade.jump(projectile, 0.00001);
|
|
|
|
assertTrue(oldNbHitPoints1.compareTo(facade.getNbHitPoints(hittedWorm1)) > 0);
|
|
|
|
assertTrue(oldNbHitPoints1.compareTo(facade.getNbHitPoints(hittedWorm1)) > 0);
|
|
|
|
assertTrue(oldNbHitPoints2.compareTo(facade.getNbHitPoints(hittedWorm2)) > 0);
|
|
|
|
assertTrue(oldNbHitPoints2.compareTo(facade.getNbHitPoints(hittedWorm2)) >= 0);
|
|
|
|
assertTrue(facade.isTerminated(projectile));
|
|
|
|
assertTrue(facade.isTerminated(projectile));
|
|
|
|
score += 6;
|
|
|
|
score += 6;
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -2499,7 +2535,8 @@ public class Part3_FullFacadeTest {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Projectile projectile = facade.fire(theWorm);
|
|
|
|
Projectile projectile = facade.fire(theWorm);
|
|
|
|
facade.jump(projectile, 0.0001);
|
|
|
|
facade.jump(projectile, 0.0001);
|
|
|
|
fail();
|
|
|
|
assertFalse(facade.getAllItems(theWorld).contains(projectile));
|
|
|
|
|
|
|
|
score += 4;
|
|
|
|
} catch (ModelException exc) {
|
|
|
|
} catch (ModelException exc) {
|
|
|
|
score += 4;
|
|
|
|
score += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -2985,20 +3022,26 @@ public class Part3_FullFacadeTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void castSpell_WormsSameTeam() {
|
|
|
|
public void castSpell_WormsSameTeam() {
|
|
|
|
max_score += 4;
|
|
|
|
max_score += 4;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, FIXTURE_DIRECTION, 1.5, "WormA", theTeam);
|
|
|
|
try {
|
|
|
|
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, FIXTURE_DIRECTION, 1.5, "WormA", null);
|
|
|
|
BigInteger nbHitPoints1 = facade.getNbHitPoints(worm1);
|
|
|
|
BigInteger nbHitPoints1 = facade.getNbHitPoints(worm1);
|
|
|
|
Worm worm2 = facade.createWorm(theWorld, new double[] { 6.0, 7.5 }, FIXTURE_DIRECTION, 1.5, "WormB", theTeam);
|
|
|
|
Worm worm2 = facade.createWorm(theWorld, new double[] { 6.0, 7.5 }, FIXTURE_DIRECTION, 1.5, "WormB", null);
|
|
|
|
BigInteger nbHitPoints2 = facade.getNbHitPoints(worm2);
|
|
|
|
BigInteger nbHitPoints2 = facade.getNbHitPoints(worm2);
|
|
|
|
|
|
|
|
facade.addWormsToTeam(theTeam, worm1, worm2);
|
|
|
|
facade.castSpell(theWorld);
|
|
|
|
facade.castSpell(theWorld);
|
|
|
|
BigInteger expectedNbHitPoints = nbHitPoints1.add(nbHitPoints2).divide(BigInteger.valueOf(2));
|
|
|
|
BigInteger expectedNbHitPoints = nbHitPoints1.add(nbHitPoints2).divide(BigInteger.valueOf(2));
|
|
|
|
assertEquals(expectedNbHitPoints, facade.getNbHitPoints(worm1));
|
|
|
|
assertEquals(expectedNbHitPoints, facade.getNbHitPoints(worm1));
|
|
|
|
assertEquals(expectedNbHitPoints, facade.getNbHitPoints(worm2));
|
|
|
|
assertEquals(expectedNbHitPoints, facade.getNbHitPoints(worm2));
|
|
|
|
score += 4;
|
|
|
|
score += 4;
|
|
|
|
|
|
|
|
} catch (MustNotImplementException exc) {
|
|
|
|
|
|
|
|
max_score -= 4;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void castSpell_WormsDifferentTeams() {
|
|
|
|
public void castSpell_WormsDifferentTeams() {
|
|
|
|
max_score += 4;
|
|
|
|
max_score += 4;
|
|
|
|
|
|
|
|
try {
|
|
|
|
Worm largestWorm = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, FIXTURE_DIRECTION, 1.5, "WormA",
|
|
|
|
Worm largestWorm = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, FIXTURE_DIRECTION, 1.5, "WormA",
|
|
|
|
theTeam);
|
|
|
|
theTeam);
|
|
|
|
long nbActionPointsLargest = facade.getNbActionPoints(largestWorm);
|
|
|
|
long nbActionPointsLargest = facade.getNbActionPoints(largestWorm);
|
|
|
@@ -3011,6 +3054,9 @@ public class Part3_FullFacadeTest {
|
|
|
|
assertEquals(nbActionPointsLargest - actionPointsToTransfer, facade.getNbActionPoints(largestWorm));
|
|
|
|
assertEquals(nbActionPointsLargest - actionPointsToTransfer, facade.getNbActionPoints(largestWorm));
|
|
|
|
assertEquals(nbActionPointsSmallest + actionPointsToTransfer, facade.getNbActionPoints(smallestWorm));
|
|
|
|
assertEquals(nbActionPointsSmallest + actionPointsToTransfer, facade.getNbActionPoints(smallestWorm));
|
|
|
|
score += 4;
|
|
|
|
score += 4;
|
|
|
|
|
|
|
|
} catch (MustNotImplementException exc) {
|
|
|
|
|
|
|
|
max_score -= 4;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@@ -3081,10 +3127,14 @@ public class Part3_FullFacadeTest {
|
|
|
|
int oldNbHitPoints2 = facade.getNbHitPoints(projectile2);
|
|
|
|
int oldNbHitPoints2 = facade.getNbHitPoints(projectile2);
|
|
|
|
facade.terminate(theWorm);
|
|
|
|
facade.terminate(theWorm);
|
|
|
|
facade.castSpell(theWorld);
|
|
|
|
facade.castSpell(theWorld);
|
|
|
|
assertTrue((facade.getNbHitPoints(projectile1) == oldNbHitPoints1 + 2) || (oldNbHitPoints1 == 7)
|
|
|
|
int newNbHitPoints1 = facade.getNbHitPoints(projectile1);
|
|
|
|
|| (oldNbHitPoints1 == 10));
|
|
|
|
int newNbHitPoints2 = facade.getNbHitPoints(projectile2);
|
|
|
|
assertTrue((facade.getNbHitPoints(projectile2) == oldNbHitPoints2 + 2) || (oldNbHitPoints2 == 7)
|
|
|
|
assertTrue((newNbHitPoints1 == oldNbHitPoints1 + 2)
|
|
|
|
|| (oldNbHitPoints2 == 10));
|
|
|
|
|| (newNbHitPoints1 == 7 && newNbHitPoints1 - oldNbHitPoints1 < 2)
|
|
|
|
|
|
|
|
|| (newNbHitPoints1 == 10 && newNbHitPoints1 - oldNbHitPoints1 < 2));
|
|
|
|
|
|
|
|
assertTrue((newNbHitPoints2 == oldNbHitPoints2 + 2)
|
|
|
|
|
|
|
|
|| (newNbHitPoints2 == 7 && newNbHitPoints2 - oldNbHitPoints2 < 2)
|
|
|
|
|
|
|
|
|| (newNbHitPoints2 == 10 && newNbHitPoints2 - oldNbHitPoints2 < 2));
|
|
|
|
score += 4;
|
|
|
|
score += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -3233,9 +3283,9 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score += 10;
|
|
|
|
max_score += 10;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
String code = "def p: print 4.0; p := 7.0;";
|
|
|
|
String code = "def p: print 4.0; p := 7.0;";
|
|
|
|
|
|
|
|
try {
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
try {
|
|
|
|
|
|
|
|
facade.executeProgram(worm1);
|
|
|
|
facade.executeProgram(worm1);
|
|
|
|
fail();
|
|
|
|
fail();
|
|
|
|
} catch (ModelException exc) {
|
|
|
|
} catch (ModelException exc) {
|
|
|
@@ -3423,6 +3473,7 @@ public class Part3_FullFacadeTest {
|
|
|
|
public void testEatStatement_NotEnoughActionPoints() throws ModelException {
|
|
|
|
public void testEatStatement_NotEnoughActionPoints() throws ModelException {
|
|
|
|
max_score += 4;
|
|
|
|
max_score += 4;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 7.5, 5.5 }, 7 * PI / 12.0, 1.5, "WormA", theTeam);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 7.5, 5.5 }, 7 * PI / 12.0, 1.5, "WormA", theTeam);
|
|
|
|
|
|
|
|
facade.createFood(theWorld, new double[] { 8.795, 5.5 });
|
|
|
|
String code = "eat; ";
|
|
|
|
String code = "eat; ";
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
@@ -3634,6 +3685,8 @@ public class Part3_FullFacadeTest {
|
|
|
|
String code = "print 1.0; v := 1.0; while true { v := v + 1.0; print v; if 4.5 < v break; } print 10.0;";
|
|
|
|
String code = "print 1.0; v := 1.0; while true { v := v + 1.0; print v; if 4.5 < v break; } print 10.0;";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
if (program == null)
|
|
|
|
|
|
|
|
throw new MustNotImplementException();
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
Object[] expecteds = { 1.0, 2.0, 3.0, 4.0, 5.0, 10.0 };
|
|
|
|
Object[] expecteds = { 1.0, 2.0, 3.0, 4.0, 5.0, 10.0 };
|
|
|
@@ -3651,6 +3704,8 @@ public class Part3_FullFacadeTest {
|
|
|
|
String code = "print 1.0; v := 1.0; while true { v := v + 1.0; { print v; if 4.5 < v break; print 0.0;} } print 10.0;";
|
|
|
|
String code = "print 1.0; v := 1.0; while true { v := v + 1.0; { print v; if 4.5 < v break; print 0.0;} } print 10.0;";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
if (program == null)
|
|
|
|
|
|
|
|
throw new MustNotImplementException();
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
Object[] expecteds = { 1.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0, 5.0, 10.0 };
|
|
|
|
Object[] expecteds = { 1.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0, 5.0, 10.0 };
|
|
|
@@ -3666,13 +3721,17 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score += 8;
|
|
|
|
max_score += 8;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
String code = "v := true; while v {print v; v := false; } break;";
|
|
|
|
String code = "v := true; while v {print v; v := false; } break;";
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
if (program == null)
|
|
|
|
|
|
|
|
throw new MustNotImplementException();
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
facade.executeProgram(worm1);
|
|
|
|
facade.executeProgram(worm1);
|
|
|
|
fail();
|
|
|
|
fail();
|
|
|
|
} catch (ModelException exc) {
|
|
|
|
} catch (ModelException exc) {
|
|
|
|
score += 8;
|
|
|
|
score += 8;
|
|
|
|
|
|
|
|
} catch (MustNotImplementException exc) {
|
|
|
|
|
|
|
|
max_score -= 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -3681,9 +3740,11 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score += 12;
|
|
|
|
max_score += 12;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
String code = "def p: { print 10.0; break; print 15.0; } print 0.0; invoke p; print 20.0;";
|
|
|
|
String code = "def p: { print 10.0; break; print 15.0; } print 0.0; invoke p; print 20.0;";
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
if (program == null)
|
|
|
|
|
|
|
|
throw new MustNotImplementException();
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
Object[] expecteds = { 0.0, 10.0, 20.0 };
|
|
|
|
Object[] expecteds = { 0.0, 10.0, 20.0 };
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
@@ -3698,9 +3759,11 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score += 20;
|
|
|
|
max_score += 20;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
String code = "def p: { print 1.0; while true { print 2.0; break; } print 3.0; break; print 4.0;} def g: { print 10.0; invoke p; print 20.0; break; print 30.0; } print 0.0; invoke g; print 100.0;";
|
|
|
|
String code = "def p: { print 1.0; while true { print 2.0; break; } print 3.0; break; print 4.0;} def g: { print 10.0; invoke p; print 20.0; break; print 30.0; } print 0.0; invoke g; print 100.0;";
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
if (program == null)
|
|
|
|
|
|
|
|
throw new MustNotImplementException();
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
Object[] expecteds = { 0.0, 10.0, 1.0, 2.0, 3.0, 20.0, 100.0 };
|
|
|
|
Object[] expecteds = { 0.0, 10.0, 1.0, 2.0, 3.0, 20.0, 100.0 };
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
@@ -3715,9 +3778,11 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score += 4;
|
|
|
|
max_score += 4;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
String code = "invoke p;";
|
|
|
|
String code = "invoke p;";
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
if (program == null)
|
|
|
|
|
|
|
|
throw new MustNotImplementException();
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
facade.executeProgram(worm1);
|
|
|
|
facade.executeProgram(worm1);
|
|
|
|
fail();
|
|
|
|
fail();
|
|
|
|
} catch (ModelException exc) {
|
|
|
|
} catch (ModelException exc) {
|
|
|
@@ -3732,9 +3797,11 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score += 6;
|
|
|
|
max_score += 6;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
String code = "def p: print 4.0; print 1.0; invoke p; print 7.0; invoke p; print 10.0;";
|
|
|
|
String code = "def p: print 4.0; print 1.0; invoke p; print 7.0; invoke p; print 10.0;";
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
if (program == null)
|
|
|
|
|
|
|
|
throw new MustNotImplementException();
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
Object[] expecteds = { 1.0, 4.0, 7.0, 4.0, 10.0 };
|
|
|
|
Object[] expecteds = { 1.0, 4.0, 7.0, 4.0, 10.0 };
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
@@ -3749,9 +3816,11 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score += 4;
|
|
|
|
max_score += 4;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
String code = "def p: print 4.0; def p: print 8.0; print 1.0; invoke p; print 7.0; ";
|
|
|
|
String code = "def p: print 4.0; def p: print 8.0; print 1.0; invoke p; print 7.0; ";
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
if (program == null)
|
|
|
|
|
|
|
|
throw new MustNotImplementException();
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
Object[] expecteds = { 1.0, 8.0, 7.0 };
|
|
|
|
Object[] expecteds = { 1.0, 8.0, 7.0 };
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
@@ -3766,9 +3835,11 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score += 8;
|
|
|
|
max_score += 8;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
String code = "def p: a := 10; invoke p; print a;";
|
|
|
|
String code = "def p: a := 10; invoke p; print a;";
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
if (program == null)
|
|
|
|
|
|
|
|
throw new MustNotImplementException();
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
Object[] expecteds = { 10.0 };
|
|
|
|
Object[] expecteds = { 10.0 };
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
@@ -3783,9 +3854,11 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score += 10;
|
|
|
|
max_score += 10;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
String code = "def p: a := a + 10.0; a := 3; invoke p; print a;";
|
|
|
|
String code = "def p: a := a + 10.0; a := 3; invoke p; print a;";
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
if (program == null)
|
|
|
|
|
|
|
|
throw new MustNotImplementException();
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
Object[] expecteds = { 13.0 };
|
|
|
|
Object[] expecteds = { 13.0 };
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
@@ -3800,9 +3873,11 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score += 10;
|
|
|
|
max_score += 10;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
String code = "def p: print 1.0; def g: { print 2.0; invoke p; print 3.0; } invoke g; ";
|
|
|
|
String code = "def p: print 1.0; def g: { print 2.0; invoke p; print 3.0; } invoke g; ";
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
if (program == null)
|
|
|
|
|
|
|
|
throw new MustNotImplementException();
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
Object[] expecteds = { 2.0, 1.0, 3.0 };
|
|
|
|
Object[] expecteds = { 2.0, 1.0, 3.0 };
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
@@ -3817,9 +3892,11 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score += 35;
|
|
|
|
max_score += 35;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
String code = "def p: { print a; if a < 5.5 { a := a + 1.0; invoke p; } } a := 0.0; invoke p; print a + 1.0;";
|
|
|
|
String code = "def p: { print a; if a < 5.5 { a := a + 1.0; invoke p; } } a := 0.0; invoke p; print a + 1.0;";
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
if (program == null)
|
|
|
|
|
|
|
|
throw new MustNotImplementException();
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
Object[] expecteds = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 };
|
|
|
|
Object[] expecteds = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 };
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
@@ -3834,10 +3911,12 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score += 25;
|
|
|
|
max_score += 25;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
String code = "def p: { print a; a := a + 5.0; jump; print a; } a := 10.0; invoke p; print a + 1.0;";
|
|
|
|
String code = "def p: { print a; a := a + 5.0; jump; print a; } a := 10.0; invoke p; print a + 1.0;";
|
|
|
|
|
|
|
|
try {
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
if (program == null)
|
|
|
|
|
|
|
|
throw new MustNotImplementException();
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
facade.decreaseNbActionPoints(worm1, facade.getNbActionPoints(worm1));
|
|
|
|
facade.decreaseNbActionPoints(worm1, facade.getNbActionPoints(worm1));
|
|
|
|
try {
|
|
|
|
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
assertNull(results);
|
|
|
|
assertNull(results);
|
|
|
|
facade.decreaseNbActionPoints(worm1, -facade.getMaxNbActionPoints(worm1));
|
|
|
|
facade.decreaseNbActionPoints(worm1, -facade.getMaxNbActionPoints(worm1));
|
|
|
@@ -3850,11 +3929,6 @@ public class Part3_FullFacadeTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// break statement
|
|
|
|
|
|
|
|
// nested break statements
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Assignment: assignment to variable with same name as procedure.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******************
|
|
|
|
/*******************
|
|
|
|
* EXPRESSION TESTS
|
|
|
|
* EXPRESSION TESTS
|
|
|
|
*******************/
|
|
|
|
*******************/
|
|
|
@@ -4122,9 +4196,11 @@ public class Part3_FullFacadeTest {
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
facade.createWorm(theWorld, new double[] { 6.0, 7.5 }, FIXTURE_DIRECTION, 1.5, "WormB", theTeam);
|
|
|
|
facade.createWorm(theWorld, new double[] { 6.0, 7.5 }, FIXTURE_DIRECTION, 1.5, "WormB", theTeam);
|
|
|
|
String code = "print sameteam searchobj 0.0;";
|
|
|
|
String code = "print sameteam searchobj 0.0;";
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
if (program == null)
|
|
|
|
|
|
|
|
throw new MustNotImplementException();
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
Object[] expecteds = { true };
|
|
|
|
Object[] expecteds = { true };
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
@@ -4140,9 +4216,11 @@ public class Part3_FullFacadeTest {
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
facade.createWorm(theWorld, new double[] { 6.0, 7.5 }, FIXTURE_DIRECTION, 1.5, "WormB", null);
|
|
|
|
facade.createWorm(theWorld, new double[] { 6.0, 7.5 }, FIXTURE_DIRECTION, 1.5, "WormB", null);
|
|
|
|
String code = "print sameteam searchobj 0.0;";
|
|
|
|
String code = "print sameteam searchobj 0.0;";
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
if (program == null)
|
|
|
|
|
|
|
|
throw new MustNotImplementException();
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
Object[] expecteds = { false };
|
|
|
|
Object[] expecteds = { false };
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
@@ -4157,9 +4235,11 @@ public class Part3_FullFacadeTest {
|
|
|
|
max_score += 3;
|
|
|
|
max_score += 3;
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", theTeam);
|
|
|
|
String code = "print sameteam null;";
|
|
|
|
String code = "print sameteam null;";
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
|
|
|
|
if (program == null)
|
|
|
|
|
|
|
|
throw new MustNotImplementException();
|
|
|
|
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
List<Object> results = facade.executeProgram(worm1);
|
|
|
|
Object[] expecteds = { false };
|
|
|
|
Object[] expecteds = { false };
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
|
assertArrayEquals(expecteds, results.toArray());
|
|
|
@@ -4175,9 +4255,9 @@ public class Part3_FullFacadeTest {
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", null);
|
|
|
|
Worm worm1 = facade.createWorm(theWorld, new double[] { 2.0, 7.5 }, 0.0, 1.5, "WormA", null);
|
|
|
|
facade.createFood(theWorld, new double[] { 8.795, 7.5 });
|
|
|
|
facade.createFood(theWorld, new double[] { 8.795, 7.5 });
|
|
|
|
String code = "print sameteam searchobj 0.0;";
|
|
|
|
String code = "print sameteam searchobj 0.0;";
|
|
|
|
|
|
|
|
try {
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
Program program = ProgramParser.parseProgramFromString(code, programFactory);
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
facade.loadProgramOnWorm(worm1, program, actionHandler);
|
|
|
|
try {
|
|
|
|
|
|
|
|
facade.executeProgram(worm1);
|
|
|
|
facade.executeProgram(worm1);
|
|
|
|
fail();
|
|
|
|
fail();
|
|
|
|
} catch (ModelException exc) {
|
|
|
|
} catch (ModelException exc) {
|
|
|
|