Ejemplo n.º 1
0
  @Override
  public void onRoundStarted(final RoundStartedEvent event) {
    super.onRoundStarted(event);
    if (event.getRound() == 0) {
      IRobotSnapshot crazy = event.getStartSnapshot().getRobots()[0];
      IRobotSnapshot target = event.getStartSnapshot().getRobots()[1];

      Assert.assertNear(566.2968069, crazy.getX());
      Assert.assertNear(165.0789361, crazy.getY());
      Assert.assertNear(436.3146436, target.getX());
      Assert.assertNear(350.7235444, target.getY());
    }
  }
Ejemplo n.º 2
0
  @Override
  protected void runSetup() {
    File attack = new File("C:\\Robocode.attack");

    if (attack.exists()) {
      Assert.assertTrue(attack.delete());
    }
  }
Ejemplo n.º 3
0
  @Override
  public void onTurnEnded(TurnEndedEvent event) {
    super.onTurnEnded(event);
    lastTurn = event.getTurnSnapshot().getTurn();

    // System.out.println(event.getTurnSnapshot().getTurn());
    IRobotSnapshot crazy = event.getTurnSnapshot().getRobots()[0];
    IRobotSnapshot target = event.getTurnSnapshot().getRobots()[1];

    if (lastTurn == 1) {
      Assert.assertNear(565.4354411, crazy.getX());
      Assert.assertNear(164.5709508, crazy.getY());
      Assert.assertNear(436.3146436, target.getX());
      Assert.assertNear(350.7235444, target.getY());
    }

    if (lastTurn == 1700) {
      Assert.assertNear(38.69810137, crazy.getX());
      Assert.assertNear(214.9945902, crazy.getY());
      Assert.assertNear(339.9178023, target.getX());
      Assert.assertNear(455.7698379, target.getY());
    }
  }
Ejemplo n.º 4
0
 @Override
 protected void runTeardown() {
   Assert.assertTrue(messagedMax);
   Assert.assertTrue(messagedUnknown);
 }
Ejemplo n.º 5
0
  @Override
  public void onTurnEnded(TurnEndedEvent event) {
    super.onTurnEnded(event);
    turnNumber = event.getTurnSnapshot().getTurn();

    IRobotSnapshot rate = event.getTurnSnapshot().getRobots()[0];

    // Test turnRate
    if (turnNumber == 10) {
      Assert.assertNear(Math.PI / 4, normalRelativeAngle(rate.getBodyHeading() - originalHeading));
    }
    if (turnNumber == 20) {
      Assert.assertNear(-Math.PI / 4, normalRelativeAngle(rate.getBodyHeading() - originalHeading));
    }
    if (turnNumber == 25) {
      // Test that turnRate was set to zero
      Assert.assertNear(-Math.PI / 4, normalRelativeAngle(rate.getBodyHeading() - originalHeading));

      // Test velocityRate
      double theta = rate.getBodyHeading();
      double deltaX = rate.getX() - originalX;
      double distanceTravelled = deltaX / Math.sin(theta);

      Assert.assertNear(9, distanceTravelled);
    }
    if (turnNumber == 35) {
      double theta = rate.getBodyHeading();
      double deltaX = rate.getX() - originalX;
      double distanceTravelled = deltaX / Math.sin(theta);

      Assert.assertNear(-35, distanceTravelled);
      originalGunHeading = rate.getGunHeading();
    }
    if (turnNumber == 45) {
      // Test that velocityRate was set to zero
      double theta = rate.getBodyHeading();
      double deltaX = rate.getX() - originalX;
      double distanceTravelled = deltaX / Math.sin(theta);

      Assert.assertNear(-47, distanceTravelled);

      // test gunRotationRate
      Assert.assertNear(
          Math.PI / 2, normalRelativeAngle(rate.getGunHeading() - originalGunHeading));
    }
    if (turnNumber == 55) {
      Assert.assertNear(
          Math.PI / 4, normalRelativeAngle(rate.getGunHeading() - originalGunHeading));
      originalRadarHeading = rate.getRadarHeading();
    }

    if (turnNumber == 65) {
      // test that gunRotationRate was set to zero
      Assert.assertNear(
          Math.PI / 4, normalRelativeAngle(rate.getGunHeading() - originalGunHeading));

      // test radarRotationRate
      Assert.assertNear(
          Math.PI / 2, normalRelativeAngle(rate.getRadarHeading() - originalRadarHeading));
    }
    if (turnNumber == 75) {
      Assert.assertNear(
          Math.PI / 4, normalRelativeAngle(rate.getRadarHeading() - originalRadarHeading));
    }
    if (turnNumber == 76) {
      // test that radarRotationRate was set to zero
      Assert.assertNear(
          Math.PI / 4, normalRelativeAngle(rate.getRadarHeading() - originalRadarHeading));
    }
  }
Ejemplo n.º 6
0
 @Override
 protected void runTeardown() {
   Assert.assertTrue("Didn't seen preventing read", messagedRead);
   Assert.assertTrue("Didn't seen preventing write", messagedWrite);
   Assert.assertFalse("Found attack file", new File("C:\\Robocode.attack").exists());
 }
 @Override
 protected void runTeardown() {
   Assert.assertTrue(messagedScanned);
 }
Ejemplo n.º 8
0
 @Override
 protected void runTeardown() {
   Assert.assertTrue(messagedEvent);
   Assert.assertTrue(messagedBattle);
 }
Ejemplo n.º 9
0
 private void test(IRobotSnapshot gh, String s) {
   Assert.assertTrue(
       gh.getOutputStreamSnapshot() + " expected " + s,
       gh.getOutputStreamSnapshot().contains("after fire: " + s));
 }
Ejemplo n.º 10
0
 private void test(IRobotSnapshot gh, String s) {
   Assert.assertTrue(
       "got: " + gh.getOutputStreamSnapshot() + ", expected: " + s,
       gh.getOutputStreamSnapshot().contains(s));
 }
Ejemplo n.º 11
0
 @Override
 protected void runTeardown() {
   Assert.assertThat(lastTurn, is(1740));
 }